Don't mind the fact that it looks ugly :) it's well beyond bedtime already.. *yawn* .. but this should be all the info you need:
use 4 vars:
playerX# playerY# playerSpeed# playerAngle
the rest is obvious..
~enjoy~
app=CreateWindow("",8,8,640,480,0,0)
canvas=CreateCanvas(0,0,640,480,app)
Global arrow=CreateImage(32,32),arrowtemp=CreateImage(32,32)
MidHandle arrow
SetBuffer ImageBuffer(arrow)
Line 0,31,16,0
Line 17,0,31,31
Line 0,31,31,31
Line 2,27,29,27
SetBuffer CanvasBuffer(canvas)
timer=CreateTimer(40)
Global playerX#=320,playerY#=240
Global playerSpeed#=1,playerAngle=0
Repeat
WaitEvent()
If EventID()=$803 quit=True
If EventID()=$4001
Controls()
EndIf
Text 0,0,"alt F4 = quit"
FlipCanvas canvas:Cls
Until quit
End
Function Controls()
If KeyDown(200) ; up
playerSpeed#=playerSpeed#+.1
If playerSpeed#>4 playerSpeed#=4
EndIf
If KeyDown(208) ; down
playerSpeed#=playerSpeed#-.1
If playerSpeed#<0 playerSpeed#=0
EndIf
If KeyDown(203) ; L
PlayerAngle=(PlayerAngle+350) Mod 360
EndIf
If KeyDown(205) ; R
PlayerAngle=(PlayerAngle+10) Mod 360
EndIf
UpdatePlayer()
DrawPlayer()
End Function
Function DrawPlayer()
Plot playerX#,playerY#
arrowtemp=CopyImage(arrow)
RotateImage arrowtemp,playerAngle
DrawImage arrowtemp,playerX#,playerY#
End Function
Function UpdatePlayer()
playerX#=playerX#+Sin(playerAngle)*playerSpeed#
playerY#=playerY#-Cos(playerAngle)*playerSpeed#
End Function
|