- After losing a life there's some invulnerability time

This commit is contained in:
2023-01-08 19:08:06 +01:00
parent 660c8ffb65
commit e0f2578842

View File

@@ -1,11 +1,11 @@
abad={x=40,y=24,flip=false,frame=1,wait=0,hab=10,vides=3,energia=40,falling=0,step=0, mustep=1,hurting=0,update=nil,jumpfwd=false,anim={0,1,0,2},bb={x=4,y=0,w=8,h=16},safe={hab=10,x=40,y=24}}
abad={x=40,y=24,flip=false,frame=1,wait=0,respawning=0,hab=10,vides=3,energia=40,falling=0,step=0, mustep=1,hurting=0,update=nil,jumpfwd=false,anim={0,1,0,2},bb={x=4,y=0,w=8,h=16},safe={hab=10,x=40,y=24}}
function abad_nop()
end
function abad_init()
abad={x=40,y=24,flip=false,frame=1,wait=0,hab=10,vides=3,energia=40,falling=0,step=0,mustep=1,draw=abad.draw,hurting=0,update=nil,jumpfwd=false,anim={0,1,0,2},bb={x=4,y=0,w=8,h=16},safe={hab=10,x=40,y=24}}
abad={x=40,y=24,flip=false,frame=1,wait=0,respawning=0,hab=10,vides=3,energia=40,falling=0,step=0,mustep=1,draw=abad.draw,hurting=0,update=nil,jumpfwd=false,anim={0,1,0,2},bb={x=4,y=0,w=8,h=16},safe={hab=10,x=40,y=24}}
abad.update=abad_state_normal
abad.objects={}
@@ -16,9 +16,15 @@ function abad:draw()
if abad.update==abad_state_stairs then
flip=(((abad.x>>1)+(abad.y>>1))%2)==0
end
if (abad.respawning==0) or (flr(abad.respawning/15)%2==0) then
sspr(abad.frame*16,0,16,16,abad.x,abad.y,16,16,flip)
end
if abad.respawning > 0 then
abad.respawning=abad.respawning-1
end
end
function abad_make_safe()
if abad.safe.hab~=abad.hab then
abad.safe.hab=abad.hab
@@ -29,7 +35,7 @@ function abad_make_safe()
end
function abad_hurt(howmuch)
if abad.hurting == 0 then
if abad.hurting == 0 and abad.respawning==0 then
play(audio_abad_hit)
abad.energia=abad.energia-howmuch
if abad.energia<=0 then
@@ -45,6 +51,7 @@ function abad_hurt(howmuch)
abad.x=abad.safe.x
abad.y=abad.safe.y
abad.hurting=60
abad.respawning=240
cls(3)
end
else
@@ -60,6 +67,7 @@ function abad_state_normal()
abad.jumpfwd=false
if abad.hurting > 0 then
abad.hurting=abad.hurting-1
return
end
if abad.falling>0 then
@@ -83,6 +91,8 @@ function abad_state_normal()
play(audio_abad_jump)
elseif btn(KEY_DOWN) then
abad.update=abad_state_crouch
elseif btn(KEY_Z) then
abad.respawning=240
elseif btnp(KEY_SPACE) and cacau.hab==-1 then
play(audio_abad_shot)
abad.update=abad_state_fire