Sign in to follow this  
Wizecoder

Paddle ball breakout

Recommended Posts

I was thinking that after i finish the cpp module 2 at gameinstitute.com i might try to make a game that uses the brick breaking of breakout with instead of just a ball bouncing back and forth using some sort of elastic band effect between the ball and paddle. Any suggestions on how i might do this? By the way it will be done with gdi and programmer art.

Share this post


Link to post
Share on other sites
Sure, just model the elastic band as a spring obeying Hooke's Law. Ignore forces produced by the band being below its rest length.

Or, in other words:


rest_length = xxx
stiffness = yyy

each frame:
spring_displacement = ball_position - paddle_position
spring_length = length(spring_displacement)
if spring_length > rest_length:
ball_acceleration = normalize(spring_displacement) * (rest_length - spring_length) * stiffness
ball_velocity += ball_acceleration * dT
ball_position += ball_velocity * DT


Also, moved to For Beginners.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this