• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Wall ball bounce

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Source:
http://fileho.com/download/120846695042/bounce2.zip.html

How would I go about making a wall for my bouncing ball?
For example if the ball hit the center box it would bounce.


========
Well, basically I have two boxes:





One box inside the other, right now the ball will bounce inside the first box, but the part I am having trouble with is making the inside box also make the ball bounce when hit.

For the first box I just took the x or y and then changed direction example:





But, because the other box is on the inside it will not work. I need to find out how to add walls that the ball will bounce off of. Preferably something that will not require at lot of check for the ball going into a certain point. But, anything that works would be great.
[ June 01, 2007: Message edited by: Emmanuel Xoc ]
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We had an assignment similar to this in my Intro CompSci course. We were using the acm.graphics package, but what we ended up doing was calling the getElementAt(int index) to know specificially which element we were at, so that if we hit an element at one index the ball would not move through it, but the ball would only move as long as it was atop an element at another index.

Maybe you already tried this, but it worked for us.

Good luck!
reply
    Bookmark Topic Watch Topic
  • New Topic