Rebound (another pong)

Show off your games, demos and other (playable) creations.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: Rebound (another pong)

Post by TechnoCat »

reuploaded again. sigh :death:
User avatar
Felipe Budinich
Citizen
Posts: 67
Joined: Thu Jul 29, 2010 1:36 pm

Re: Rebound (another pong)

Post by Felipe Budinich »

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:

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
and it "should" be

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
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 :death: but the thing is, that it works better.
Last edited by Felipe Budinich on Sat Aug 14, 2010 4:38 pm, edited 3 times in total.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Rebound (another pong)

Post by bartbes »

You could of course use math.min there.
User avatar
Chief
Party member
Posts: 101
Joined: Fri Mar 12, 2010 7:57 am
Location: Norway, 67° north

Re: Rebound (another pong)

Post by Chief »

Entertaining game! Power ups are awesome! Would like to see this on an IPhone or something :P

Pure prettyness!

12 on a role-play die! :awesome:
User avatar
Felipe Budinich
Citizen
Posts: 67
Joined: Thu Jul 29, 2010 1:36 pm

Re: Rebound (another pong)

Post by Felipe Budinich »

bartbes wrote:You could of course use math.min there.
I'm trying to understand hmmm....

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.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Rebound (another pong)

Post by bartbes »

I meant this:

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
could be replaced by:

Code: Select all

p.p.y = math.max(p.p.y-p.spd*dt, balls[1].p.y)
And the other by math.min.
User avatar
Felipe Budinich
Citizen
Posts: 67
Joined: Thu Jul 29, 2010 1:36 pm

Re: Rebound (another pong)

Post by Felipe Budinich »

Yes, it does work :-)
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Rebound (another pong)

Post by Robin »

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. :crazy:

Also, it appears to lack a license. This makes böb sad: :cry:
Help us help you: attach a .love.
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Rebound (another pong)

Post by thelinx »

Robin wrote:This makes böb sad: :cry:
don't go making characters up
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Rebound (another pong)

Post by Robin »

thelinx wrote:don't go making characters up
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.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests