Computer Science Canada Help with slowmotion in pong |
Author: | sylvester-27 [ Fri Jan 13, 2006 1:49 pm ] | ||
Post subject: | Help with slowmotion in pong | ||
Im workin on a pong game for my final project and my bullet-time funtion isn't working. well i works part of the time im using this
what happens is that when i press it it works but as soon as the ball goes off the screen the speed changes to -1 and the slow-motion will either stop it or have it flatline across the screen. any suggestions? |
Author: | Cervantes [ Fri Jan 13, 2006 1:53 pm ] |
Post subject: | |
To bounce the ball off a horizontal or vertical wall, multiply the x or y component of the velocity by -1. |
Author: | sylvester-27 [ Mon Jan 16, 2006 11:26 am ] | ||
Post subject: | |||
i do have that already in my code and thats not what i need help with. i need help with making my slowmotion function work. when i press the button 'x' or 'm' the ball is supposed to slow down ball. the speed should stay the same until the ball has bounced 5 times but it increases by one each time. then when the ball goes off the screen the speed goes to -1, which shouldn't happen cause the speed shoudl reset to 3 each time because i told it too and set it as a constant. heres some of the code but it is not in order. some came from different places in the code.
This is basically (i think) all the code that involves the slow motion |
Author: | MysticVegeta [ Mon Jan 16, 2006 11:52 am ] | ||
Post subject: | |||
sylvester-27 wrote:
Is it because of this? I think you are resetting the speed of the ball to SPEED var again which I suppose would be a const/you dont change it. So I think thats why after 1 bounce its resetting to original speed? |
Author: | sylvester-27 [ Mon Jan 16, 2006 5:42 pm ] |
Post subject: | |
no its not that. in my game i told it to output my speed whenever the ball hits something and it should only increase every 5 bounces but it goes 3, -4, 5, -6... and once it goes off the screen a few times it goes to -1 and that is when my slowmotion function starts messing up[/code] |
Author: | MysticVegeta [ Mon Jan 16, 2006 7:19 pm ] |
Post subject: | |
You think you can post the entire code cause its really hard to tell wehre the error is. Remove the code later if you want to |
Author: | Clayton [ Tue Jan 17, 2006 10:59 pm ] | ||
Post subject: | |||
MysticVegeta wrote: sylvester-27 wrote:
Is it because of this? I think you are resetting the speed of the ball to SPEED var again which I suppose would be a const/you dont change it. So I think thats why after 1 bounce its resetting to original speed? im pretty sure hes right because ive had the same problem before so try putting that outside of the function and making it global or importing it or whatever, but yes please post the code to help us figure out wats going on |
Author: | sylvester-27 [ Sun Jan 22, 2006 3:03 pm ] |
Post subject: | |
nvm i figured it out. I was accidentaly resetting the speed to -1 when the ball came back in. |