Breakout: Accurately reproduce paddle physics?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
CoffeeCoder
Prole
Posts: 19
Joined: Sun Aug 23, 2015 4:10 am

Breakout: Accurately reproduce paddle physics?

Post by CoffeeCoder »

Alright, so for my first official LOVE game, I want to make a version of Breakout that also integrates Pong in some manner.

I have done some Googling on the theory of the paddle physics (angle in = angle out), but I can't seem to find a solid formula for accurately affecting the behavior of the ball when it bounces off of the paddle. Bricks, yes, that much I can do, but for accurately recreating the effect of the paddle in the original Breakout, I am having little luck.

Could someone, who is wiser than myself, possibly help me with the formula? I'm not asking for code just the general idea behind the formula. Please and many thank yous to follow and maybe a few rounds on me!
- CoffeeCoder
Visit my site to learn more about me! :megagrin:
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Breakout: Accurately reproduce paddle physics?

Post by Jasoco »

Most Breakout clones take the position of the ball where it hits the paddle and use that to affect the angle. If it hits the left then it goes left, and vice versa. But only the outer edges might actually change the angle or force. The middle of the paddle would only mirror the Y speed.

Some will take into account the speed the paddle and ball are moving as well.

And some, the badly coded ones, will always use 45º angles.

Also some will put checks in to detect if the ball has not hit the paddle in a certain amount of time and assumes it's stuck in a loop between the walls and some unbreakable blocks and will change its angle very slightly to help it get back into the game.

You could do some research on YouTube with playthroughs of some Breakout clones. My favorite is Thunder and Lightning. I believe this one only changes the angle from 45º to 30º if you are moving when you hit the ball. Really it's all up to the developer to use your own method.
User avatar
kbmonkey
Party member
Posts: 139
Joined: Tue Sep 01, 2015 12:19 pm
Location: Sydney
Contact:

Re: Breakout: Accurately reproduce paddle physics?

Post by kbmonkey »

I am not clear when you say "recreating the effect of the paddle". Off the top of my head I imagine these behaviours:

1. The angle of the ball is the determined by the angle of incidence. The angle in == inverse angle out.
2. The angle of the ball is affected by the position of where it hits the paddle. The paddle edges deflect at a lower angle than the centre of the paddle.
3. The angle of the ball is affected by the motion of the paddle. A paddle moving opposite the ball direction provide resistance, a paddle moving with the ball provide acceleration.

So I watched a couple of breakout gameplay videos - with so many versions which one do we consider "original"?

Atari 2600 Breakout gameplay
Atari 8-bit - Super Breakout [Atari] 1979

Watching those, to me at least, it seems that behaviour #2 is most prevalent. So I suggest moving the ball with trigonometry (angle + speed). Work out how far from the centre of the paddle the ball hits, and adjust the ball angle accordingly. A centre hit will only reverse the angle, but a hit on the edge nearest to the ball should adjust the angle enough that the ball flies more upward, or even bounce back the direction it came from (if that is what you want).

Just my suggestion :)
User avatar
CoffeeCoder
Prole
Posts: 19
Joined: Sun Aug 23, 2015 4:10 am

Re: Breakout: Accurately reproduce paddle physics?

Post by CoffeeCoder »

Sorry, wrote this post while I was half asleep last night so didn't explain very well what I mean!

By "effect of the paddle", I mean to say how it actually deflects the ball back towards the brick. How it hits the paddle determines how it's reflected back towards the bricks.

I did a bit more Googling and I think I finally found somewhere that explains the theory a little bit better than everywhere else. The problem, though, is that it uses vectors to determine angles. Does LOVE have a vector module/library somewhere, or will I have to code my own? No big deal if I have to, I just want to know if one exists before I go ahead and just do it. :P

Thanks guys! :)
- CoffeeCoder
Visit my site to learn more about me! :megagrin:
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Breakout: Accurately reproduce paddle physics?

Post by Nixola »

There are lots of vector implementations already coded by people (amongst them, one crappy one made by me which attempts to be lighter using tables, which behaves weirdly (if a,b,c are three vectors: a = b + c will actually edit vector B instead of creating a new one, and A will reference the exact same vector)), but coding one isn't so hard
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 5 guests