What's the best way to obtain a zero value on PLAYER_CMOVESPEED#
It starts doing this 1.-e1234 things after a while.
Should floats just be avoided?
It starts doing this 1.-e1234 things after a while.
Should floats just be avoided?
;My Code Graphics3D 640, 480, 0, 2 CAM = CreateCamera() MoveEntity CAM, 0, 80, 0 TurnEntity CAM, 90, 0, 0 Global PLAYER_MOVESTATE Global PLAYER_MOVESPEED# = .75 Global PLAYER_CMOVESPEED# Global PLAYER_MOVEACC# = .01 Global PLAYER_MOVEDIRECTION Global PLAYER_MESH PLAYER_MESH = CreateCube() EntityFX PLAYER_MESH, 1 Create_Grid(32) Repeat Move_Player() DebugLog PLAYER_CMOVESPEED# RenderWorld() Text 0, 0, "Speed: " + PLAYER_CMOVESPEED# Text 0, 20, "Move State: " + PLAYER_MOVESTATE Flip Until KeyHit(1) End Function Move_Player() If KeyDown(17) Then move = 1 PLAYER_MOVEDIRECTION = 1 EndIf If KeyDown(31) Then move = 1 PLAYER_MOVEDIRECTION = -1 EndIf If KeyDown(30) Then turn = 1 EndIf If KeyDown(32) Then turn = -1 EndIf If move = 1 Then If PLAYER_MOVEDIRECTION = 1 Then PLAYER_CMOVESPEED# = PLAYER_CMOVESPEED# + PLAYER_MOVEACC# If PLAYER_CMOVESPEED# > PLAYER_MOVESPEED# Then PLAYER_CMOVESPEED# = PLAYER_MOVESPEED# Elseif PLAYER_MOVEDIRECTION = -1 PLAYER_CMOVESPEED# = PLAYER_CMOVESPEED# - PLAYER_MOVEACC# If PLAYER_CMOVESPEED# < -PLAYER_MOVESPEED# Then PLAYER_CMOVESPEED# = -PLAYER_MOVESPEED# EndIf Else If PLAYER_CMOVESPEED < 0 Then PLAYER_CMOVESPEED# = PLAYER_CMOVESPEED# + PLAYER_MOVEACC# ElseIf PLAYER_CMOVESPEED > 0 PLAYER_CMOVESPEED# = PLAYER_CMOVESPEED# - PLAYER_MOVEACC# EndIf EndIf If PLAYER_CMOVESPEED# <> 0 Then MoveEntity PLAYER_MESH, 0, 0, PLAYER_CMOVESPEED# EndIf TurnEntity PLAYER_MESH, 0, turn, 0 End Function Function Create_Grid(scale=1, size=256) GRIDTex = CreateTexture(size, size,1+2+8) SetBuffer TextureBuffer(GRIDTex) Color 0, 255, 0 Rect 0, 0, size, size, 0 Color 50, 50, 50 Rect 1, 1, size-2, size-2, 1 SetBuffer BackBuffer() ScaleTexture GRIDTex, scale, scale GRID = CreatePlane() EntityTexture GRID, GRIDTex EntityAlpha GRID, .75 Color 255, 255, 255 End Function