First of all, when posting code on the forum, click the CODE box, paste your code and then click the CODE box again. This will put it all nicely inside a code snippet box.
It is probably easier for me to post this code and have you look over it to see what was done. I would strongly suggest that you not use the goto command and use subroutines (included here) instead. If you end up making a large program, you will pull your hair out chasing after your code if you use goto's.
Anyway, here is something that should help you.
sync on
sync rate 60
backdrop on
color backdrop 0
randomize timer()
hide mouse
man = 1 : ManImage = 1
ScreenWidth = screen width() : ScreenHeight = screen height()
load image "man.bmp", ManImage
load image "man with axe1.bmp",2
load image "Man With Axe2.bmp",3
AttackDelay# = timer() : AnimDelay# = timer()
x = 1
y = 380
ManStatus = 1
sprite man,x,y,ManImage
disable escapekey
repeat
if rightkey() = 1 and x < (ScreenWidth - sprite width(man) - 4) then inc x,4
if leftkey() = 1 and x > 4 then dec x,4
if ManStatus = 2 then gosub AnimateMan
if spacekey()=1 and timer() > AttackDelay# and ManStatus = 1 then gosub attack
sprite man,x,y,MAnImage
sync
until keystate(1) = 1
delete image ManImage : delete image 2
delete sprite man
show mouse
end
attack:
ManStatus = 2 : ` attacking
ManImage = 2
sprite man,x,y,ManImage
AttackDelay# = timer() + 700
AnimDelay# = timer() + 120
return
AnimateMan:
if timer() > AnimDelay#
ManImage = sprite image(man)
if ManImage = 2
ManImage = 3
else
ManStatus = 1 : ManImage = 1
endif
AnimDelay# = timer() + 130
sprite man,x,y,ManImage
endif
return
The code assumes you have an image for a man standing (image 1), and have images showing using the axe (images 2 and 3). It is better to store values in variables instead of hard-coding them. You can rename images 2 and 3 as you see fit.
You would do well to create a 'sprite sheet' which has same sized images for the man. You can use the 'create animated sprite' command to neatly make it into images for you.
The code uses the backdrop, but you don't have to when you are only using 2D sprites. If you want to turn the backdrop off, you will have to either create everything as a sprite (including the background) or paste the non-sprite items on the screen every loop iteration.
I hope this is a help to you. Let me know if you have any questions and I will see what I can do to help.