Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object-oriented balls moving around a box?

Status
Not open for further replies.

may1hem

Programmer
Jul 28, 2002
262
GB
I am totally new to Java and object-oriented design.

I am trying to write a program which will draw 2 balls moving iside a box and a text string appearing on the screen when they collide.

Of course, they should bounce back off the walls and it should be as simple as possible. I just need to see how object oriented programming works.

Any ideas on where to start?

Thanks,

May
 
Can anyone help with this?

I guess if no-one can be bothered to help I will take the slow boat...

May
 
You've already described the objects that are needed for the program. There should be a Ball object and a Box object. The Ball object should hold all data that pertains to it, location, speed, direction, etc. The Box object will probably contain bounds info and hold a series of Ball objects and will deal with collisions as well. There will probably be some other class that will run the show, that will draw the objects based on there info and advance some animation loop. I'm intentionally being vague so that you will have to learn how to do this on your own, since you'll learn more this way, but hopefully this will give you someplace to start.
If you need anymore info, let us know.

Hope this helps,
MarsChelios
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top