Page 3 of 5

Re: Rebound (another pong)

Posted: Tue Jun 29, 2010 1:30 am
by TechnoCat
reuploaded again. sigh :death:

Re: Rebound (another pong)

Posted: Sat Aug 14, 2010 2:56 pm
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.

Re: Rebound (another pong)

Posted: Sat Aug 14, 2010 3:04 pm
by bartbes
You could of course use math.min there.

Re: Rebound (another pong)

Posted: Sun Aug 15, 2010 11:55 am
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:

Re: Rebound (another pong)

Posted: Sun Aug 15, 2010 6:50 pm
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)

Re: Rebound (another pong)

Posted: Sun Aug 15, 2010 7:02 pm
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.

Re: Rebound (another pong)

Posted: Sun Aug 15, 2010 7:12 pm
by Felipe Budinich
Yes, it does work :-)

Re: Rebound (another pong)

Posted: Tue Jan 18, 2011 8:22 pm
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:

Re: Rebound (another pong)

Posted: Tue Jan 18, 2011 8:25 pm
by thelinx
Robin wrote:This makes böb sad: :cry:
don't go making characters up

Re: Rebound (another pong)

Posted: Tue Jan 18, 2011 9:34 pm
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.