Hello, I have a problem with program speed. When the program is processing a lot of things the game slows down, and when everything settles down it goes fast again.
You can see it in the movement here:
As you can see the character dashes when the animation goes from 9 to 5, and this is probably because of the way i designed my program. You can see the code over here:
-Something to note is, most of the features like jump and duck were before i decided to add animations but i didnt change them. so you can ignore them. i need help in either finding a new method to organize my sprites and to load them when needed, or to fix my problem of maintaining a constant program speed.
.MK Omar Chehab
sub(INIT)
Repeat getKey(15)
sub(MOVEMENT)
sub(ACTION)
sub(RENDER)
End
Lbl MOVEMENT
..If TIRED then RECOVER
{L1+4}++
If {L1+3}>128
{L1+3}++
End
..If no ANIMATION STATE is going on then
If {L1+3}=0
0->{L1+2}
..DUCK
If getKey(1)
..Set ANIMATION to DUCK
3->{L1+2}
End
..LEFT
If getKey(2) and ({L1+2}=0)
..Decrement X POSITION
{L1+0}--
sub(aWALK)
End
..RIGHT
If getKey(3) and ({L1+2}=0)
..Increment X POSITION
{L1+0}++
sub(aWALK)
End
..JUMP
If getKey(4) and ({L1+1}=56)
..Set ANIMATION to JUMP
4->{L1+2}
..Set ANIMATION STATE to UPWARDS
1->{L1+3}
End
..IDLE
If {L1+2}>=0 and ({L1+2}<=4)
sub(aIDLE)
End
End
..GRAVITY
If {L1+2}=4 or ({L1+2}=5)
..LEFT
If getKey(2)
{L1}--
End
..RIGHT
If getKey(3)
{L1}++
End
If {L1+1}=56 and ({L1+3}=2)
..Set ANIMATION to RECOVER
11->{L1+2}
..Set ANIMATION STATE to RECOVER for 15 ticks
~15->{L1+3}
End
..Peak
If {L1+1}=34
..Set ANIMATION to FALLING
5->{L1+2}
..Set ANIMATION STATE to DOWNWARDS
2->{L1+3}
End
..If ANIMATION STATE is UPWARDS
If {L1+3}=1
..Increment height
{L1+1}--
End
If {L1+3}=2
..Decrement height
{L1+1}++
End
End
Return
Lbl ACTION
Return
Lbl RENDER
Text(0,0,{L1+2}>Dec
..Sum all sprite sizes up till the selected sprite
0->D
For(C,0,{L1+2})
(({GDB1+(C-1*2))*({GDB1+(C-1*2+1)))+D->D
End
..Loop for height of sprite
0->C
({GDB1+({L1+2}*2+1)})->B
While B>0
B--
..Loop for width of sprite
For(A,0,({GDB1+({L1+2}*2)})-1)
Pt-On(A*8+{L1},~B*8+{L1+1},C*16+Pic0+(D*16))
Pt-On(A*8+{L1},~B*8+{L1+1},C*16+Pic0+8+(D*16))^^r
C++
End
End
DispGraphClrDraw^^r^^r
Return
Lbl aIDLE
If {L1+4}=128
0->{L1+4}
End
If {L1+4}<16
0->{L1+2}
ElseIf {L1+4}<32
1->{L1+2}
ElseIf {L1+4}<64
2->{L1+2}
ElseIf {L1+4}<96
3->{L1+2}
ElseIf {L1+4}<128
4->{L1+2}
End
Return
Lbl aWALK
If {L1+4}=128
0->{L1+4}
End
If {L1+4}<16
5->{L1+2}
ElseIf {L1+4}<32
6->{L1+2}
ElseIf {L1+4}<64
7->{L1+2}
ElseIf {L1+4}<96
8->{L1+2}
ElseIf {L1+4}<128
9->{L1+2}
End
Return
Lbl INIT
0->{L1+0}.. X POSITION
56->{L1+1}.. Y POSITION
0->{L1+2}.. ANIMATION
0->{L1+3}.. ANIMATION STATE
0->{L1+4}.. ANIMATION CLOCK
*Hexadecimal Sprites into Pic0 and their sizes x,y into GDB1*
Return