General Physics Question

Started by
2 comments, last by the_grip 22 years, 10 months ago
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!"
"You call him Dr. Grip, doll!"
Advertisement
how about this?

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

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!"
"You call him Dr. Grip, doll!"
  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
------------------------------"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'."-RemZirem Software

This topic is closed to new replies.

Advertisement