Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help with slowmotion in pong
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
sylvester-27




PostPosted: 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
code:
if SlowMotion then
            ball.x += ball.xspeed div 2
            ball.y += ball.yspeed div 2
        else
            ball.x += ball.xspeed
            ball.y += ball.yspeed
        end if

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?
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Fri Jan 13, 2006 1:53 pm   Post subject: (No subject)

To bounce the ball off a horizontal or vertical wall, multiply the x or y component of the velocity by -1.
sylvester-27




PostPosted: Mon Jan 16, 2006 11:26 am   Post subject: (No 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.
code:
var SlowMotion : boolean := false
ball.xspeed := SPEED
ball.yspeed := SPEED
   if SlowMotion then
            ball.x += ball.xspeed div 2
            ball.y += ball.yspeed div 2
        else
            ball.x += ball.xspeed
            ball.y += ball.yspeed
        end if
if keys_pressed ('x') or keys_pressed ('m') then
            SlowMotion := true
        elsif not keys_pressed ('x') or keys_pressed ('m') then
            SlowMotion := false
        end if

This is basically (i think) all the code that involves the slow motion
MysticVegeta




PostPosted: Mon Jan 16, 2006 11:52 am   Post subject: (No subject)

sylvester-27 wrote:

code:

ball.xspeed := SPEED
ball.yspeed := SPEED




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?
sylvester-27




PostPosted: Mon Jan 16, 2006 5:42 pm   Post subject: (No 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]
MysticVegeta




PostPosted: Mon Jan 16, 2006 7:19 pm   Post subject: (No 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
Clayton




PostPosted: Tue Jan 17, 2006 10:59 pm   Post subject: (No subject)

MysticVegeta wrote:
sylvester-27 wrote:

code:

ball.xspeed := SPEED
ball.yspeed := SPEED




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
sylvester-27




PostPosted: Sun Jan 22, 2006 3:03 pm   Post subject: (No subject)

nvm i figured it out. I was accidentaly resetting the speed to -1 when the ball came back in.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: