Code: Select all
@VERSION 10,0
@DISPLAY{WIDTH = 800, HEIGHT = 600, MODE = "WINDOWED", TITLE = "Grid Movement", COLOR = #BLACK}
CreateBrush(1, 16, 16, #GREEN)
ply_X = 384 ;Set initial X-position
ply_Y = 288 ; Set initial Y-position
Function p_UpdateScreen()
Local leap = 16
If IsKeyDown("LEFT") = True Then ply_X = ply_X - leap
If IsKeyDown("RIGHT") = True Then ply_X = ply_X + leap
If IsKeyDown("UP") = True Then ply_Y = ply_Y - leap
If IsKeyDown("DOWN") = True Then ply_Y = ply_Y + leap
DisplayBrush(1, ply_X, ply_Y)
Wait (7)
EndFunction
Function p_DrawGrid()
For Local x = 0 to 799 step 16
Line(x, 0, x, 600, #MAROON)
Next
For Local y = 0 to 599 step 16
Line(0, y, 800, y, #MAROON)
Next
EndFunction
BeginDoubleBuffer()
EscapeQuit(True)
Repeat
Cls(#BLACK)
p_DrawGrid()
p_UpdateScreen()
Flip()
Forever
EndDoubleBuffer()