Archived

This topic is now archived and is closed to further replies.

General Physics Question

This topic is 6108 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

i have several games i''ve never brought through to completion, so just for a bang (and for a new change of pace) i''m writing a silly little breakout style game. i''m used to creating tile games where physics is not an issue, and it has been some time since i was in school taking physics. Question: how can one determine the physics of the ball''s motion? i.e. when it hits a wall, how to reflect it properly. i have some idea of how this might work, but i''m sure there are tested, tried, and true methods out there for this type of thing. Any advice is appreciated. "You call him Dr. Grip, doll!"

Share on other sites

if ball hit from above or under
ball.velocity.y = -ball.velocity.y

if ball hit from left or right
ball.velocity.x = -ball.velocity.x

Share on other sites
That sounds good, but don''t i need to track the ball''s position? Or should i determine that from the velocity (if so, how exactly?)? Thanks!

"You call him Dr. Grip, doll!"

Share on other sites
  int ball_x; // holds ball''s x coordint ball_y; // holds ball''s y coordint ball_velo_x; // velocity incrementer for x coordint ball_velo_y; // same but for yball_x += ball_velo_x; // find new xball_y += ball_velo_y; // find new y

Then set a default value for each velocity, then all you do is reverse it''s property (I dunno a word for this) from negative to positive.

Check my site, I got a clone of breakout that you can download and play with. I can send you the semi messy source so you can learn from it.

------------------------------
"I''m a decorated astronaut, I don''t make those kind of mistakes."
"Oh now wait a minute. Look I''ll show ya. I''ll enter the same calculations using what we like to call ''The Right Way''."

-Rem
Zirem Software