Public Group

#### Archived

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

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

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

## Recommended Posts

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]

##### Share on other sites
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

##### Share on other sites
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

1. 1
2. 2
3. 3
4. 4
5. 5
Rutin
11

• 12
• 19
• 10
• 14
• 10
• ### Forum Statistics

• Total Topics
632665
• Total Posts
3007711
• ### Who's Online (See full list)

There are no registered users currently online

×