I was wondering, is there a command to negate a value,that is to say,I want to start off at a random speed, which i have done, but when it hits the edge of the screen i want it to totally negate its speed, so lets say the speed was a value of 4, I want it to hit the edge of the screen and make it -4, but bare in mind it could be any value,as it is initially given a random speed as I said!
Code: Select all
new_face:
AddElement(face())
face()\xb=Random(640)
face()\yb=Random(480)
face()\xspeed=1
face()\yspeed=Random(3)+1
Return
And this is the movement, but i dont want face()\yspeed=-3 or 3,I want the negative of what it was originally assigned in the new_face routine!
Code: Select all
draw_sprites:
ResetList(face())
While NextElement(face())
DisplaySprite(#fcs,face()\xb,face()\yb)
face()\yb=face()\yb+face()\yspeed
face()\xb=face()\xb+face()\xspeed
If face()\xb>=640-64
face()\xspeed=-1
EndIf
If face()\xb<=0
face()\xspeed=1
EndIf
If face()\yb<=0
face()\yspeed=3
EndIf
If face()\yb>=480-64
face()\yspeed=-3
EndIf
Wend
Return

