Can someone help a newbie with some Breakout-style probs?

Started by
1 comment, last by ServantOfGlaaki 22 years, 3 months ago
Hi there, I''m fairly experienced in Java programming, but have only just started programming games. My first project is a clone of Breakout (like Pong). My question is: How can I implement realistic physics. By this, I mean what do I have to do to get the ball to rebound off the bat at the correct angle? I understand what Maths must be done to work it out, but don''t know how to actually do it. Any help greatly appreciated. It''''s over for now... until yesterday begins again... tomorrow... tomorrow... tomorrow... [Powerman 5000 - Watch the Sky for Me]
And a woman needs a man... like a fish needs a bicycle...[U2 - Tryin' to throw your arms around the world]
Advertisement
If you know the math, there is no issue with figuring out how it works.

if(Ball.x > MAX_X || Ball.x < MIN_X)    Ball.x =- Ball.x;if (Ball.y < MIN_Y)    Ball. =- Ball.y;//check ball->block collisions blah......// check ball -> bottom edge collisionif (Ball.y > MAX_Y)    if (Ball.x < Paddle.x + PADDLE_WIDTH && Ball.x > Paddle.x)        //reflect ball off paddle        ...    else        //ball is off the bottom of the screen        //restart or whatever        ... 


I don't know if that's what you want, but that's as good as I can do from what you asked.

Later,
ZE.

EDITED for formatting and code issues.

Edited by - ZealousElixir on December 18, 2001 5:39:08 PM

[twitter]warrenm[/twitter]

Hey, ServantOfGlaaki, welcome to Gamedev!

I just wanted to say that if you are programming your game in Java, you might do well to post your question in the Java Development forum. That''s where I generally post my Java programming questions, and everyone has been very helpful. The Beginner forum is a great place to start. But keep in mind that while not everyone who visits this forum is familiar with Java, you''re bound to find many people in the Java Development forum who have cut their teeth on projects like that which you are currently working on.


Jonathon
quote:"Mathematics are one of the fundamentaries of educationalizing our youths." -George W. Bush

"When a nation is filled with strife, then do patriots flourish." - Lao Tzu

Jonathon[quote]"Mathematics are one of the fundamentaries of educationalizing our youths." -George W. Bush"When a nation is filled with strife, then do patriots flourish." - Lao Tzu America: Love it or leave it ... in the mess it's in. [/quote]

This topic is closed to new replies.

Advertisement