Rebound (another pong)
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: Rebound (another pong)
reuploaded again. sigh
- Felipe Budinich
- Citizen
- Posts: 67
- Joined: Thu Jul 29, 2010 1:36 pm
Re: Rebound (another pong)
I did a vivisectionof your code and found a mistake on the paddle's AI, that makes them go back and forth (like if they were shaking).
Not really noticeable, unless you replace the particles with another kind of display (like a rectangle or something).
Currently you've got this:
and it "should" be
That way, the paddle will move only the distance needed, and not the max distance possible on each update. If i'm not making sense, it's because i'm mucho hungover but the thing is, that it works better.
Not really noticeable, unless you replace the particles with another kind of display (like a rectangle or something).
Currently you've got this:
Code: Select all
if balls[1].live==false and ai1 and ai2 then
for _,b in ipairs(balls) do
b:start()
end
end
if ai1 then
local p = paddles[1]
if p.p.y+30 < balls[1].p.y then
p.p.y = p.p.y + p.spd*dt
elseif p.p.y-30 > balls[1].p.y then
p.p.y = p.p.y - p.spd*dt
end
end
if ai2 then
local p = paddles[2]
if p.p.y < balls[1].p.y then
p.p.y = p.p.y + p.spd*dt
elseif p.p.y > balls[1].p.y then
p.p.y = p.p.y - p.spd*dt
end
end
Code: Select all
if ai2 then
local p = paddles[2]
if p.p.y - 32 > balls[1].p.y then
p.p.y = p.p.y - p.spd*dt
if p.p.y < balls[1].p.y then
p.p.y = balls[1].p.y
end
elseif p.p.y + 32 < balls[1].p.y then
p.p.y = p.p.y + p.spd*dt
if p.p.y > balls[1].p.y then
p.p.y = balls[1].p.y
end
end
end
if ai1 then
local p = paddles[1]
if p.p.y + 32 > balls[1].p.y then
p.p.y = p.p.y - p.spd*dt
if p.p.y < balls[1].p.y then
p.p.y = balls[1].p.y
end
elseif p.p.y - 32 < balls[1].p.y then
p.p.y = p.p.y + p.spd*dt
if p.p.y > balls[1].p.y then
p.p.y = balls[1].p.y
end
end
end
Last edited by Felipe Budinich on Sat Aug 14, 2010 4:38 pm, edited 3 times in total.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Rebound (another pong)
You could of course use math.min there.
Re: Rebound (another pong)
Entertaining game! Power ups are awesome! Would like to see this on an IPhone or something
Pure prettyness!
12 on a role-play die!
Pure prettyness!
12 on a role-play die!
- Felipe Budinich
- Citizen
- Posts: 67
- Joined: Thu Jul 29, 2010 1:36 pm
Re: Rebound (another pong)
I'm trying to understand hmmm....bartbes wrote:You could of course use math.min there.
paddle position = math.min( paddle position + speed , ball position )
will go and try :-p
Ps: you've got to use math.min and math.max (depending on the movement direction)
Last edited by Felipe Budinich on Sun Aug 15, 2010 7:05 pm, edited 1 time in total.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Rebound (another pong)
I meant this:
could be replaced by:
And the other by math.min.
Code: Select all
p.p.y = p.p.y - p.spd*dt
if p.p.y < balls[1].p.y then
p.p.y = balls[1].p.y
end
Code: Select all
p.p.y = math.max(p.p.y-p.spd*dt, balls[1].p.y)
- Felipe Budinich
- Citizen
- Posts: 67
- Joined: Thu Jul 29, 2010 1:36 pm
Re: Rebound (another pong)
Yes, it does work :-)
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Rebound (another pong)
Wow. I forgot how awesome this is. And still working without change, even though the last version is from seven months ago.
Also, I had the whole split-balls thing, and they were sorta stuck: they bounced against each other, went to the other side, bounced again, etc. At a certain moment, a third ball appeared.
Also, it appears to lack a license. This makes böb sad:
Also, I had the whole split-balls thing, and they were sorta stuck: they bounced against each other, went to the other side, bounced again, etc. At a certain moment, a third ball appeared.
Also, it appears to lack a license. This makes böb sad:
Help us help you: attach a .love.
Re: Rebound (another pong)
don't go making characters upRobin wrote:This makes böb sad:
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Rebound (another pong)
Böb's quite old, actually. One of the suggested names of LovelyBigPlanet's protagonist, IIRC. We ended up with Neo. We ended up in permanent hibernation, of course.thelinx wrote:don't go making characters up
Help us help you: attach a .love.
Who is online
Users browsing this forum: No registered users and 0 guests