Computer Science Canada bouncing ball |
Author: | shoobyman [ Thu Dec 15, 2005 9:42 pm ] | ||
Post subject: | bouncing ball | ||
This code is driving me crazy cuz i can only give it the borders on the x axis, not y (even though my program looks like i tried to make a y border). can some1 plz tell me how to change it so the y border will actually work without changing everything? this is the code
Mod edit: Code tags please, no triple posting, and no caps lock. Thanks. |
Author: | Bored [ Thu Dec 15, 2005 9:47 pm ] |
Post subject: | |
The problem with your program is really simple your changeing both the y and x directions when your ball hits the end of the x part of the screen. Try using a single loop and a variable to store xSpeed and ySpeed. When the ball hits its max or minimum x value have the xSpeed become - xSpeed therfore going the other way (bouncing). Do the same for your y |