I have created 3 cubes that bounce up and down using an if statement that reverses the direction of the cube once it has moved a number of units. I am attempting to speedup or slowdown the speed the cubes bounce by pressing one of 3 keys. When I press one of the keys the speed of the cube changes but does not reverse direction essentially the cube "runs away". Can someone point out what I am doing wrong?
Graphics3D 640, 480, 0, 2 cam = CreateCamera () TurnEntity cam,15,0,0 PositionEntity cam,0,25,-20 lite = CreateLight() cube1=CreateCube() PositionEntity cube1,-10,0,20 cube2=CreateCube() PositionEntity cube2,0,0,20 cube3=CreateCube() PositionEntity cube3,10,0,20 Global zz = .51 Global xx = .51 Repeat bounce = bounce + zz If Abs(bounce) => 5 zz = -zz MoveEntity cube1,0,bounce,0 MoveEntity cube2,0,bounce,0 MoveEntity cube3,0,bounce,0 ;---these keys are meant to speed up the bouncing motion-------- ; the "q" key If KeyDown( 16 )=True Then zz = .55 ; the "w" key If KeyDown( 17 )=True Then zz = .60 ; the "e" key If KeyDown( 18 )=True Then zz = .65 UpdateWorld RenderWorld Text 20, 20, bounce Flip Until KeyHit (1) End