Sprites: How do I move across screen
BlitzMax Forums/BlitzMax Beginners Area/Sprites: How do I move across screen
| ||
| Hi, I have a nice sprite that goes through it's animation sequence at the location where I specify.I'm a beginner and am wondering what is the next step in moving this sprite across the screen so that it actually moves as opposed to staying in the one location ? Looking for a point in the right direction please. THanks ! Graphics 800,600 'set gfx mode Global FrameTimer = MilliSecs() Global frame:Int = 0 SetMaskColor 0,160,0 Global myimage:TImage = LoadAnimImage("Ko2_style5a_2x.png",32,32,69,72) SetClsColor 0,160,0 Repeat Cls If MilliSecs() > FrameTimer + 100 FrameTimer = MilliSecs() frame:+1 EndIf If frame > 3 Then frame = 0 Flip FlushMem Until KeyHit(KEY_ESCAPE) |
| ||
Something like this:Graphics 800,600 'set gfx mode
Global FrameTimer = MilliSecs()
Global frame:Int = 0
SetMaskColor 0,160,0
Global myimage:TImage = LoadAnimImage("Ko2_style5a_2x.png",32,32,69,72)
SetClsColor 0,160,0
x = 400
y = 300
Repeat
Cls
If MilliSecs() > FrameTimer + 100
FrameTimer = MilliSecs()
frame:+1
EndIf
If frame > 3 Then frame = 0
DrawImage myimage,x,y,frame
y :+ 1
Flip
FlushMem
Until KeyHit(KEY_ESCAPE)
|
| ||
| I believe you left out what frame in the draw image command above. change drawimage to: DrawImage myimage,x,y,frame '<< in code above |
| ||
| Fixed. |
| ||
| Wow, thanks beaker. I didn't realise it was that easy. |