Hello,
I just recently bought BlitzMax, and after playing around quite a bit, I've decided to make a side-scrolling shooter. I'm trying to animate my character to look like he's walking upon KeyDown(KEY_RIGHT), and this is what I got.
Type THero
Field X:Int
Field Y:Int
Field Speed:Int=3
Field Frame:Int
Field Image:TImage
Function Create:THero(File:String,xstart:Int,ystart:Int)
Local WalkImage:THero=New THero
WalkImage.X=xstart
WalkImage.Y=ystart
WalkImage.Frame=animframe
WalkImage.image=LoadAnimImage(LoadBank(File),64,64,0,2)
If WalkImage.image=Null
Print "Image file not found. Quitting..."
End
End If
Return WalkImage
End Function
Method DrawSelf()
DrawImage Image,X,Y,Frame
End Method
Method UpdateState()
If KeyDown(KEY_LEFT)
X:- Speed
EndIf
If KeyDown(KEY_RIGHT)
X:+ Speed
If Frame<1 Then
Frame :+ 1
EndIf
If Frame>0 Then
Frame :- 1
EndIf
EndIf
When I run my app and DrawSelf() and UpdateState(), I get the following error:
Unhandled Exception:Attempt to index array element beyond array length
Any suggestions?
I just recently bought BlitzMax, and after playing around quite a bit, I've decided to make a side-scrolling shooter. I'm trying to animate my character to look like he's walking upon KeyDown(KEY_RIGHT), and this is what I got.
Type THero
Field X:Int
Field Y:Int
Field Speed:Int=3
Field Frame:Int
Field Image:TImage
Function Create:THero(File:String,xstart:Int,ystart:Int)
Local WalkImage:THero=New THero
WalkImage.X=xstart
WalkImage.Y=ystart
WalkImage.Frame=animframe
WalkImage.image=LoadAnimImage(LoadBank(File),64,64,0,2)
If WalkImage.image=Null
Print "Image file not found. Quitting..."
End
End If
Return WalkImage
End Function
Method DrawSelf()
DrawImage Image,X,Y,Frame
End Method
Method UpdateState()
If KeyDown(KEY_LEFT)
X:- Speed
EndIf
If KeyDown(KEY_RIGHT)
X:+ Speed
If Frame<1 Then
Frame :+ 1
EndIf
If Frame>0 Then
Frame :- 1
EndIf
EndIf
When I run my app and DrawSelf() and UpdateState(), I get the following error:
Unhandled Exception:Attempt to index array element beyond array length
Any suggestions?