Jump to content
  • Advertisement


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.

If you intended to correct an error in the post then please contact us.

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 this post

Link to post
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 collision
if (Ball.y > MAX_Y)
if (Ball.x < Paddle.x + PADDLE_WIDTH && Ball.x > Paddle.x)
//reflect ball off paddle
//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.


EDITED for formatting and code issues.

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

Share this post

Link to post
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.

"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

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!