i have a cube i want to spin 90 degrees at a time with key presses.
here is the code i have:
what am i doing wrong here? the cube isnt seating into its correct position after 90 degrees
here is the code i have:
Global gameFPS = 50 Global turning=False,spin,rt#,yw#,direction Graphics3D 800,600 cam = CreateCamera () PositionEntity cam,10,10,10 CameraViewport cam, 0, 0, GraphicsWidth (), GraphicsHeight () light=CreateLight() PositionEntity light,10,10,10 Global mainbox=CreateCube() PointEntity cam,mainbox framePeriod = 1000 / gameFPS frameTime = MilliSecs () - framePeriod Repeat Repeat frameElapsed = MilliSecs () - frameTime Until frameElapsed frameTicks = frameElapsed / framePeriod frameTween# = Float (frameElapsed Mod framePeriod) / Float (framePeriod) For frameLimit = 1 To frameTicks If frameLimit = frameTicks Then CaptureWorld frameTime = frameTime + framePeriod UpdateGame () UpdateWorld Next RenderWorld frameTween Text 0,0,rt#+" "+spin+" "+turning Flip Until KeyHit (1) End Function UpdateGame () keypress() rotatemain() End Function Function keypress() If Not turning If KeyHit(203) turning=True spin=0 direction=1 ElseIf KeyHit(205) turning=True spin=0 direction=2 ElseIf KeyHit(200) turning=True spin=0 direction=3 ElseIf KeyHit(208) turning=True spin=0 direction=4 EndIf EndIf End Function Function rotatemain() If turning spin=spin+1 RotateEntity mainbox,rt#,0,yw# If direction =1 Then rt#=rt#-9 If direction =2 Then rt#=rt#+9 If direction =3 Then yw#=yw#+9 If direction =4 Then yw#=yw#-9 If spin = 10 turning=False Return EndIf EndIf End Function
what am i doing wrong here? the cube isnt seating into its correct position after 90 degrees