Computer Science Canada ball bouncing help |
Author: | Stormtrooper [ Tue Apr 15, 2003 12:58 pm ] | ||
Post subject: | ball bouncing help | ||
ok i made this code and i want the balls to bounce when they hit eachother what should i add to the programm and where to put it? also my 2 balls are in each other how do i make them to be by them selves and move into different directions?
|
Author: | Tony [ Tue Apr 15, 2003 1:44 pm ] |
Post subject: | |
well the basic idea is to change the direction of movement after the collision. You should read a tutorial on circular collisions. To realistically bounce balls from each other, read a tutorial on "making a pool game". It describes the physics behind ball colision and gives some code examples of how to code it. You should use it as a guide only though since it was programmed as an animation so it would bug if you just copy/paste it into your program. You can find all the reading material in the "tutorials" section of this site. |
Author: | Homer_simpson [ Fri Apr 25, 2003 10:41 pm ] | ||
Post subject: | |||
i believe this is what you have been trying to make ?...
|
Author: | SilverSprite [ Sat Apr 26, 2003 11:07 am ] |
Post subject: | |
What does this line do? dirx := not dirx |
Author: | Martin [ Sat Apr 26, 2003 11:08 am ] |
Post subject: | |
Toggle's dirX not true = false not false = true therefor, not dirX = true if dirX = false, and vise versa |
Author: | void [ Thu May 01, 2003 5:33 pm ] |
Post subject: | paddle game |
okay....i have this thing for paddle ball game where i tell the porgram that if the lowest point in the ball touches any part of the top of the paddle....then bounce it back....and i have everything perfectly fine.....(i used the same program structure that i saw on here before for the bouncing balls...but i edited it so that if its below 0 on the y-axis...then exit the loop thats drawing the ball....but now im stuck....i need an idea that will allow me to repeat the process for 3 times (the user has three balls to use).....any ideas .....im up for anything |
Author: | Tony [ Thu May 01, 2003 5:51 pm ] |
Post subject: | |
well put that loop inside another loop. Every time you exit your inside loop you add one to used up lifes counter. When the counter reaches 3, that means you used up your 3rd ball and its game over. Otherwise your outside loop returns you to the beginning of your inside loop |
Author: | Homer_simpson [ Thu May 01, 2003 6:27 pm ] |
Post subject: | |
or u can make a variable and everytime ball misses add the value of the variable by 1 and exit loop when variable = 3 |
Author: | Homer_simpson [ Thu May 01, 2003 6:35 pm ] | ||
Post subject: | |||
here's another one that balls change direction when they hit eachother |