Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Bouncing Balls problem  RSS feed

 
Sam Hackett
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to figure out how to have multiple balls bouncing in a frame simultaneously. I know how to have one ball bouncing but I can't figure out the logic to having more than one ball. I know my code is kind of mess. I appreciate any help. Thanks



 
Fred Kleinschmidt
Bartender
Posts: 554
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to add methods in Ball to alter the Ball's x and y.
Also, your moveBall() method doesn't do anything - it calculates new values for x and y, then discards the result.
 
Campbell Ritchie
Sheriff
Posts: 55284
156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use java.util.Timer; use a javax.swing.Timer.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!