OK, its time to give a larger description of whats going on
I have 4 functions aimed at managing animations, for this particular animation I am testing with I have to use individual image variables for each frame, there is no getting around that
The details of an animation are stored in 2 arrays, A$(25,1) for 2 strings allowing me to identify the animation and AN(25, 2) in which the second dimension is set out as follows:
0: Millisecs between frame updates
1: Millisecs() on last update
2: Current frame number
To add an animation to the arrays I call this finction:
Function SetAnim(on, what, speed)
A$(ANum, 0) = on
A$(ANum, 1) = what
AN(ANum, 0) = speed
AN(ANum, 1) = MilliSecs
ANum = 0
While Not A$(ANum, 0) = ""
ANum = ANum + 1
Wend
End Function
The test animation is a simple 4 frame walking animation for when the player is walking south, when this happens the above function is called with:
SetAnim("Char1", "S", 2000)
the last number is large for testing purposes, but how big or small it is doesnt seem to make a difference
Another function checks which animations are stored in the array, updates them if neccessary, and draws them to the screen, the function is called at the end of a loop that runs constantly and is present for the express purpose of running check functions, other routines in the loop all work as they should, currently only the walking animation is present in the function
Function PlayAnims()
For CNum = 0 To 25
If Not A$(CNum,0) = ""
If MilliSecs() > AN(CNum,0) + AN(CNum,1) Then
AN(CNum,2) = AN(CNum,2) + 1
AN(CNum,1) = MilliSecs()
EndIf
If A$(CNum,0) = "Char1" Then
If A$(CNum,1) = "S" Then
DrawRoom
If AN(CNum, 2) = 0 Then DrawImage Orient40, 32*LOCX+129, 32*LOCY+65
If AN(CNum, 2) = 1 Then DrawImage Orient4, 32*LOCX+129, 32*LOCY+73
If AN(CNum, 2) = 2 Then DrawImage Orient41, 32*LOCX+129, 32*LOCY+81
If AN(CNum, 2) = 3 Then DeleteAnim(CNum)
EndIf
EndIf
EndIf
Next
End Function
The other functions called here are:
Drawroom:- Draws the current background to the screen and the players sprite if he is stationary
DeleteAnim:- Removes an animation from the arrays
Function DeleteAnim(Num)
For I = 0 To 1
A$(Num,I) = ""
Next
For I = 0 To 2
AN(Num,I) = 0
Next
End Function
In order to be useful the stationary sprites are not drawn if a "Char1" animation is present in the array, this is done with SearchAnim, thanks greyalien for the smaller code
Function SearchAnims(on$)
For TNum = 0 To 25
If A$(TNum, 0) = on$ Then Return 1
Next
Return 0
End Function
In Drawroom, SearchAnims is called like this:
K = SearchAnims("Char1")
If K = 0
Select Orientation
Case 1
DrawImage Orient1, X, Y
Case 4
DrawImage Orient4, X, Y
Case 2
DrawImage Orient2, X, Y
Case 3
DrawImage Orient3, X, Y
End Select
Else
Stop
EndIf
And here lies the problem, SearchAnim NEVER returns a 1, if it did the Else statement would be called and the program would stop, the strange thing is that even with it returning 0s the stationary image Orient4 is not drawn
Assuming that SearchAnims works, it would mean that the animation was removed from the arrays before being searched for, but I dont see how thats possible
Any help at all would be immensely apreciated
I have 4 functions aimed at managing animations, for this particular animation I am testing with I have to use individual image variables for each frame, there is no getting around that
The details of an animation are stored in 2 arrays, A$(25,1) for 2 strings allowing me to identify the animation and AN(25, 2) in which the second dimension is set out as follows:
0: Millisecs between frame updates
1: Millisecs() on last update
2: Current frame number
To add an animation to the arrays I call this finction:
Function SetAnim(on, what, speed)
A$(ANum, 0) = on
A$(ANum, 1) = what
AN(ANum, 0) = speed
AN(ANum, 1) = MilliSecs
ANum = 0
While Not A$(ANum, 0) = ""
ANum = ANum + 1
Wend
End Function
The test animation is a simple 4 frame walking animation for when the player is walking south, when this happens the above function is called with:
SetAnim("Char1", "S", 2000)
the last number is large for testing purposes, but how big or small it is doesnt seem to make a difference
Another function checks which animations are stored in the array, updates them if neccessary, and draws them to the screen, the function is called at the end of a loop that runs constantly and is present for the express purpose of running check functions, other routines in the loop all work as they should, currently only the walking animation is present in the function
Function PlayAnims()
For CNum = 0 To 25
If Not A$(CNum,0) = ""
If MilliSecs() > AN(CNum,0) + AN(CNum,1) Then
AN(CNum,2) = AN(CNum,2) + 1
AN(CNum,1) = MilliSecs()
EndIf
If A$(CNum,0) = "Char1" Then
If A$(CNum,1) = "S" Then
DrawRoom
If AN(CNum, 2) = 0 Then DrawImage Orient40, 32*LOCX+129, 32*LOCY+65
If AN(CNum, 2) = 1 Then DrawImage Orient4, 32*LOCX+129, 32*LOCY+73
If AN(CNum, 2) = 2 Then DrawImage Orient41, 32*LOCX+129, 32*LOCY+81
If AN(CNum, 2) = 3 Then DeleteAnim(CNum)
EndIf
EndIf
EndIf
Next
End Function
The other functions called here are:
Drawroom:- Draws the current background to the screen and the players sprite if he is stationary
DeleteAnim:- Removes an animation from the arrays
Function DeleteAnim(Num)
For I = 0 To 1
A$(Num,I) = ""
Next
For I = 0 To 2
AN(Num,I) = 0
Next
End Function
In order to be useful the stationary sprites are not drawn if a "Char1" animation is present in the array, this is done with SearchAnim, thanks greyalien for the smaller code
Function SearchAnims(on$)
For TNum = 0 To 25
If A$(TNum, 0) = on$ Then Return 1
Next
Return 0
End Function
In Drawroom, SearchAnims is called like this:
K = SearchAnims("Char1")
If K = 0
Select Orientation
Case 1
DrawImage Orient1, X, Y
Case 4
DrawImage Orient4, X, Y
Case 2
DrawImage Orient2, X, Y
Case 3
DrawImage Orient3, X, Y
End Select
Else
Stop
EndIf
And here lies the problem, SearchAnim NEVER returns a 1, if it did the Else statement would be called and the program would stop, the strange thing is that even with it returning 0s the stationary image Orient4 is not drawn
Assuming that SearchAnims works, it would mean that the animation was removed from the arrays before being searched for, but I dont see how thats possible
Any help at all would be immensely apreciated