- Reestructuració

This commit is contained in:
2023-01-13 19:16:34 +01:00
parent 22be7de746
commit b95650cee0
54 changed files with 45 additions and 0 deletions

332
data/abad.lua Normal file
View File

@@ -0,0 +1,332 @@
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,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={}
end
function abad:draw()
local flip=abad.flip
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
abad.safe.x=abad.x
abad.safe.y=abad.y
--cls(4)
end
end
function abad_hurt(howmuch)
if abad.hurting == 0 and abad.respawning==0 then
playsnd(audio_abad_hit)
abad.energia=abad.energia-howmuch
if abad.energia<=0 then
abad.vides=abad.vides-1
if abad.vides==0 then
--final de la partida
dead.start()
playmus(audio_game_over,0)
else
playmus(audio_life_lost,0)
abad.energia=40
abad.hab=abad.safe.hab
abad.x=abad.safe.x
abad.y=abad.safe.y
abad.hurting=60
abad.update=abad_state_normal
abad.bb.y=0
abad.bb.h=16
abad.respawning=240
cls(3)
end
else
cls(3)
end
end
end
function abad_state_normal()
abad.frame=0
abad.wait=0
abad.step=0
abad.jumpfwd=false
if abad.hurting > 0 then
abad.hurting=abad.hurting-1
return
end
if abad.falling>0 then
if abad.falling>12 then
abad_hurt(abad.falling-12)
end
abad.falling=0
end
abad_make_safe()
if btn(KEY_RIGHT) then
abad.update=abad_state_walking
abad.flip=false
elseif btn(KEY_LEFT) then
abad.update=abad_state_walking
abad.flip=true
elseif btn(KEY_UP) then
abad.update=abad_state_jumping
abad.step=0
abad.jumpfwd=false
if abad.jump then
stopsound(abad.jump)
abad.jump=nil
end
playsnd(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
playsnd(audio_abad_shot)
abad.update=abad_state_fire
abad.wait=0
cacau.init(abad.hab,abad.x+8,abad.y+8,abad.flip)
end
end
function abad_state_crouch()
abad.bb.y=8
abad.bb.h=8
abad.frame=5
abad.wait=0
abad.step=0
abad.jumpfwd=false
if not btn(KEY_DOWN) then
abad.update=abad_state_normal
abad.bb.y=0
abad.bb.h=16
end
end
function abad_state_fire()
abad.frame=6
abad.wait=abad.wait+1
if abad.wait==6 then
abad.wait=0
abad.update=abad_state_normal
end
end
function abad_advance()
local inc=12 if abad.flip then inc=2 end
local limit=tiletype.block
if abad.update~=abad_state_walking then limit=tiletype.half end
if not abad.flip and abad.x==84 then
abad.hab=abad.hab+1
imp.reset()
abad.x=-4
elseif check_tile(abad.hab,abad.x+inc,abad.y+14)<limit then
if abad.flip then
abad.x=abad.x-2
else
abad.x=abad.x+2
end
if abad.x<-4 then
abad.hab=abad.hab-1
imp.reset()
abad.x=84
end
end
if check_tile(abad.hab,abad.x+6,abad.y+8)==tiletype.stair then
abad.update=abad_state_stairs
elseif abad.update==abad_state_stairs then
abad.update=abad_state_normal
abad.frame=0
end
end
function abad_state_walking()
abad.wait=abad.wait+1
if abad.wait==6 then
abad.wait=0
abad.step=(abad.step+1)%2
if abad.step==0 then
playsnd(audio_abad_step[abad.mustep],32)
abad.mustep = abad.mustep + 1
if abad.mustep == 5 then abad.mustep=1 end
end
abad.frame=abad.anim[abad.step+1]
abad_advance()
if check_tile(abad.hab,abad.x+4,abad.y+16)==tiletype.void and ((abad.x+4)&7==0 or check_tile(abad.hab,abad.x+12,abad.y+16)==tiletype.void) then
abad.update=abad_state_falling
return
end
end
abad_make_safe()
if btn(KEY_UP) then
abad.update=abad_state_jumping
abad.step=0
abad.jumpfwd=true
if abad.jump then
stopsound(abad.jump)
abad.jump=nil
end
playsnd(audio_abad_jump)
return
elseif btn(KEY_DOWN) then
abad.update=abad_state_crouch
elseif btn(KEY_SPACE) and cacau.hab==-1 then
playsnd(audio_abad_shot)
abad.update=abad_state_fire
abad.wait=0
cacau.init(abad.hab,abad.x+8,abad.y+8,abad.flip)
end
if btn(KEY_RIGHT) then
abad.flip=false
elseif btn(KEY_LEFT) then
abad.flip=true
elseif abad.wait==0 then
abad.update=abad_state_normal
end
end
function abad_state_jumping()
abad.frame=3
abad.wait=abad.wait+1
--print(abad.x,1,50)
--print(abad.y,10,50)
if abad.wait==6 then
abad.wait=0
if abad.jumpfwd then abad_advance() end
--local xx=flr((abad.x+4)/8)
--local yy=flr(abad.y/8)
--rect(xx*8,yy*8, (xx+2)*8,(yy+1)*8)
if abad.step<6 then
if abad.y>0 then
if check_tile(abad.hab,abad.x+4,abad.y-2)~=tiletype.block then
if (abad.x+4)&7==0 or check_tile(abad.hab,abad.x+12,abad.y-2)~=tiletype.block then
if check_tile(abad.hab,abad.x+4,abad.y-2)==tiletype.switch then
-- Executar el switch
local xx=min(11,max(0,flr((abad.x+4)/8)))
local yy=min(5,max(0,flr((abad.y-2)/8)))
switches.start(abad.hab,1+xx+yy*12)
--cls(4)
elseif (abad.x+4)&7~=0 and check_tile(abad.hab,abad.x+12,abad.y-2)==tiletype.switch then
-- Executar el switch
local xx=min(11,max(0,flr((abad.x+12)/8)))
local yy=min(5,max(0,flr((abad.y-2)/8)))
switches.start(abad.hab,1+xx+yy*12)
--cls(4)
else
abad.y=abad.y-2
end
end
end
else
abad.hab=abad.hab-10
imp.reset()
abad.y=32
end
elseif abad.step>6 then
abad.update=abad_state_falling
abad.jump=playsnd(audio_abad_fall)
end
abad.step=abad.step+1
end
end
function abad_state_falling()
abad.frame=3
abad.wait=abad.wait+1
if abad.wait==6 then
abad.wait=0
if abad.jumpfwd then abad_advance() end
local xx=flr((abad.x+4)/8)
local yy=flr((abad.y+16)/8)
if abad.y<32 then
if (abad.y+16)&7==0 and (check_tile(abad.hab,abad.x+4,abad.y+16)>=tiletype.half or ((abad.x+4)&7~=0 and check_tile(abad.hab,abad.x+12,abad.y+16)>=tiletype.half)) then
abad.update=abad_state_normal
return
end
abad.y=abad.y+2
abad.falling=abad.falling+1
else
abad.hab=abad.hab+10
imp.reset()
abad.y=0
end
end
end
function abad_state_stairs()
abad.frame=4
abad.wait=abad.wait+1
if abad.wait==6 then
abad.wait=0
if btn(KEY_RIGHT) then
abad.flip=false
abad_advance()
playsnd(audio_low)
elseif btn(KEY_LEFT) then
abad.flip=true
abad_advance()
playsnd(audio_low)
elseif btn(KEY_UP) then
if abad.y>0 then
if check_tile(abad.hab,abad.x+4,abad.y+8)==tiletype.stair or (abad.x+4)&7~=0 and check_tile(abad.hab,abad.x+12,abad.y+8)==tiletype.stair then
abad.y=abad.y-2
playsnd(audio_low)
end
else
abad.hab=abad.hab-10
imp.reset()
abad.y=32
end
elseif btn(KEY_DOWN) then
if abad.y<32 then
if check_tile(abad.hab,abad.x+4,abad.y+16)==tiletype.stair or (abad.x+4)&7~=0 and check_tile(abad.hab,abad.x+12,abad.y+16)==tiletype.stair then
abad.y=abad.y+2
playsnd(audio_low)
end
else
abad.hab=abad.hab+10
imp.reset()
abad.y=0
end
end
end
end

20
data/audio.lua Normal file
View File

@@ -0,0 +1,20 @@
audio_main_song="mus_menu.ogg"
audio_song_batman="mus_batm.ogg"
audio_song_premiere="mus_prem.ogg"
audio_song_elalien="mus_alie.ogg"
audio_life_lost="mus_life.ogg"
audio_game_over="mus_over.ogg"
audio_final=audio_main_song
audio_abad_jump="snd_ajmp.wav"
audio_abad_fall="snd_afal.wav"
audio_abad_hit="snd_ahit.wav"
audio_abad_shot="snd_asht.wav"
audio_abad_step={"snd_ast1.wav", "snd_ast2.wav", "snd_ast3.wav", "snd_ast2.wav"}
audio_switch="snd_swch.wav"
audio_hit="snd_hit.wav"
audio_low="snd_low.wav"
audio_text_abad="snd_txta.wav"
audio_text_premiere="snd_txtp.wav"
audio_text_elalien="snd_txte.wav"
audio_text_batman="snd_txtb.wav"

135
data/bambolla.lua Normal file
View File

@@ -0,0 +1,135 @@
bambolla={hab=75,x=24,y=24,cx=0,dx=0,dy=0,flip=true,enabled=false,counter=800,wait=0,bb={x=4,y=4,w=8,h=8}}
function bambolla.reset()
bambolla.hit=bambolla.hit
bambolla.update=bambolla.update_normal
bambolla.draw=bambolla.draw_normal
bambolla.hab=abad.hab
bambolla.enabled=false
bambolla.counter=800
end
function bambolla.init()
bambolla.enabled=false
bambolla.hit=bambolla.hit
bambolla.update=bambolla.update_normal
bambolla.draw=bambolla.draw_normal
bambolla.hab=abad.hab
if abad.x<40 then
if check_tile(bambolla.hab,92,38)<tiletype.half and
check_tile(bambolla.hab,84,38)<tiletype.half and
check_tile(bambolla.hab,92,30)<tiletype.half and
check_tile(bambolla.hab,84,30)<tiletype.half and
check_tile(bambolla.hab,92,46)>=tiletype.half then
bambolla.enabled=true
bambolla.flip=true
bambolla.x=92
else
bambolla.reset()
end
else
if check_tile(bambolla.hab,0,38)<tiletype.half and
check_tile(bambolla.hab,8,38)<tiletype.half and
check_tile(bambolla.hab,0,30)<tiletype.half and
check_tile(bambolla.hab,0,30)<tiletype.half and
check_tile(bambolla.hab,0,46)>=tiletype.half then
bambolla.enabled=true
bambolla.flip=false
bambolla.x=-12
else
bambolla.reset()
end
end
end
function bambolla.draw_normal()
if bambolla.enabled then
sspr(112,16,16,16,bambolla.x,bambolla.y,16,16)
end
end
function bambolla.hit()
end
function bambolla.update_normal()
bambolla.wait=bambolla.wait+1
if bambolla.wait==3 then
bambolla.wait=0
if not bambolla.enabled then
bambolla.counter=bambolla.counter-1
local r = rnd(bambolla.counter)
--print(r)
if bambolla.counter==1 or r==1 then
bambolla.init()
end
return
end
if bambolla.flip then
bambolla.x=bambolla.x-2
if bambolla.x<=-12 then
bambolla.reset()
end
else
bambolla.x=bambolla.x+2
if bambolla.x>=92 then
bambolla.reset()
end
end
bambolla.y=28-abs(sin(bambolla.x*0.1))*24
if bambolla.hab==abad.hab and bambolla.y>25.2 then
playsnd(audio_low)
end
if bambolla.hab==abad.hab then
if cacau.hab==bambolla.hab and aabb(bambolla,cacau) then
bambolla.update=bambolla.update_splash
bambolla.draw=bambolla.draw_splash
bambolla.cx=bambolla.x+8
bambolla.y=bambolla.y+8
bambolla.dx=0
bambolla.dy=-4
playsnd(audio_hit)
end
if aabb(bambolla,abad) then
abad_hurt(1)
bambolla.update=bambolla.update_splash
bambolla.draw=bambolla.draw_splash
bambolla.cx=bambolla.x+8
bambolla.y=bambolla.y+8
bambolla.dx=0
bambolla.dy=-4
end
end
end
end
bambolla.update=bambolla.update_normal
bambolla.draw=bambolla.draw_normal
function bambolla.draw_splash()
circfill(bambolla.cx+bambolla.dx,bambolla.y,2,16)
circfill(bambolla.cx+bambolla.dx,bambolla.y,1,6)
circfill(bambolla.cx-bambolla.dx,bambolla.y,2,16)
circfill(bambolla.cx-bambolla.dx,bambolla.y,1,6)
circfill(bambolla.cx-(bambolla.dx/2),bambolla.y-4,2,16)
circfill(bambolla.cx-(bambolla.dx/2),bambolla.y-4,1,6)
circfill(bambolla.cx+(bambolla.dx/2),bambolla.y-4,2,16)
circfill(bambolla.cx+(bambolla.dx/2),bambolla.y-4,1,6)
end
function bambolla.update_splash()
bambolla.wait=bambolla.wait+1
if bambolla.wait==3 then
bambolla.wait=0
bambolla.dx=bambolla.dx-2
bambolla.x=bambolla.cx+bambolla.dx
bambolla.y=bambolla.y+bambolla.dy
bambolla.dy=bambolla.dy+1
if bambolla.y>48 then
bambolla.reset()
end
end
end

250
data/batman.lua Normal file
View File

@@ -0,0 +1,250 @@
batman={hab=5,x=24,y=24,flip=true,goup=true,frame=8,stairscooldown=0,stepscooldown=0,stepsremember=0,wait=0,step=0,anim={24,25,24,26},bb={x=4,y=0,w=8,h=16},scene_intro=false,scene_object=false}
function batman.init()
batman.hit=batman.hit
batman.update=batman.update_normal
batman.draw=batman.draw
local habs={5,9,46,36,18}
batman.hab=habs[1+rnd(#habs)]
end
function batman.draw()
local flip=batman.flip
if batman.update==batman.update_stairs then
flip=(((batman.x>>1)+(batman.y>>1))%2)==0
end
sspr((batman.frame&7)*16,(batman.frame>>3)*16,16,16,batman.x,batman.y,16,16,flip)
end
function batman.hit()
if abad.objects.bol~=nil then
batman.endgame=true
-- Start end of the game
start_scene(scenes.final)
end
end
function batman.update_normal()
batman.wait=batman.wait+1
if batman.wait>=6 then
batman.wait=0
if batman.stairscooldown>0 then batman.stairscooldown=batman.stairscooldown-1 end
batman.step=(batman.step+1)%4
if batman.stepscooldown>0 then batman.stepscooldown=batman.stepscooldown-1 end
batman.frame=batman.anim[batman.step+1]
local inc=12 if batman.flip then inc=2 end
if not batman.flip and batman.x==84 then
batman.hab=batman.hab+1
batman.x=-4
elseif check_tile(batman.hab,batman.x+inc,batman.y+14)==tiletype.nonpc then
--if rnd(10)<8 then
batman.update=batman.update_jumping
batman.step=0
--else
-- batman.flip=not batman.flip
--end
elseif check_tile(batman.hab,batman.x+inc,batman.y+14)<tiletype.half then
if batman.flip then
batman.x=batman.x-2
else
batman.x=batman.x+2
end
if batman.x<-4 then
batman.hab=batman.hab-1
batman.x=84
end
elseif check_tile(batman.hab,batman.x+inc,batman.y+6)<tiletype.half then
local r=rnd(2)
if check_tile(batman.hab,batman.x+inc,batman.y+14)==tiletype.block then r=0 end
if batman.stepscooldown>0 and check_tile(batman.hab,batman.x+inc,batman.y+14)==tiletype.half then r=batman.stepsremember end
if r==0 then
batman.update=batman.update_jumping
batman.step=0
else
if batman.flip then
batman.x=batman.x-2
else
batman.x=batman.x+2
end
if batman.x<-4 then
batman.hab=batman.hab-1
batman.x=84
end
end
if batman.stepscooldown==0 then
batman.stepscooldown=30
batman.stepsremember=r
end
else
--if check_tile(batman.hab,batman.x+4,batman.y+16)==tiletype.void and ((batman.x+4)&7==0 or check_tile(batman.hab,batman.x+12,batman.y+16)==tiletype.void) then
--batman.update=batman.update_falling
--else
batman.flip=not batman.flip
--end
end
if batman.stairscooldown==0 and
check_tile(batman.hab,batman.x+6,batman.y+8)==tiletype.stair and
check_tile(batman.hab,batman.x+14,batman.y+8)==tiletype.stair then
if rnd(10)<8 then
batman.update=batman.update_stairs
if check_tile(batman.hab,batman.x+4,batman.y+16)==tiletype.block then
batman.goup=true
else
batman.goup=false
end
--batman.goup=rnd(2)==0 and true or false
else
batman.stairscooldown=50
end
elseif batman.update==batman.update_stairs then
batman.stairscooldown=50
batman.update=batman.update_normal
batman.frame=24
end
if check_tile(batman.hab,batman.x+4,batman.y+16)==tiletype.void and ((batman.x+4)&7==0 or check_tile(batman.hab,batman.x+12,batman.y+16)==tiletype.void) then
local option=rnd(2)
if batman.stairscooldown>0 then option=0 end
if option==0 then
batman.update=batman.update_falling
else
batman.update=batman.update_jumping
batman.step=0
batman.wait=0
--else
-- batman.flip=not batman.flip
end
end
if batman.hab==abad.hab then
if aabb(abad,batman) then
abad_hurt(40)
end
end
end
end
function batman.update_jumping()
batman.frame=25
batman.wait=batman.wait+1
if batman.wait>=6 then
batman.wait=0
local inc=12 if batman.flip then inc=2 end
if not batman.flip and batman.x==84 then
batman.hab=batman.hab+1
batman.x=-4
elseif check_tile(batman.hab,batman.x+inc,batman.y+14)<tiletype.half then
if batman.flip then
batman.x=batman.x-2
else
batman.x=batman.x+2
end
if batman.x<-4 then
batman.hab=batman.hab-1
batman.x=84
end
end
if batman.step<6 then
if batman.y>0 then
if check_tile(batman.hab,batman.x+4,batman.y-2)~=tiletype.block then
if (batman.x+4)&7==0 or check_tile(batman.hab,batman.x+12,batman.y-2)~=tiletype.block then
batman.y=batman.y-2
end
end
else
batman.hab=batman.hab-10
batman.y=32
end
elseif batman.step>6 then
batman.update=batman.update_falling
end
batman.step=batman.step+1
end
end
function batman.update_falling()
batman.frame=25
batman.wait=batman.wait+1
if batman.wait>=6 then
batman.wait=0
local inc=12 if batman.flip then inc=2 end
if not batman.flip and batman.x==84 then
batman.hab=batman.hab+1
batman.x=-4
elseif check_tile(batman.hab,batman.x+inc,batman.y+14)<tiletype.half then
if batman.flip then
batman.x=batman.x-2
else
batman.x=batman.x+2
end
if batman.x<-4 then
batman.hab=batman.hab-1
batman.x=84
end
end
if batman.y<32 then
if (batman.y+16)&7==0 and (check_tile(batman.hab,batman.x+4,batman.y+16)>=tiletype.half or ((batman.x+4)&7~=0 and check_tile(batman.hab,batman.x+12,batman.y+16)>=tiletype.half)) then
batman.update=batman.update_normal
return
end
batman.y=batman.y+2
else
batman.hab=batman.hab+10
batman.y=0
end
end
end
function batman.update_stairs()
batman.frame=27
batman.wait=batman.wait+1
if batman.wait>=6 then
batman.wait=0
--if btn(KEY_RIGHT) then
-- batman.flip=false
-- batman_advance()
--elseif btn(KEY_LEFT) then
-- batman.flip=true
-- batman_advance()
if batman.goup then
if batman.y>0 then
if check_tile(batman.hab,batman.x+4,batman.y+8)==tiletype.stair or (batman.x+4)&7~=0 and check_tile(batman.hab,batman.x+12,batman.y+8)==tiletype.stair then
batman.y=batman.y-2
else
batman.update=batman.update_normal
if rnd(3)>0 then batman.flip=not batman.flip end
batman.stairscooldown=50
end
else
batman.hab=batman.hab-10
batman.y=32
end
else
if batman.y<32 then
if check_tile(batman.hab,batman.x+4,batman.y+16)==tiletype.stair or (batman.x+4)&7~=0 and check_tile(batman.hab,batman.x+12,batman.y+16)==tiletype.stair then
batman.y=batman.y+2
else
batman.update=batman.update_normal
if rnd(3)>0 then batman.flip=not batman.flip end
batman.stairscooldown=50
end
else
batman.hab=batman.hab+10
batman.y=0
end
end
end
end

20
data/bol.lua Normal file
View File

@@ -0,0 +1,20 @@
bol={hab=39,x=28,y=25,bb={x=0,y=0,w=16,h=8}}
function bol.init()
bol.update=bol.update
bol.draw=bol.draw
end
function bol.draw()
sspr(112,88,16,8,bol.x,bol.y,16,8)
end
function bol.update()
if bol.hab==abad.hab then
if aabb(abad,bol) then
abad.objects.bol=true
start_scene(scenes.bol_trobat)
remove_actor(bol)
end
end
end

41
data/cacau.lua Normal file
View File

@@ -0,0 +1,41 @@
cacau={hab=-1,x=0,y=0,wait=0,flip=false,bb={x=0,y=0,w=4,h=4}}
function cacau.init(_hab,_x,_y,_flip)
if cacau.hab ~= -1 then return end
cacau.hab=_hab
cacau.x=_x
cacau.y=_y
cacau.flip=_flip
end
function cacau:draw()
circfill(cacau.x,cacau.y,2,16)
circfill(cacau.x,cacau.y,1,6)
end
function cacau:update()
if cacau.hab == -1 then return end
cacau.wait=cacau.wait+1
if cacau.wait==3 then
cacau.wait=0
if cacau.x>96 then
cacau.hab=-1
return
elseif check_tile(cacau.hab,cacau.x,cacau.y)<tiletype.block then
if cacau.flip then
cacau.x=cacau.x-4
else
cacau.x=cacau.x+4
end
if cacau.x<-4 then
cacau.hab=-1
return
end
else
cacau.hab=-1
return
end
end
end

79
data/caco.lua Normal file
View File

@@ -0,0 +1,79 @@
caco={}
function caco.new(_hab,_x,_y,_flip)
return {hab=_hab,x=_x,y=_y,flip=_flip,frame=19,wait=0,step=0,hit=caco.hit,update=caco.update_normal,draw=caco.draw,jumpfwd=false,anim={19,19,20,21},bb={x=2,y=4,w=12,h=8}}
end
function caco:draw()
if self.frame>0 then sspr((self.frame&7)*16,(self.frame>>3)*16,16,16,self.x,self.y,16,16,self.flip) end
end
function caco:update_normal()
self.wait=self.wait+1
if self.wait==6 then
self.wait=0
self.step=self.step+1
if self.step<12 then
self.frame=19
elseif self.step==12 then
self.frame=20
elseif self.step==13 then
self.frame=21
self.step=0
end
local inc=14 if self.flip then inc=0 end
if not self.flip and self.x==84 then
self.hab=self.hab+1
self.x=-4
elseif check_tile(self.hab,self.x+inc,self.y+14)<tiletype.block then
if self.flip then
self.x=self.x-2
else
self.x=self.x+2
end
if self.x<-4 then
self.hab=self.hab-1
self.x=84
end
else
self.flip=not self.flip
end
if self.hab==abad.hab then
if aabb(abad,self) then
abad_hurt(1)
end
end
--if check_tile(self.hab,self.x+4,self.y+16)==tiletype.void and ((self.x+4)&7==0 or check_tile(self.hab,self.x+12,self.y+16)==tiletype.void) then
-- self.flip=not self.flip
--end
end
end
function caco:update_hit()
self.wait=self.wait+1
if self.wait==6 then
self.wait=0
self.step=self.step+1
if self.step<40 then
if self.step%2==0 then
self.frame=21
else
self.frame=-1
end
elseif self.step>=40 then
self.frame=19
self.step=0
self.wait=0
self.update=caco.update_normal
end
end
end
function caco:hit()
self.update=caco.update_hit
end

48
data/dead.lua Normal file
View File

@@ -0,0 +1,48 @@
dead={}
function dead.start()
dead.count=0
dead.pos={}
dead.vel={}
for i=1,128 do
dead.pos[i]=0
dead.vel[i]=(200+rnd(400))/400
end
_update=dead.update
end
function dead.update()
dead.count=dead.count+1
for i=1,128 do
if dead.pos[i]<96 then
dead.pos[i]=dead.pos[i]+dead.vel[i]
vline(i-1,0,dead.pos[i],16)
end
end
if dead.count>50 then
if dead.count>130 then
prnt("GAME OVER",44,40,2)
elseif dead.count>120 then
prnt("GAME OVE",44,40,2)
elseif dead.count>110 then
prnt("GAME OV",44,40,2)
elseif dead.count>100 then
prnt("GAME O",44,40,2)
elseif dead.count>90 then
prnt("GAME",44,40,2)
elseif dead.count>80 then
prnt("GAM",44,40,2)
elseif dead.count>70 then
prnt("GA",44,40,2)
elseif dead.count>60 then
prnt("G",44,40,2)
end
end
if (dead.count>250 and btnp(KEY_SPACE)) or dead.count>500 then
game_exit()
game_init(true)
--_init()
--_update=update_game
end
end

260
data/elalien.lua Normal file
View File

@@ -0,0 +1,260 @@
elalien={hab=66,x=24,y=24,flip=true,goup=true,frame=8,stairscooldown=0,wait=0,step=0,anim={8,9,8,10},bb={x=4,y=0,w=8,h=16},scene_intro=false,scene_object=false}
function elalien.init()
elalien.x=24
elalien.y=24
elalien.frame=8
elalien.stairscooldown=0
elalien.wait=0
elalien.step=0
elalien.update=elalien.update_normal
elalien.scene_intro=false
elalien.scene_object=false
local habs={66,56,59,53}
elalien.hab=habs[1+rnd(4)]
end
function elalien.draw()
local flip=elalien.flip
if elalien.update==elalien.update_stairs then
flip=(((elalien.x>>1)+(elalien.y>>1))%2)==0
end
sspr((elalien.frame&7)*16,(elalien.frame>>3)*16,16,16,elalien.x,elalien.y,16,16,flip)
end
function elalien.hit()
end
function elalien.update_normal()
elalien.wait=elalien.wait+1
if elalien.wait>=6 then
elalien.wait=0
if elalien.stairscooldown>0 then elalien.stairscooldown=elalien.stairscooldown-1 end
elalien.step=(elalien.step+1)%4
elalien.frame=elalien.anim[elalien.step+1]
local inc=12 if elalien.flip then inc=2 end
if not elalien.flip and elalien.x==84 then
elalien.hab=elalien.hab+1
elalien.x=-4
elseif check_tile(elalien.hab,elalien.x+inc,elalien.y+14)==tiletype.nonpc then
--if rnd(10)<8 then
elalien.update=elalien.update_jumping
elalien.step=0
--else
-- elalien.flip=not elalien.flip
--end
elseif check_tile(elalien.hab,elalien.x+inc,elalien.y+14)<tiletype.half then
if elalien.flip then
elalien.x=elalien.x-2
else
elalien.x=elalien.x+2
end
if elalien.x<-4 then
elalien.hab=elalien.hab-1
elalien.x=84
end
elseif check_tile(elalien.hab,elalien.x+inc,elalien.y+6)<tiletype.half then
local r=rnd(2)
if check_tile(elalien.hab,elalien.x+inc,elalien.y+14)==tiletype.block then r=0 end
if r==0 then
elalien.update=elalien.update_jumping
elalien.step=0
else
if elalien.flip then
elalien.x=elalien.x-2
else
elalien.x=elalien.x+2
end
if elalien.x<-4 then
elalien.hab=elalien.hab-1
elalien.x=84
end
end
else
--if check_tile(elalien.hab,elalien.x+4,elalien.y+16)==tiletype.void and ((elalien.x+4)&7==0 or check_tile(elalien.hab,elalien.x+12,elalien.y+16)==tiletype.void) then
--elalien.update=elalien.update_falling
--else
elalien.flip=not elalien.flip
--end
end
if elalien.stairscooldown==0 and
check_tile(elalien.hab,elalien.x+6,elalien.y+8)==tiletype.stair and
check_tile(elalien.hab,elalien.x+14,elalien.y+8)==tiletype.stair then
if rnd(10)<8 then
elalien.update=elalien.update_stairs
if check_tile(elalien.hab,elalien.x+4,elalien.y+16)==tiletype.block then
elalien.goup=true
else
elalien.goup=false
end
--elalien.goup=rnd(2)==0 and true or false
else
elalien.stairscooldown=50
end
elseif elalien.update==elalien.update_stairs then
elalien.stairscooldown=50
elalien.update=elalien.update_normal
elalien.frame=8
end
if check_tile(elalien.hab,elalien.x+4,elalien.y+16)==tiletype.void and ((elalien.x+4)&7==0 or check_tile(elalien.hab,elalien.x+12,elalien.y+16)==tiletype.void) then
local option=rnd(2)
if elalien.stairscooldown>0 then option=0 end
if option==0 then
elalien.update=elalien.update_falling
else
elalien.update=elalien.update_jumping
elalien.step=0
elalien.wait=0
--else
-- elalien.flip=not elalien.flip
end
end
if elalien.hab==abad.hab then
if aabb(abad,elalien) then
if not elalien.scene_intro then
if abad.objects.peu~=nil then
start_scene(scenes.elalien_intro_peu)
elalien.scene_object=true
abad.objects.clau_elalien=true
abad.objects.peu=nil
else
start_scene(scenes.elalien_intro)
end
elalien.scene_intro=true
elseif not elalien.scene_object and abad.objects.peu~=nil then
start_scene(scenes.elalien_peu)
elalien.scene_object=true
abad.objects.clau_elalien=true
abad.objects.peu=nil
end
end
end
end
end
function elalien.update_jumping()
elalien.frame=9
elalien.wait=elalien.wait+1
if elalien.wait>=6 then
elalien.wait=0
local inc=12 if elalien.flip then inc=2 end
if not elalien.flip and elalien.x==84 then
elalien.hab=elalien.hab+1
elalien.x=-4
elseif check_tile(elalien.hab,elalien.x+inc,elalien.y+14)<tiletype.half then
if elalien.flip then
elalien.x=elalien.x-2
else
elalien.x=elalien.x+2
end
if elalien.x<-4 then
elalien.hab=elalien.hab-1
elalien.x=84
end
end
if elalien.step<6 then
if elalien.y>0 then
if check_tile(elalien.hab,elalien.x+4,elalien.y-2)~=tiletype.block then
if (elalien.x+4)&7==0 or check_tile(elalien.hab,elalien.x+12,elalien.y-2)~=tiletype.block then
elalien.y=elalien.y-2
end
end
else
elalien.hab=elalien.hab-10
elalien.y=32
end
elseif elalien.step>6 then
elalien.update=elalien.update_falling
end
elalien.step=elalien.step+1
end
end
function elalien.update_falling()
elalien.frame=9
elalien.wait=elalien.wait+1
if elalien.wait>=6 then
elalien.wait=0
local inc=12 if elalien.flip then inc=2 end
if not elalien.flip and elalien.x==84 then
elalien.hab=elalien.hab+1
elalien.x=-4
elseif check_tile(elalien.hab,elalien.x+inc,elalien.y+14)<tiletype.half then
if elalien.flip then
elalien.x=elalien.x-2
else
elalien.x=elalien.x+2
end
if elalien.x<-4 then
elalien.hab=elalien.hab-1
elalien.x=84
end
end
if elalien.y<32 then
if (elalien.y+16)&7==0 and (check_tile(elalien.hab,elalien.x+4,elalien.y+16)>=tiletype.half or ((elalien.x+4)&7~=0 and check_tile(elalien.hab,elalien.x+12,elalien.y+16)>=tiletype.half)) then
elalien.update=elalien.update_normal
return
end
elalien.y=elalien.y+2
else
elalien.hab=elalien.hab+10
elalien.y=0
end
end
end
function elalien.update_stairs()
elalien.frame=11
elalien.wait=elalien.wait+1
if elalien.wait>=6 then
elalien.wait=0
--if btn(KEY_RIGHT) then
-- elalien.flip=false
-- elalien_advance()
--elseif btn(KEY_LEFT) then
-- elalien.flip=true
-- elalien_advance()
if elalien.goup then
if elalien.y>0 then
if check_tile(elalien.hab,elalien.x+4,elalien.y+8)==tiletype.stair or (elalien.x+4)&7~=0 and check_tile(elalien.hab,elalien.x+12,elalien.y+8)==tiletype.stair then
elalien.y=elalien.y-2
else
elalien.update=elalien.update_normal
if rnd(3)>0 then elalien.flip=not elalien.flip end
elalien.stairscooldown=50
end
else
elalien.hab=elalien.hab-10
elalien.y=32
end
else
if elalien.y<32 then
if check_tile(elalien.hab,elalien.x+4,elalien.y+16)==tiletype.stair or (elalien.x+4)&7~=0 and check_tile(elalien.hab,elalien.x+12,elalien.y+16)==tiletype.stair then
elalien.y=elalien.y+2
else
elalien.update=elalien.update_normal
if rnd(3)>0 then elalien.flip=not elalien.flip end
elalien.stairscooldown=50
end
else
elalien.hab=elalien.hab+10
elalien.y=0
end
end
end
end

99
data/fade.lua Normal file
View File

@@ -0,0 +1,99 @@
fade = {
table={13,15,5,3,12,5,6,7,12,9,10,16,9,13,14},
pal={},
old_update=nil,
wait=0,
step=0,
outin=false,
init = function()
for i=1,15 do
local r,g,b=getcolor(i)
fade.pal[i]={r,g,b}
end
end,
getstep=function(num,steps)
if steps==0 or num==16 then return num end
for i=1,steps do
num=fade.table[num]
if num==16 then return num end
end
return num
end,
fadeout = function()
--print("fading out")
fade.old_update=_update
_update=fade.update_fadeout
fade.wait=0
fade.step=0
end,
fadeoutin = function()
--print("fading outin")
fade.old_update=_update
_update=fade.update_fadeout
fade.wait=0
fade.step=0
fade.outin=true
end,
update_fadeout=function()
--print("out")
fade.wait=fade.wait+1
if fade.wait==6 then
fade.wait=0
for i=1,15 do
local v=fade.getstep(i,fade.step)
--print(v)
if v==16 then
setcolor(i,0,0,0)
else
setcolor(i,fade.pal[v][1],fade.pal[v][2],fade.pal[v][3])
end
end
fade.step=fade.step+1
if fade.step==7 then
_update = fade.old_update
if fade.outin then
fade.outin=false;
fade.fadein()
end
end
end
end,
fadein = function()
--print("fading in")
fade.old_update=_update
_update=fade.update_fadein
fade.wait=0
fade.step=6
for i=1,15 do setcolor(i,0,0,0) end
end,
update_fadein=function()
--print("in")
fade.old_update()
fade.wait=fade.wait+1
if fade.wait==6 then
fade.wait=0
for i=1,15 do
local v=fade.getstep(i,fade.step)
--print(v)
if v==16 then
setcolor(i,0,0,0)
else
setcolor(i,fade.pal[v][1],fade.pal[v][2],fade.pal[v][3])
end
end
fade.step=fade.step-1
if fade.step<0 then
_update = fade.old_update
end
end
end
}

158
data/final.lua Normal file
View File

@@ -0,0 +1,158 @@
final_rooms = {2,6,60,21,49,23,66,32,4,46,39,55,74}
function final_init()
actors={}
cameras={}
current_actor=1
abad.update = abad_nop
_update=update_final
next_actor()
playmus(audio_final)
local r,g,b=getcolor(15)
setcolor(17,r,g,b)
--fade.fadein()
end
go_next_actor=false
function update_final()
cls(16)
camera(-16,-41)
mapa_draw(final_room)
draw_actor()
camera(0,0)
rectfill(0,0,14,96,16)
rectfill(114,0,191,96,16)
rect(15,40,113,89,2)
text("C A C A U S", 42, 12, 17)
text(actor.name, 64-(#actor.name*2), 28, 11)
mapa_update(abad.hab,final_room)
if btnp(KEY_M) then
mute = not mute
if mute then
stopmusic()
else
playmus(audio_final)
end
end
if go_next_actor then next_actor() end
end
function init_actor(name,flipped,w,h,anim)
actor={name=name,flip=flipped,w=w,h=h,anim=anim,frame=0,wait=0,step=0}
actor.y=40-h
actor.center_count=20
actor.frame=actor.anim[1]
if #anim==1 then
actor.x=48-w/2
actor.center_count=40
elseif flipped then
actor.x=96
else
actor.x=-actor.w
end
end
function draw_actor()
actor.wait=actor.wait+1
if actor.wait==6 or (actor.wait==3 and current_actor==7) then
actor.wait=0
if actor.x == 48-actor.w/2 and actor.center_count>0 then
actor.center_count=actor.center_count-1
actor.frame=actor.anim[1]
else
actor.step=actor.step+1
if actor.step >= #actor.anim then actor.step=0 end
actor.frame=actor.anim[actor.step+1]
if #actor.anim>1 then
if actor.flip then
actor.x=actor.x-2
else
actor.x=actor.x+2
end
end
if current_actor==7 then
actor.y=28-abs(sin(actor.x*0.1))*24
end
if actor.x>96 or actor.x<-actor.w or (#actor.anim==1 and actor.center_count==0) then
go_next_actor=true
fade.fadeoutin()
return true
end
end
end
local tpl=128/actor.w
sspr((actor.frame%tpl)*actor.w,flr(actor.frame/tpl)*actor.h,actor.w,actor.h,actor.x,actor.y,actor.w,actor.h,actor.flip)
end
function next_actor()
go_next_actor=false
faded = true
if current_actor==1 then
init_actor("ZOMBIE",false,16,16,{16,17,16,18})
elseif current_actor==2 then
init_actor("CACODEMON",true,16,16,{19,19,19,19,19,19,19,19,19,19,19,19,20,21})
actor.y=16
elseif current_actor==3 then
init_actor("GPS",false,16,16,{31})
actor.y=16
elseif current_actor==4 then
init_actor("IMP",false,16,16,{28,29,28,30})
elseif current_actor==5 then
init_actor("GORRO DE PREMIERE",false,16,16,{22})
elseif current_actor==6 then
init_actor("BAMBOLLA DE CAFÉ",true,16,16,{15,15})
elseif current_actor==7 then
init_actor("PEU DE PACO",false,16,16,{23})
elseif current_actor==8 then
init_actor("PREMIERE",false,16,16,{12,13,12,14})
elseif current_actor==9 then
init_actor("CLAU",false,16,8,{15})
elseif current_actor==10 then
init_actor("EL_ALIEN",true,16,16,{8,9,8,10})
elseif current_actor==11 then
init_actor("BOL DE CACAUS",false,16,8,{95})
elseif current_actor==12 then
init_actor("BATMAN",false,16,16,{24,25,24,26})
elseif current_actor==13 then
init_actor("EL ABAD",true,16,16,{0,1,0,2})
elseif current_actor==14 then
final_count=0
_update=update_final2
fade.fadeoutin()
end
final_room=final_rooms[current_actor]
current_actor=current_actor+1
end
function update_final2()
cls(16)
text("C A C A U S", 42, 12, 17)
text("GRACIES PER JUGAR", 30, 48, 10)
if btnp(KEY_M) then
mute = not mute
if mute then
stopmusic()
else
playmus(audio_final)
end
end
final_count=final_count+1
if final_count==200 or btnp(KEY_SPACE) or btnp(KEY_RETURN) then
game_exit()
game_init(true)
fade.fadeoutin()
end
end

49
data/fireball.lua Normal file
View File

@@ -0,0 +1,49 @@
fireball={hab=-1,x=0,y=0,wait=0,flip=false,bb={x=0,y=0,w=4,h=4}}
function fireball.init(_hab,_x,_y,_flip)
if fireball.hab ~= -1 then return end
fireball.hab=_hab
fireball.x=_x
fireball.y=_y
fireball.flip=_flip
end
function fireball:draw()
circfill(fireball.x,fireball.y,3,16)
circfill(fireball.x,fireball.y,2,3)
circfill(fireball.x,fireball.y,1,8)
end
function fireball:update()
if fireball.hab == -1 then return end
fireball.wait=fireball.wait+1
if fireball.wait==3 then
fireball.wait=0
if fireball.x>96 then
fireball.hab=-1
return
elseif check_tile(fireball.hab,fireball.x,fireball.y)<tiletype.block then
if fireball.flip then
fireball.x=fireball.x-4
else
fireball.x=fireball.x+4
end
if fireball.x<-4 then
fireball.hab=-1
return
end
else
fireball.hab=-1
return
end
if fireball.hab==abad.hab then
if aabb(fireball,abad) and abad.update~=abad_state_crouch then
fireball.hab=-1
abad_hurt(1)
end
end
end
end

5
data/game.ini Normal file
View File

@@ -0,0 +1,5 @@
title=Cacaus
width=128
height=96
zoom=5
files=final.lua,fade.lua,audio.lua,dead.lua,scenes.lua,trigger.lua,score.lua,switches.lua,map.lua,mapa.lua,bol.lua,invisibl.lua,gota.lua,fireball.lua,cacau.lua,bambolla.lua,imp.lua,gps.lua,peu.lua,gorro.lua,batman.lua,elalien.lua,premiere.lua,caco.lua,zombie.lua,abad.lua,intro.lua,game.lua,main.lua

413
data/game.lua Normal file
View File

@@ -0,0 +1,413 @@
--hab=0
modes={playing=0,editing=1}
--mode=modes.editing
mode=modes.playing
seltile = 0
actors={}
cameras={}
camera_names={[0]="GPS","Gorro","Peu de Paco","Premiere","EL_ALIEN","BatMan"}
current_camera=0
mute=false
function remove_actor(actor)
for index, value in pairs(actors) do
if value == actor then
table.remove(actors,index)
end
end
end
function playmus(song,loop)
if not mute then
playmusic(song,loop)
end
end
function playsnd(sound,volume)
if not mute then
--print(sound)
return playsound(sound,volume)
end
end
function game_init(menu)
actors={}
cameras={}
camera_names={[0]="GPS","Gorro","Peu de Paco","Premiere","EL_ALIEN","BatMan"}
current_camera=0
-- ACTORS PRINCIPALS
abad_init()
table.insert(actors,abad)
gps.init()
table.insert(actors,gps)
gorro.init()
table.insert(actors,gorro)
peu.init()
table.insert(actors,peu)
premiere.init()
table.insert(actors,premiere)
elalien.init()
table.insert(actors,elalien)
batman.init()
table.insert(actors,batman)
bol.init()
table.insert(actors,bol)
-- MALOTES PERSISTENTS
table.insert(actors,gota.new(70,40,8,20))
table.insert(actors,gota.new(70,72,8,30))
table.insert(actors,gota.new(63,40,4,25))
table.insert(actors,gota.new(63,72,4,20))
table.insert(actors,gota.new(64,24,4,10))
table.insert(actors,gota.new(64,48,4,25))
table.insert(actors,gota.new(65,56,4,10))
table.insert(actors,gota.new(65,63,4,25))
table.insert(actors,gota.new(66,24,4,10))
table.insert(actors,gota.new(66,32,4,15))
table.insert(actors,gota.new(77,16,4,30))
table.insert(actors,gota.new(77,72,4,25))
table.insert(actors,invisible.new(77,40,32))
table.insert(actors,invisible.new(77,48,32))
table.insert(actors,invisible.new(58,16,32))
table.insert(actors,invisible.new(58,16,32))
table.insert(actors,zombie.new(2,24,24,false))
table.insert(actors,caco.new(13,24,16,true))
table.insert(actors,caco.new(20,24,16,false))
table.insert(actors,zombie.new(32,24,24,false))
table.insert(actors,caco.new(41,24,16,false))
table.insert(actors,zombie.new(44,24,24,false))
table.insert(actors,caco.new(50,24,16,false))
table.insert(actors,caco.new(61,24,16,false))
table.insert(actors,zombie.new(73,24,24,false))
table.insert(actors,zombie.new(54,24,24,false))
table.insert(actors,zombie.new(68,24,24,false))
table.insert(actors,caco.new(57,24,16,false))
table.insert(actors,zombie.new(46,24,24,false))
table.insert(actors,caco.new(37,24,16,false))
table.insert(actors,caco.new(26,24,16,false))
table.insert(actors,zombie.new(28,24,24,false))
table.insert(actors,caco.new(17,24,16,false))
-- TRIGGERS
if not menu then table.insert(actors,trigger.new(10,57,32,triggers.escena_abad_inici)) end
table.insert(actors,trigger.new(11,16,32,triggers.escena_abad_corfes))
table.insert(actors,trigger.new(31,12,32,triggers.escena_abad_portes))
table.insert(actors,trigger.new(31,48,32,triggers.escena_abad_portes))
table.insert(actors,trigger.new(71,56,24,triggers.escena_abad_portes))
table.insert(actors,trigger.new(53,40,32,triggers.escena_abad_porta_casa))
table.insert(actors,trigger.new(56,32,32,triggers.escena_abad_porta_batman))
table.insert(actors,trigger.new(19,32,32,triggers.escena_habitacio_batman))
table.insert(actors,trigger.new(14,40,32,triggers.teleport_a))
table.insert(actors,trigger.new(67,8,32,triggers.teleport_b))
table.insert(actors,trigger.new(29,40,32,triggers.teleport_c))
table.insert(actors,trigger.new(61,8,32,triggers.teleport_d))
score.create()
cameras[0]=gps
table.insert(cameras,gorro)
table.insert(cameras,peu)
table.insert(cameras,premiere)
table.insert(cameras,elalien)
table.insert(cameras,batman)
mapa_do_backup()
if menu then
abad.update = abad_nop
_update=update_menu
menu_count=0
menu_change_room=300
menu_room=rnd(60)
playmus(audio_main_song)
else
_update=update_game
stopmusic()
end
--fade.fadein()
end
function text(str,x,y,col)
color(16)
prnt(str,x-1,y-1)
prnt(str,x,y-1)
prnt(str,x+1,y-1)
prnt(str,x-1,y)
prnt(str,x+1,y)
prnt(str,x-1,y+1)
prnt(str,x,y+1)
prnt(str,x+1,y+1)
prnt(str,x,y,col)
end
function draw_hab(hab,x,y,editing)
camera(-x,-y)
mapa_draw(hab)
if not editing then
for key,actor in pairs(actors) do
if actor.hab==hab then
actor:draw()
end
end
if imp.hab==hab then imp.draw() end
if bambolla.hab==hab then bambolla.draw() end
if cacau.hab==hab then cacau:draw() end
if fireball.hab==hab then fireball:draw() end
end
camera(0,0)
end
function update_dialog()
rectfill(16,16,112,50,12)
rect(15,15,113,51,16)
text("Save the map?",20,20,2)
text("This cannot be undone",20,27,2)
text("(Y)es (N)o",25,40,2)
if btnp(KEY_N) then
_update=update_game
elseif btnp(KEY_Y) then
mapa_save()
_update=update_game
end
end
scroll=0
function update_game()
cls(16)
if mode==modes.editing then
draw_hab(abad.hab,0,0,true)
text(abad.hab,120,1,2)
sspr(0,64+scroll*8,128,48,0,48)
color(3)
local xx=(seltile&15)*8
local yy=48+(seltile>>4)*8
rect(xx,yy,xx+8,yy+8)
text("EDIT",100,1,3)
local hx = abad.hab%10
local hy = flr(abad.hab/10)
scroll=0
if btnp(KEY_RIGHT) and hx<9 then
abad.hab=abad.hab+1
elseif btnp(KEY_LEFT) and hx>0 then
abad.hab=abad.hab-1
elseif btnp(KEY_DOWN) and hy<7 then
abad.hab=abad.hab+10
elseif btnp(KEY_UP) and hy>0 then
abad.hab=abad.hab-10
elseif btnp(KEY_RETURN) then
mode=modes.playing
elseif btnp(KEY_S) and (btn(KEY_LCTRL) or btn(KEY_LGUI)) then
_update=update_dialog
elseif btnp(KEY_C) then
mapa_cycle_colors(abad.hab)
elseif btnp(KEY_M) then
mapa_create_minimap()
return
end
if btn(KEY_TAB) then
scroll=2
end
local mx,my=mousex(),mousey()
if mx>>3 < 12 and my>>3 < 6 then
text(mx>>3,100,10,2)
text(my>>3,111,10,2)
text((mx>>3)+(my>>3)*12,118,10,2)
end
if mbtn(1) then
if my>=48 then
seltile=(mx>>3)+((my-48+(scroll*8))>>3)*16
elseif mx<96 then
mapa_set_tile(abad.hab,mx>>3,my>>3,seltile)
end
elseif mbtn(3) then
if my<48 and mx<96 then
mapa_set_tile(abad.hab,mx>>3,my>>3,256)
end
end
if mx>>3 < 12 and my>>3 < 6 then
local tx,ty=(mx>>3)<<3,(my>>3)<<3
rect(tx,ty,tx+8,ty+8,3)
end
else
if abad.hurting == 0 then
draw_hab(abad.hab,0,0)
--text(abad.hab,1,1,2)
draw_hab(cameras[current_camera].hab,0,48)
text(camera_names[current_camera],2,49,8)
score.draw()
setsource(tiles)
prnt("x"..abad.vides,114,13,2)
rectfill(102+(abad.energia>>1),30,122,37,16)
else
sspr(0,0,16,9,50,40,16,9,true)
if abad.hurting > 40 then
prnt("x"..abad.vides+1,63,43,3)
elseif abad.hurting < 20 then
prnt("x"..abad.vides,63,43,2)
end
end
mapa_update(abad.hab,cameras[current_camera].hab)
for key,actor in pairs(actors) do
actor:update()
if actor.hab==cacau.hab and actor~=abad then
if aabb(actor,cacau) then
if actor.hit~=nil then
actor:hit()
cacau.hab=-1
end
end
end
end
imp.update()
bambolla.update()
cacau.update()
fireball.update()
switches.update()
--local hx = abad.hab%10
--local hy = flr(abad.hab/10)
--if btnp(KEY_RETURN) then
-- mode=modes.editing
-- mapa_restore_backup()
--elseif btn(KEY_LSHIFT) and btnp(KEY_RIGHT) and hx<9 then
-- abad.hab=abad.hab+1
--elseif btn(KEY_LSHIFT) and btnp(KEY_LEFT) and hx>0 then
-- abad.hab=abad.hab-1
--elseif btn(KEY_LSHIFT) and btnp(KEY_DOWN) and hy<7 then
-- abad.hab=abad.hab+10
--elseif btn(KEY_LSHIFT) and btnp(KEY_UP) and hy>0 then
-- abad.hab=abad.hab-10
--elseif btnp(KEY_M) then
-- mute = not mute
--elseif btnp(KEY_ESCAPE) then
-- pause()
--end
if btnp(KEY_ESCAPE) then
pause()
end
if abad.objects.gps~=nil then
if btnp(KEY_1) then
if abad.objects.gorro==nil and abad.objects.clau_premiere==nil then current_camera=1 end
elseif btnp(KEY_2) then
if abad.objects.peu==nil and abad.objects.clau_elalien==nil then current_camera=2 end
elseif btnp(KEY_3) then
current_camera=3
elseif btnp(KEY_4) then
current_camera=4
elseif btnp(KEY_5) then
current_camera=5
end
end
end
end
function update_menu()
menu_count=menu_count+1
menu_change_room=menu_change_room-1
if menu_change_room==0 then
menu_room = rnd(60)
menu_change_room=300
end
cls(16)
text("C A C A U S", 42, 12, 15)
if menu_count<20 then
text("Pulsa SPACE", 42, 28, 13)
else
text("Pulsa SPACE", 42, 28, 16)
if menu_count>40 then menu_count=0 end
end
draw_hab(menu_room,16,41)
rectfill(0,0,14,96,16)
rectfill(114,0,191,96,16)
rect(15,40,113,89,2)
mapa_update(abad.hab,menu_room)
for key,actor in pairs(actors) do
actor:update()
end
imp.update()
bambolla.update()
cacau.update()
fireball.update()
switches.update()
if btnp(KEY_SPACE) then
game_exit()
game_init()
fade.fadeoutin()
elseif btnp(KEY_M) then
mute = not mute
if mute then
stopmusic()
else
playmus(audio_main_song)
end
end
end
function game_exit()
mapa_restore_backup()
actors={}
cameras={}
end
function aabb(a, b)
return (a.x+a.bb.x+a.bb.w >= b.x+b.bb.x) and (a.x+a.bb.x <= b.x+b.bb.x+b.bb.w) and (a.y+a.bb.y+a.bb.h >= b.y+b.bb.y) and (a.y+a.bb.y <= b.y+b.bb.y+b.bb.h)
end
function pause()
setsource(0)
setdest(back)
sspr(0,0,128,96,0,0)
setdest(0)
setsource(tiles)
pause_old_update=_update
_update=update_pause
end
function update_pause()
rectfill(16,16,112,80,16)
rect(16,16,112,80,15)
prnt("PAUSA",54,30,15)
prnt("ESC torna al joc",30,50,14)
prnt("SPACE eixir",30,60,14)
if btnp(KEY_ESCAPE) then
setsource(back)
sspr(0,0,128,96,0,0)
setsource(tiles)
_update = pause_old_update
elseif btnp(KEY_SPACE) then
game_exit()
game_init(true)
end
end

29
data/gorro.lua Normal file
View File

@@ -0,0 +1,29 @@
gorro={hab=5,x=48,y=24,bb={x=0,y=0,w=8,h=8}}
function gorro.init()
local habs={{60,5},{4,5},{34,4},{62,7},{75,4}}
local r=1+rnd(#habs)
gorro.hab=habs[r][1]
gorro.x=habs[r][2]*8
gorro.update=gorro.update
gorro.draw=gorro.draw
end
function gorro.draw()
sspr(96,32,16,16,gorro.x,gorro.y,16,16)
end
function gorro.update()
if gorro.hab==abad.hab then
if aabb(abad,gorro) then
abad.objects.gorro=true
if premiere.scene_intro then
start_scene(scenes.gorro_trobat)
else
start_scene(scenes.gorro_trobat_nointro)
end
if abad.objects.gps~=nil then current_camera=3 end
remove_actor(gorro)
end
end
end

76
data/gota.lua Normal file
View File

@@ -0,0 +1,76 @@
gota={}
function gota.new(_hab,_x,_y,_freq)
return {hab=_hab,ix=_x,iy=_y,x=_x,y=_y,freq=_freq,cx=0,dx=0,dy=0,wait=0,step=0,hit=gota.hit,update=gota.update_normal, draw=gota.draw_normal,bb={x=2,y=0,w=4,h=6}}
end
function gota:draw_normal()
sspr(112,0,8,8,self.x,self.y)
end
function gota:update_normal()
self.wait=self.wait+1
if self.wait==6 then
self.wait=0
self.step=self.step+1
if self.step > self.freq then
self.y=self.y+4
if check_tile(self.hab,self.x+2,self.y+2)>=tiletype.block then
self.update=gota.update_splash
self.draw=gota.draw_splash
self.cx=self.x+2
self.dx=0
self.dy=-4
if self.hab==abad.hab then playsnd(audio_low) end
end
else
--self.flip=not self.flip
end
if self.hab==abad.hab then
if aabb(abad,self) then
abad_hurt(1)
self.update=gota.update_splash
self.draw=gota.draw_splash
self.cx=self.x+2
self.dx=0
self.dy=-4
end
end
end
end
function gota:hit()
end
function gota:draw_splash()
circfill(self.cx+self.dx,self.y,2,16)
circfill(self.cx+self.dx,self.y,1,11)
circfill(self.cx-self.dx,self.y,2,16)
circfill(self.cx-self.dx,self.y,1,11)
circfill(self.cx-(self.dx/2),self.y-4,2,16)
circfill(self.cx-(self.dx/2),self.y-4,1,11)
circfill(self.cx+(self.dx/2),self.y-4,2,16)
circfill(self.cx+(self.dx/2),self.y-4,1,11)
end
function gota:update_splash()
self.wait=self.wait+1
if self.wait==3 then
self.wait=0
self.dx=self.dx-2
self.x=self.cx+self.dx
self.y=self.y+self.dy
self.dy=self.dy+1
if self.y>48 then
self.step=0
self.update=gota.update_normal
self.draw=gota.draw_normal
self.x=self.ix
self.y=self.iy
end
end
end

31
data/gps.lua Normal file
View File

@@ -0,0 +1,31 @@
gps={hab=5,x=48,y=24,bb={x=0,y=0,w=8,h=8}}
function gps.init()
local habs={{33,8},{13,4},{51,9},{50,4},{42,7}}
local r=1+rnd(#habs)
gps.hab=habs[r][1]
gps.x=habs[r][2]*8
gps.update=gps.update
gps.draw=gps.draw
end
function gps.draw()
sspr(112,48,16,16,gps.x,gps.y,16,16)
end
function gps.update()
if gps.hab==abad.hab then
if aabb(abad,gps) then
abad.objects.gps=true
if abad.objects.gorro==nil then
current_camera=1
elseif abad.objects.peu==nil then
current_camera=2
else
current_camera=3
end
remove_actor(gps)
start_scene(scenes.gps_trobat)
end
end
end

94
data/imp.lua Normal file
View File

@@ -0,0 +1,94 @@
imp={hab=75,x=24,y=24,flip=true,enabled=false,counter=500,frame=28,wait=0,step=0,anim={28,29,28,30},bb={x=4,y=0,w=8,h=16},scene_intro=false,scene_object=false}
function imp.reset()
imp.hit=imp.hit
imp.update=imp.update
imp.draw=imp.draw
imp.hab=abad.hab
imp.enabled=false
imp.counter=500
end
function imp.init()
imp.enabled=false
imp.hit=imp.hit
imp.update=imp.update
imp.draw=imp.draw
imp.hab=abad.hab
if abad.x<40 then
if check_tile(imp.hab,92,38)<tiletype.half and
check_tile(imp.hab,84,38)<tiletype.half and
check_tile(imp.hab,92,30)<tiletype.half and
check_tile(imp.hab,84,30)<tiletype.half and
check_tile(imp.hab,92,46)>=tiletype.half then
imp.enabled=true
imp.flip=true
imp.x=92
else
imp.reset()
end
else
if check_tile(imp.hab,0,38)<tiletype.half and
check_tile(imp.hab,8,38)<tiletype.half and
check_tile(imp.hab,0,30)<tiletype.half and
check_tile(imp.hab,0,30)<tiletype.half and
check_tile(imp.hab,0,46)>=tiletype.half then
imp.enabled=true
imp.flip=false
imp.x=-12
else
imp.reset()
end
end
end
function imp.draw()
if imp.enabled then
sspr((imp.frame&7)*16,(imp.frame>>3)*16,16,16,imp.x,imp.y,16,16,imp.flip)
end
end
function imp.hit()
end
function imp.update()
imp.wait=imp.wait+1
if imp.wait==6 then
imp.wait=0
if not imp.enabled then
imp.counter=imp.counter-1
local r = rnd(imp.counter)
--print(r)
if imp.counter==1 or r==1 then
imp.init()
end
return
end
imp.step=(imp.step+1)%4
imp.frame=imp.anim[imp.step+1]
if imp.flip then
imp.x=imp.x-2
if imp.x==78 then
fireball.init(imp.hab,imp.x+8,imp.y+4,imp.flip)
playsnd(audio_hit)
imp.flip=not imp.flip
elseif imp.x==-12 then
imp.reset()
end
else
imp.x=imp.x+2
if imp.x==4 then
fireball.init(imp.hab,imp.x+8,imp.y+4,imp.flip)
playsnd(audio_hit)
imp.flip=not imp.flip
elseif imp.x==92 then
imp.reset()
end
end
end
end

101
data/intro.lua Normal file
View File

@@ -0,0 +1,101 @@
intro_wait=40
intro_step=0
function intro_init()
_update = intro_intro
intro_wait=400
cls(16)
setdest(logo)
cls(16)
prnt("JAILGAMES",0,0,15)
setdest(0)
setsource(logo)
sspr(0,0,36,5,28,35,72,10)
setsource(tiles)
fade.fadein()
end
function intro_intro()
--text("JAILGAMES",40,30,15)
text("presenta",48,50,14)
intro_wait=intro_wait-1
if intro_wait==0 or btnp(KEY_ESCAPE) or btnp(KEY_SPACE) then
intro_wait=1
_update = intro_update
fade.fadeoutin()
end
if btnp(KEY_M) then
mute = not mute
end
end
function intro_update()
if btnp(KEY_ESCAPE) then
game_init(true)
fade.fadeoutin()
elseif btnp(KEY_SPACE) then
intro_wait=1
elseif btnp(KEY_M) then
mute = not mute
end
intro_wait=intro_wait-1
if intro_wait==0 then
if intro_step==0 then
cls(16)
rect(15,3,113,53,2)
camera(-16,-4)
mapa_draw(10)
rectfill(73,24,79,39,16)
sspr(0,0,16,16,44,24,16,16,true)
camera(0,0)
intro_step=intro_step+1
elseif intro_step==1 then
start_scene(scenes.intro_01,58)
intro_step=intro_step+1
elseif intro_step==2 then
cls(16)
rect(15,3,113,53,2)
camera(-16,-4)
mapa_draw(10)
rectfill(73,24,79,39,16)
sspr(0,0,16,16,44,24,16,16,false)
camera(0,0)
intro_step=intro_step+1
elseif intro_step==3 then
start_scene(scenes.intro_02,58)
intro_step=intro_step+1
elseif intro_step==4 then
cls(16)
rect(15,3,113,53,2)
camera(-16,-4)
mapa_draw(10)
rectfill(73,24,79,39,16)
sspr(0,0,16,16,44,24,16,16,false)
sspr(112,88,16,8,76,32,16,8,true)
sspr(0,48,16,16,82,24,16,16,true)
camera(0,0)
intro_step=intro_step+1
elseif intro_step==5 then
start_scene(scenes.intro_03,58)
intro_step=intro_step+1
elseif intro_step==6 then
cls(16)
rect(15,3,113,53,2)
camera(-16,-4)
mapa_draw(10)
rectfill(73,24,79,39,16)
sspr(0,0,16,16,44,24,16,16,false)
camera(0,0)
intro_step=intro_step+1
elseif intro_step==7 then
start_scene(scenes.intro_04,58)
intro_step=intro_step+1
elseif intro_step==8 then
playmus(audio_main_song)
game_init(true)
fade.fadeoutin()
end
intro_wait=50
end
end

27
data/invisibl.lua Normal file
View File

@@ -0,0 +1,27 @@
invisible={}
function invisible.new(_hab,_x,_y)
return {hab=_hab,x=_x,y=_y,wait=0,hit=invisible.hit,update=invisible.update,draw=invisible.draw,bb={x=0,y=0,w=8,h=8}}
end
function invisible:draw()
-- Es invisible, res que drawar
end
function invisible:update()
self.wait=self.wait+1
if self.wait==6 then
self.wait=0
if self.hab==abad.hab then
if aabb(abad,self) then
abad_hurt(1)
end
end
end
end
function invisible:hit()
end

32
data/main.lua Normal file
View File

@@ -0,0 +1,32 @@
function _init()
tiles=loadsurf("tiles.gif")
setsource(tiles)
local pal=loadpal("tiles.gif")
setpal(pal)
logo=newsurf(36,5)
back=newsurf(128,96)
fade.init()
audio_text_abad = loadsound(audio_text_abad)
audio_text_premiere = loadsound(audio_text_premiere)
audio_text_elalien = loadsound(audio_text_elalien)
audio_text_batman = loadsound(audio_text_batman)
audio_abad_jump = loadsound(audio_abad_jump)
audio_abad_fall = loadsound(audio_abad_fall)
audio_abad_hit = loadsound(audio_abad_hit)
audio_abad_shot = loadsound(audio_abad_shot)
audio_abad_step[1] = loadsound(audio_abad_step[1])
audio_abad_step[2] = loadsound(audio_abad_step[2])
audio_abad_step[3] = loadsound(audio_abad_step[3])
audio_abad_step[4] = audio_abad_step[2]
audio_switch = loadsound(audio_switch)
audio_hit = loadsound(audio_hit)
audio_low = loadsound(audio_low)
--game_init()
intro_init()
--final_init()
end
function _update() end

802
data/map.lua Normal file
View File

@@ -0,0 +1,802 @@
mapa={
-- 1
{
256,256,256,18,19,21,20,21,20,21,20,21,
64,68,256,16,72,256,256,256,256,256,256,256,
256,256,66,256,88,256,256,70,71,256,256,256,
256,66,256,16,256,112,256,86,87,256,114,256,
66,256,256,16,256,256,256,256,256,256,256,256,
256,64,256,16,20,21,20,21,20,21,20,21,
},
-- 2
{
20,21,20,21,20,21,20,21,20,21,20,21,
256,256,256,256,256,256,256,256,256,256,256,256,
256,256,73,74,256,256,256,256,73,74,256,256,
256,256,89,90,256,256,256,256,89,90,256,256,
256,256,256,256,256,256,256,256,256,256,256,256,
20,21,20,21,20,21,21,256,80,17,20,21,
},
-- 3
{
20,21,20,21,20,21,20,21,20,21,20,21,
256,256,256,256,256,256,256,256,256,256,256,256,
256,96,97,96,256,73,74,256,97,96,96,256,
256,99,256,100,256,89,90,256,99,256,100,256,
256,256,256,256,256,256,256,256,256,256,256,256,
20,21,20,21,20,21,20,21,20,21,20,21,
},
-- 4
{
20,21,20,21,20,21,20,21,20,21,18,19,
256,256,256,256,256,256,256,256,256,256,77,17,
256,73,74,256,256,73,74,256,98,98,93,17,
256,89,90,256,256,89,90,256,99,100,256,256,
256,256,256,256,256,256,256,256,10,11,256,256,
20,21,20,21,20,21,20,21,10,11,20,21,
},
-- 5
{
66,256,256,67,256,65,256,64,256,256,256,66,
256,256,64,256,256,256,256,256,256,68,256,67,
18,19,18,19,18,19,18,19,256,256,65,256,
256,256,256,256,256,256,256,16,256,256,256,256,
256,256,256,256,256,256,256,16,256,64,256,66,
20,21,20,21,20,21,20,21,256,256,66,256,
},
-- 6
{
256,66,256,41,44,45,44,45,44,45,44,45,
64,256,256,41,256,256,256,256,256,256,256,256,
68,256,66,256,256,256,96,97,256,256,256,256,
256,67,256,41,256,256,99,100,256,256,256,256,
65,256,256,41,95,256,256,256,10,11,256,256,
256,65,42,43,44,45,44,45,10,11,44,45,
},
-- 7
{
42,43,256,256,256,256,65,256,256,256,256,64,
256,41,256,67,256,256,256,256,68,256,256,256,
256,41,256,256,256,66,256,256,256,256,256,256,
256,256,256,64,256,256,65,256,67,256,67,256,
256,256,256,256,256,256,256,256,256,256,256,256,
42,43,20,21,20,21,20,21,20,21,20,21,
},
-- 8
{
67,256,256,256,256,65,256,256,256,256,64,256,
256,256,67,256,256,256,256,68,256,256,256,256,
256,256,256,256,66,256,256,256,256,256,256,67,
256,256,64,256,256,65,256,67,256,67,256,256,
256,256,256,256,256,111,111,256,256,256,256,256,
20,21,20,21,17,256,256,17,20,21,20,21,
},
-- 9
{
256,256,256,256,65,256,256,256,256,64,17,17,
256,67,256,256,256,256,68,256,256,256,17,256,
256,256,256,66,256,256,256,256,256,256,17,256,
256,64,256,256,65,256,67,256,67,256,256,256,
256,256,256,256,256,256,256,256,256,256,256,256,
20,21,20,21,20,21,20,21,20,21,20,21,
},
-- 10
{
17,17,17,17,17,17,17,17,17,17,18,19,
256,256,256,256,256,256,256,256,256,256,17,17,
256,256,73,74,256,256,73,74,256,256,18,19,
256,256,89,90,256,256,89,90,256,256,17,17,
256,256,256,256,256,256,256,256,256,256,18,19,
20,21,256,80,17,18,19,17,18,19,17,17,
},
-- 11
{
256,66,26,27,28,29,28,29,26,27,28,29,
256,256,256,24,256,256,256,256,15,25,256,256,
64,68,256,256,256,256,256,256,256,25,256,256,
256,256,66,24,256,121,256,256,256,38,256,256,
256,66,256,24,101,102,103,256,256,38,256,256,
66,256,256,24,28,29,28,29,28,29,28,29,
},
-- 12
{
28,29,28,29,28,29,29,256,256,256,26,27,
256,256,256,256,256,256,256,256,256,25,72,256,
256,256,73,74,256,256,256,256,1,256,88,256,
256,256,89,90,256,256,256,1,256,256,256,256,
256,256,256,256,256,256,1,256,256,256,256,256,
28,29,28,29,28,29,28,29,28,29,28,29,
},
-- 13
{
28,29,26,27,26,27,28,29,28,29,28,29,
256,256,256,26,27,256,256,256,256,256,256,256,
256,256,256,256,256,256,256,256,73,74,256,256,
256,256,256,98,98,256,256,256,89,90,256,256,
256,256,104,101,102,103,256,256,256,256,256,256,
28,29,28,29,28,29,29,256,81,25,28,29,
},
-- 14
{
28,29,28,29,28,29,28,29,10,11,28,25,
256,256,256,256,256,256,256,256,10,11,256,25,
256,73,74,256,256,256,256,256,10,11,256,256,
256,89,90,256,256,75,76,256,10,11,256,25,
256,256,256,256,256,91,92,256,10,11,256,25,
28,29,28,29,28,29,28,29,28,29,28,29,
},
-- 15
{
26,27,26,27,28,29,28,29,26,27,26,27,
28,29,256,256,256,256,256,256,256,256,28,24,
256,256,256,256,256,73,74,256,256,256,256,24,
256,256,75,76,256,89,90,256,75,76,256,24,
256,256,91,92,256,256,256,256,91,92,256,24,
26,27,28,29,28,29,28,29,28,29,26,27,
},
-- 16
{
64,256,26,27,28,29,28,29,10,11,28,29,
68,256,66,25,256,256,256,256,10,11,256,256,
256,67,256,256,256,107,108,256,10,11,256,256,
65,256,256,25,256,109,110,256,10,11,256,256,
256,65,256,25,256,256,256,256,10,11,256,256,
256,256,26,27,28,29,28,29,10,11,28,29,
},
-- 17
{
28,29,28,29,25,41,44,45,44,45,44,45,
256,256,256,256,25,41,256,256,256,256,256,256,
256,73,74,256,25,41,256,256,73,74,256,256,
256,89,90,78,25,41,256,256,89,90,256,256,
256,256,95,94,25,41,256,256,10,11,256,256,
28,29,28,29,25,41,44,45,10,11,44,45,
},
-- 18
{
44,45,44,45,41,256,256,41,44,45,44,45,
256,256,256,256,256,69,256,256,256,256,256,256,
256,256,256,256,256,256,69,256,256,256,256,256,
256,256,256,256,256,111,111,256,256,256,256,256,
256,256,256,41,41,256,69,41,41,256,256,256,
45,44,45,42,43,256,256,42,43,44,45,44,
},
-- 19
{
44,45,44,45,42,43,42,43,44,45,44,45,
256,256,256,256,256,40,40,256,256,256,256,256,
256,97,98,97,256,40,40,256,98,97,96,256,
256,99,256,100,256,40,40,256,99,256,100,256,
256,256,256,256,256,40,40,256,256,256,256,256,
3,41,83,256,44,45,44,45,44,45,44,45,
},
-- 20
{
44,45,256,256,256,42,43,41,42,43,41,41,
256,256,256,256,41,41,256,256,256,77,42,43,
256,256,256,3,256,41,256,256,256,93,41,41,
256,256,3,256,256,39,256,256,256,256,42,43,
256,3,256,256,256,38,256,256,8,9,41,41,
44,45,44,45,44,45,44,45,8,9,42,43,
},
-- 21
{
34,35,36,37,36,37,36,37,36,37,36,37,
32,256,256,256,256,256,256,256,256,256,256,256,
32,256,97,97,98,256,256,256,97,96,97,256,
32,256,99,256,100,256,256,256,99,256,100,256,
32,256,8,9,256,104,101,102,103,256,256,256,
34,35,8,9,36,37,36,37,36,37,36,37,
},
-- 22
{
36,37,33,33,36,37,36,37,33,33,36,37,
256,256,256,256,256,256,256,256,256,256,256,256,
256,256,256,256,96,97,96,98,256,256,256,256,
256,256,113,256,99,256,256,100,256,114,256,256,
256,256,256,256,256,256,256,256,256,256,256,256,
36,37,36,37,36,37,36,37,36,37,36,37,
},
-- 23
{
37,36,37,36,37,36,37,256,256,256,36,37,
256,256,256,256,256,256,256,256,256,33,256,256,
256,97,98,97,256,256,112,256,2,256,256,256,
256,99,256,100,256,256,256,2,256,75,76,256,
256,256,256,256,256,256,2,256,256,91,92,256,
36,37,36,37,36,37,36,37,36,37,36,37,
},
-- 24
{
34,35,256,256,256,256,256,256,256,256,34,35,
256,2,34,35,34,35,34,35,34,35,2,256,
256,256,113,256,256,112,114,256,256,114,256,256,
256,256,256,256,256,256,256,256,256,256,256,256,
256,104,101,102,256,101,102,256,101,102,103,256,
36,37,36,37,36,37,36,37,36,37,36,37,
},
-- 25
{
36,37,36,37,36,37,36,37,36,37,34,35,
256,256,256,256,256,256,73,74,256,256,77,32,
256,96,97,96,256,256,89,90,256,256,93,32,
256,99,256,100,256,121,256,256,256,256,256,32,
256,256,256,256,256,101,102,103,8,9,256,32,
36,37,36,37,36,37,36,37,8,9,33,32,
},
-- 26
{
18,19,17,17,18,19,17,17,10,11,18,19,
17,256,256,256,256,256,256,256,10,11,256,256,
18,19,256,256,256,256,256,256,10,11,256,256,
256,17,256,256,256,75,76,256,10,11,256,256,
18,19,256,256,256,91,92,256,10,11,256,256,
20,21,256,256,18,19,17,17,18,19,17,17,
},
-- 27
{
17,17,18,19,17,17,18,19,10,11,18,19,
256,256,256,256,256,256,256,256,10,11,256,256,
256,73,74,256,256,73,74,256,10,11,256,256,
256,89,90,256,256,89,90,256,10,11,256,256,
256,256,256,256,256,256,256,256,10,11,256,256,
17,17,18,19,17,256,80,17,18,19,17,17,
},
-- 28
{
18,19,17,18,19,256,256,33,33,34,35,33,
256,256,256,17,17,256,69,34,35,72,256,256,
256,256,256,18,19,256,69,33,33,88,256,256,
256,256,256,17,16,256,256,34,35,256,256,256,
256,256,256,18,19,69,256,41,33,256,256,256,
17,18,19,17,17,69,256,34,35,33,33,34,
},
-- 29
{
33,256,256,256,33,33,34,35,33,33,34,35,
256,33,256,256,256,256,256,256,256,256,256,256,
256,256,2,256,256,256,256,256,256,256,256,256,
256,256,256,2,256,256,256,117,98,106,116,256,
256,256,256,256,2,256,104,101,102,101,102,256,
34,35,33,33,34,35,33,33,34,35,33,33,
},
-- 30
{
33,33,34,35,33,33,34,35,8,9,33,33,
256,256,256,256,256,256,33,33,8,9,34,35,
256,256,256,256,256,97,34,35,8,9,33,33,
256,256,256,256,115,100,33,33,8,9,34,35,
256,256,256,104,101,102,34,35,8,9,33,33,
34,35,33,33,34,35,33,33,8,9,34,35,
},
-- 31
{
40,40,8,9,40,40,40,40,40,40,40,40,
40,45,8,9,45,44,45,44,45,44,45,44,
40,256,8,9,256,256,256,256,256,256,256,256,
40,256,8,9,256,256,112,75,76,113,256,256,
40,256,8,9,256,256,256,91,92,256,256,256,
42,43,44,45,44,45,44,45,44,45,44,45,
},
-- 32
{
40,40,40,40,40,40,40,40,40,40,40,40,
44,45,41,45,44,41,44,45,44,45,44,45,
256,256,38,256,256,38,256,256,256,256,256,256,
256,112,38,256,113,38,256,256,114,256,256,113,
256,256,38,256,256,38,256,256,256,256,256,256,
44,45,41,83,256,44,45,44,45,44,45,44,
},
-- 33
{
40,40,40,40,40,40,40,40,40,40,40,40,
43,44,45,44,45,42,43,44,45,44,45,42,
256,256,256,256,256,256,256,256,256,256,256,256,
256,256,75,76,256,114,113,256,75,76,256,256,
256,256,91,92,256,256,256,256,91,92,256,256,
44,45,44,45,44,45,44,45,44,45,44,45,
},
-- 34
{
40,40,40,40,40,40,40,40,40,40,40,40,
45,44,45,44,45,44,45,44,45,44,45,40,
256,256,256,256,256,256,256,256,73,74,256,40,
256,256,113,256,256,114,256,121,89,90,256,40,
256,256,256,256,256,256,256,101,102,103,256,40,
44,45,41,83,256,44,45,44,45,44,45,40,
},
-- 35
{
26,27,28,29,28,29,28,29,8,9,26,27,
24,15,256,256,256,256,256,256,8,9,256,24,
24,256,256,256,256,256,256,256,8,9,256,24,
24,256,256,256,256,256,256,256,8,9,256,24,
24,256,256,256,256,256,256,256,8,9,256,24,
26,27,28,29,28,29,28,29,8,9,26,27,
},
-- 36
{
24,29,256,256,1,25,26,27,25,1,28,29,
24,256,256,256,256,256,25,26,27,256,256,256,
24,256,256,256,256,256,256,256,25,256,256,256,
24,256,106,116,256,256,256,256,38,256,256,256,
24,25,101,102,256,256,256,256,38,256,256,256,
28,29,28,29,25,81,256,28,29,28,29,28,
},
-- 37
{
29,26,27,28,29,256,256,256,26,27,26,27,
256,256,256,256,256,256,256,25,256,256,28,29,
256,256,256,256,256,256,1,256,256,256,256,256,
256,112,256,256,256,1,256,256,256,256,113,256,
256,256,256,256,1,256,101,102,103,256,256,256,
28,29,28,29,28,29,28,29,28,29,28,29,
},
-- 38
{
27,26,27,28,29,256,256,28,29,26,27,26,
29,256,256,256,256,256,69,256,256,256,256,28,
256,256,98,96,98,256,256,98,98,96,256,256,
256,256,99,256,100,256,256,99,256,100,256,256,
256,256,256,256,256,111,111,256,256,256,256,256,
29,28,29,28,29,69,256,28,29,28,29,28,
},
-- 39
{
28,29,25,25,28,29,25,25,28,29,25,25,
256,256,25,25,256,256,256,256,256,256,106,24,
256,256,15,256,256,256,256,256,256,256,95,24,
256,256,256,256,78,97,107,108,256,106,105,24,
256,256,256,256,94,101,102,110,103,105,98,24,
28,29,28,29,28,29,28,29,28,29,28,29,
},
-- 40
{
24,29,28,29,28,29,28,29,8,9,26,27,
24,256,256,256,256,256,256,256,8,9,25,25,
24,256,114,256,256,256,112,256,8,9,26,27,
24,256,256,256,256,256,256,256,8,9,25,25,
24,256,256,256,105,256,256,256,8,9,26,27,
24,29,28,29,28,29,28,29,28,29,25,25,
},
-- 41
{
26,27,28,29,28,29,26,27,26,27,28,29,
24,72,256,256,256,256,256,28,29,256,256,256,
24,88,256,256,256,256,256,256,256,256,256,256,
24,256,256,256,112,256,256,256,256,256,114,256,
24,256,256,256,256,256,256,256,256,256,256,256,
28,29,28,29,28,29,25,81,256,28,29,29,
},
-- 42
{
28,29,256,256,256,1,26,27,26,27,28,29,
256,256,25,256,256,256,256,28,29,256,256,256,
256,256,256,1,256,256,256,256,256,256,256,256,
256,113,256,256,1,256,256,96,97,96,98,256,
256,256,256,256,256,1,256,101,256,256,102,256,
28,29,28,29,28,29,28,29,28,29,28,29,
},
-- 43
{
28,29,28,29,26,27,26,27,28,29,26,27,
256,256,256,256,256,28,29,256,256,256,77,24,
256,256,256,256,256,256,256,256,256,256,93,24,
256,113,256,256,256,75,76,256,114,256,256,24,
256,256,10,11,256,91,92,256,256,256,256,24,
28,29,10,11,28,29,28,29,28,29,28,29,
},
-- 44
{
33,37,256,256,256,36,37,36,37,36,37,2,
32,256,33,256,256,256,256,256,256,256,256,256,
32,98,256,2,256,256,256,256,256,256,256,256,
32,99,256,256,2,256,256,256,75,76,256,256,
32,256,256,256,256,2,256,256,91,92,256,256,
36,37,36,37,36,37,36,37,36,37,36,37,
},
-- 45
{
36,37,36,37,36,37,36,37,8,9,34,35,
256,256,256,256,256,256,256,256,8,9,256,32,
256,256,98,97,96,256,256,256,8,9,256,32,
256,256,99,256,100,256,256,256,8,9,256,32,
256,256,256,256,101,102,103,256,8,9,256,32,
36,37,36,37,36,37,36,37,36,37,36,37,
},
-- 46
{
18,19,18,19,256,256,256,20,21,20,21,20,
18,19,72,256,17,256,256,256,256,256,256,256,
18,19,88,256,256,0,256,256,256,256,256,256,
18,19,256,75,76,78,0,256,256,116,256,256,
18,19,256,91,92,94,95,0,256,101,102,256,
18,19,18,19,18,19,18,19,18,19,18,19,
},
-- 47
{
20,21,20,21,20,21,20,21,20,21,20,21,
256,256,256,256,256,256,256,256,256,256,256,256,
256,97,96,98,97,256,256,96,97,98,96,256,
114,99,256,256,100,114,114,99,256,256,100,114,
256,256,256,256,256,256,256,256,256,256,256,256,
18,19,18,19,18,19,18,19,18,19,18,19,
},
-- 48
{
20,21,20,21,17,256,256,17,20,21,20,21,
256,256,256,256,256,256,69,256,256,256,256,256,
256,256,96,97,256,256,69,256,256,256,256,256,
256,115,99,100,256,256,256,256,256,117,256,256,
256,101,102,103,256,111,111,256,101,102,103,256,
19,18,19,18,19,69,256,18,19,18,19,18,
},
-- 49
{
20,21,256,69,18,19,18,19,20,21,20,21,
256,256,256,256,256,256,256,256,256,256,114,256,
256,256,69,256,256,256,114,256,256,256,256,256,
256,114,69,111,256,256,256,256,17,18,19,17,
256,256,111,256,18,19,18,19,18,19,18,19,
18,19,256,69,17,18,19,18,19,18,19,17,
},
-- 50
{
20,21,20,21,20,21,20,21,20,21,20,16,
256,114,256,256,256,256,256,256,256,256,98,16,
256,256,256,256,256,256,256,256,256,256,100,16,
17,19,256,256,256,114,256,256,256,256,78,16,
18,19,18,19,256,256,256,256,256,256,94,16,
17,18,19,18,19,18,19,256,80,17,18,19,
},
-- 51
{
42,43,44,45,44,45,256,256,256,44,45,45,
40,72,256,256,256,256,41,256,256,256,256,256,
40,96,256,256,256,256,256,3,256,256,256,256,
40,99,256,114,256,114,256,256,3,256,256,256,
40,256,256,256,256,256,256,256,256,3,256,256,
44,45,44,45,44,45,44,45,44,45,44,45,
},
-- 52
{
44,45,44,45,44,45,44,45,44,45,44,41,
256,256,256,256,256,256,256,256,256,256,256,40,
256,256,73,74,256,256,256,70,71,256,97,40,
256,256,89,90,256,256,256,86,87,256,100,40,
256,256,256,256,256,256,256,256,256,256,256,40,
44,45,41,83,256,44,44,45,44,45,44,45,
},
-- 53
{
18,19,10,11,18,19,17,17,20,21,20,21,
16,15,10,11,256,256,256,256,256,256,256,256,
16,256,10,11,256,256,75,76,256,256,256,256,
16,256,10,11,256,256,91,92,256,256,256,256,
16,256,10,11,256,256,18,19,256,256,256,256,
20,21,20,21,20,21,20,21,20,21,20,21,
},
-- 54
{
20,21,20,21,21,17,18,19,67,256,256,256,
256,256,256,256,256,17,18,19,256,65,68,64,
256,256,256,256,256,256,18,19,256,256,256,256,
256,256,256,256,256,256,38,256,67,256,64,256,
256,256,256,256,256,256,38,256,256,256,256,256,
20,21,20,21,20,21,20,21,54,55,54,56,
},
-- 55
{
256,65,256,256,256,67,256,67,256,256,256,256,
256,256,256,64,256,256,256,256,65,68,64,256,
256,256,256,256,256,256,64,256,256,256,256,67,
256,256,65,67,256,256,64,256,256,64,256,256,
256,256,256,256,256,256,256,256,256,256,256,256,
54,55,54,56,56,55,54,56,54,56,55,54,
},
-- 56
{
65,256,256,256,67,256,67,256,256,256,256,64,
256,256,64,256,256,256,256,65,68,64,256,256,
256,256,256,256,256,64,256,256,256,256,67,256,
256,65,67,256,256,64,256,256,64,256,256,256,
256,256,256,256,256,256,256,256,256,256,256,256,
55,54,55,54,56,54,55,56,54,55,54,56,
},
-- 57
{
256,256,256,67,34,35,34,35,34,35,34,35,
256,64,256,256,34,35,72,256,256,256,256,256,
256,256,256,256,34,35,88,256,256,256,256,256,
65,67,256,256,256,38,256,256,75,76,256,256,
256,256,256,256,256,38,256,256,91,92,256,256,
54,55,56,54,36,37,36,37,36,37,36,37,
},
-- 58
{
35,34,35,34,35,69,256,34,35,34,35,34,
256,256,256,256,256,69,256,256,256,256,256,256,
256,113,70,71,114,256,256,112,107,108,113,256,
256,256,86,87,256,256,69,256,109,110,256,256,
256,256,256,256,256,111,111,256,256,256,256,256,
37,36,37,36,37,256,256,36,37,36,37,36,
},
-- 59
{
34,35,256,256,34,35,34,35,34,35,34,35,
256,256,256,69,256,256,256,256,256,256,256,256,
256,256,69,256,256,256,97,96,256,256,256,256,
256,256,111,111,256,256,99,100,256,256,256,256,
256,41,120,119,41,256,256,256,8,9,256,256,
3,41,46,47,41,3,36,37,8,9,36,37,
},
-- 60
{
35,34,35,34,35,34,35,256,256,33,34,35,
256,256,36,37,256,256,256,256,256,33,34,35,
256,256,256,256,256,256,256,256,2,77,34,35,
256,256,116,256,256,256,256,2,256,93,34,35,
256,256,101,102,103,256,2,256,256,256,34,35,
36,37,36,37,36,37,36,37,36,37,36,37,
},
-- 61
{
18,19,21,20,21,20,21,20,21,17,18,19,
16,15,256,256,256,256,256,256,256,77,18,19,
16,256,256,256,256,256,256,256,256,93,18,19,
16,256,256,256,256,256,256,116,256,78,18,19,
16,256,10,11,256,256,101,102,256,94,18,19,
20,21,10,11,20,21,20,21,20,21,20,21,
},
-- 62
{
18,19,256,256,256,20,20,21,20,21,20,21,
16,72,17,256,256,256,256,256,256,256,256,256,
16,88,256,0,256,256,256,256,256,256,256,256,
16,256,256,78,0,256,256,114,75,76,256,256,
16,95,256,94,256,0,256,256,91,92,256,256,
20,21,20,21,20,21,20,21,20,21,20,21,
},
-- 63
{
20,21,20,21,20,21,20,21,20,21,20,17,
256,256,256,256,256,256,256,256,256,256,256,16,
256,256,256,256,256,256,256,256,256,256,98,16,
256,256,256,256,256,256,117,97,96,256,100,16,
256,256,256,256,256,256,101,256,102,103,256,16,
20,21,17,80,256,20,20,21,20,21,20,21,
},
-- 64
{
41,48,49,48,50,49,48,49,48,50,49,48,
41,256,256,256,256,256,256,256,256,256,256,256,
41,256,256,256,256,256,256,256,256,256,256,256,
41,256,256,256,113,256,256,114,256,256,112,256,
41,256,8,9,256,256,256,256,256,256,256,256,
42,43,8,9,42,43,42,43,42,43,42,43,
},
-- 65
{
48,50,48,49,50,49,50,48,50,49,50,48,
256,256,256,256,256,256,256,256,256,256,112,256,
256,256,256,256,256,256,113,256,256,256,256,256,
256,256,114,256,256,256,256,256,42,43,42,43,
256,256,256,256,42,43,42,43,256,256,256,256,
42,43,42,43,256,256,256,256,256,256,256,256,
},
-- 66
{
48,49,48,48,50,49,48,50,49,48,48,50,
256,113,256,256,114,256,256,256,256,256,256,256,
256,256,256,256,256,256,256,256,256,256,256,256,
42,43,42,43,42,43,256,256,256,112,256,256,
256,256,256,256,42,43,3,256,256,256,256,256,
256,256,256,256,42,43,42,43,42,43,42,43,
},
-- 67
{
50,48,50,49,50,48,50,49,41,42,43,48,
256,256,256,256,256,256,256,256,77,42,43,256,
256,256,256,256,256,256,256,256,93,42,43,256,
256,256,114,256,256,113,256,256,256,42,43,256,
256,256,256,256,256,256,256,256,256,42,43,256,
42,43,41,41,42,43,41,83,256,42,43,50,
},
-- 68
{
25,28,29,26,27,256,69,26,27,28,29,28,
24,97,256,256,256,256,256,256,256,256,256,256,
24,99,256,256,256,69,256,256,256,256,256,256,
24,256,95,256,113,69,256,256,114,75,76,256,
24,101,102,103,256,111,111,256,256,91,92,256,
28,28,29,28,29,256,69,28,29,28,29,28,
},
-- 69
{
28,29,26,27,26,27,28,29,8,9,28,29,
256,256,256,28,29,256,256,256,8,9,256,256,
256,256,256,256,256,256,256,256,8,9,256,256,
75,76,75,76,75,76,75,76,8,9,256,256,
91,92,91,92,91,92,91,92,8,9,256,256,
28,29,1,26,27,1,28,29,8,9,28,29,
},
-- 70
{
28,29,26,27,25,25,256,256,65,256,256,256,
256,256,256,77,26,27,256,256,256,68,256,256,
256,256,256,93,25,25,256,256,256,256,66,256,
256,256,256,78,26,27,256,66,256,256,256,67,
256,256,95,94,25,25,256,256,256,256,256,256,
28,29,28,29,26,27,54,56,54,56,55,54,
},
-- 71
{
46,47,10,11,46,47,46,47,46,47,46,47,
47,256,10,11,256,256,256,256,256,256,256,256,
47,98,10,11,256,256,256,256,256,256,256,256,
47,99,10,11,256,256,115,105,256,256,256,256,
47,256,10,11,256,256,101,102,103,256,256,256,
46,47,46,47,46,47,46,47,46,47,46,47,
},
-- 72
{
46,47,46,47,46,47,46,47,46,47,46,47,
256,256,256,256,256,256,26,27,26,27,28,29,
256,256,256,256,256,256,38,256,256,256,256,256,
256,256,256,116,256,256,38,256,256,256,256,256,
256,256,101,102,256,256,26,27,26,27,256,256,
46,47,46,47,46,47,46,47,46,47,28,29,
},
-- 73
{
46,47,256,256,256,25,26,27,26,27,26,27,
28,29,25,256,256,256,256,256,256,28,29,25,
256,256,256,1,256,256,256,116,96,96,256,256,
256,256,256,256,1,256,256,99,256,100,256,256,
256,25,256,256,256,1,256,256,256,256,256,256,
28,29,28,29,26,27,26,27,26,27,26,27,
},
-- 74
{
26,27,8,9,26,27,26,27,26,27,26,27,
25,256,8,9,1,25,28,29,28,29,25,1,
256,256,8,9,256,256,256,256,256,256,256,256,
256,256,8,9,256,256,256,116,106,256,256,256,
256,256,8,9,256,256,104,101,102,103,256,256,
26,27,26,27,26,27,26,27,26,27,26,27,
},
-- 75
{
26,27,26,27,26,27,26,27,26,27,26,27,
256,256,28,29,25,28,29,25,28,29,256,256,
256,256,256,256,256,256,256,256,256,256,256,256,
256,114,256,256,256,113,256,256,256,256,114,256,
256,256,256,256,256,256,256,256,256,256,256,256,
26,27,28,29,28,29,28,29,28,29,26,27,
},
-- 76
{
26,27,26,27,26,27,26,27,18,19,20,21,
256,256,256,256,256,256,15,25,17,15,256,256,
256,256,256,256,256,256,256,25,17,256,256,256,
256,256,256,114,256,256,78,25,17,256,256,256,
256,256,256,256,256,95,94,25,17,256,256,256,
26,27,26,27,26,27,26,27,51,53,52,51,
},
-- 77
{
18,19,18,19,18,19,256,256,256,18,19,52,
256,256,17,72,256,256,17,256,256,256,256,256,
256,256,38,88,256,113,256,0,256,256,256,256,
256,256,38,256,256,256,256,256,0,256,256,256,
256,256,38,256,256,256,256,256,256,0,256,256,
52,51,52,53,52,53,51,52,51,53,52,53,
},
-- 78
{
51,52,53,51,52,256,256,52,53,51,52,17,
256,256,256,256,256,256,69,256,256,256,256,17,
256,256,256,256,256,69,256,256,256,256,256,17,
256,256,256,256,256,111,111,106,256,256,78,17,
256,256,256,256,17,118,119,17,256,95,94,17,
51,52,53,53,51,53,52,53,51,52,51,17,
},
-- 79
{
256,256,256,256,42,43,42,43,8,9,42,43,
256,256,256,256,42,43,72,256,8,9,256,256,
256,126,127,256,42,43,88,256,8,9,256,256,
256,256,256,256,42,43,256,256,8,9,256,256,
256,256,256,256,42,43,256,256,8,9,256,256,
256,256,256,256,42,43,42,43,42,43,42,43,
},
-- 80
{
42,43,42,43,42,43,42,43,256,256,256,256,
256,256,256,256,256,15,42,43,256,256,256,256,
256,256,256,256,256,256,42,43,256,126,127,256,
256,256,256,256,256,256,42,43,256,256,256,256,
256,256,256,256,256,256,42,43,256,256,256,256,
42,43,42,43,42,43,42,43,256,256,256,256,
},
}

174
data/mapa.lua Normal file
View File

@@ -0,0 +1,174 @@
--mapa={}
tiletype={void=0,nonpc=1,stair=2,switch=3,half=4,block=5}
mapa.wait=0
mapa.step=0
function mapa_do_backup()
mapa_backup={}
for i=1,#mapa do
mapa_backup[i]={}
for j=1,#mapa[i] do
mapa_backup[i][j]=mapa[i][j]
end
end
end
function mapa_restore_backup()
for i=1,#mapa do
for j=1,#mapa[i] do
mapa[i][j]=mapa_backup[i][j]
end
end
end
function mapa_new()
for my=0,7 do
for mx=0,9 do
local mi=1+mx+my*10
mapa[mi]={}
for ty=0,5 do
for tx=0,11 do
local tile=256
if mx==0 and tx==0 then
tile=16
elseif mx==4 and tx==11 then
tile=16
elseif ty==0 or ty==5 then
if tx%2==0 then
tile=20
else
tile=21
end
end
mapa[mi][1+tx+ty*12]=tile
end
end
end
end
end
function mapa_save()
file = io.open("data/map.lua", "w")
io.output(file)
io.write("mapa={\n")
for i=1,80 do
io.write(" -- "..i.."\n {\n ")
for j=1,72 do
io.write(mapa[i][j]..",")
if j%12==0 then io.write("\n ") end
end
io.write("\n },\n")
end
io.write("}\n")
io.close(file)
end
anim_tiles={113,114,112,116,117,115,119,120,118,122,121}
function mapa_update(hab1,hab2)
mapa.wait=mapa.wait+1
if mapa.wait==6 then
mapa.wait=0
mapa.step=(mapa.step+1)&31
local hab=hab1
repeat
for ty=0,5 do
for tx=0,11 do
local tile=mapa[1+hab][1+tx+ty*12]
if tile>=112 and tile<126 then
mapa[1+hab][1+tx+ty*12]=anim_tiles[tile-111]
end
end
end
if hab==hab2 then break end
hab=hab2
until false
end
end
function mapa_draw(hab)
for ty=0,5 do
for tx=0,11 do
local tile=mapa[1+hab][1+tx+ty*12]
if tile~=256 and (tile<126 or mapa.step>4) then
sspr((tile&15)*8,64+(tile>>4)*8,8,8,tx*8,ty*8)
end
end
end
end
function mapa_set_tile(hab,x,y,tile)
mapa[1+hab][1+x+y*12]=tile
end
function mapa_set_tile_by_index(hab,index,tile)
mapa[1+hab][index]=tile
end
function mapa_get_tile(hab,x,y)
return mapa[1+hab][1+x+y*12]
end
function mapa_cycle_colors(hab)
for i=1,72 do
local tile=mapa[1+hab][i]
if tile<4 then
tile=(tile+1)&3
elseif tile>=16 and tile<48 then
tile=tile+8
if tile>=48 then tile=tile-32 end
end
mapa[1+hab][i]=tile
end
end
function check_tile(hab,x,y)
local xx=min(11,max(0,flr(x/8)))
local yy=min(5,max(0,flr(y/8)))
--rect(xx*8,yy*8,xx*8+8,yy*8+8,3)
local tile=mapa_get_tile(hab,xx,yy)
if tile<8 then
return tiletype.half
elseif tile<15 then
return tiletype.stair
elseif tile==15 then
return tiletype.switch
elseif tile<64 then
return tiletype.block
elseif tile==111 then
return tiletype.nonpc
else
return tiletype.void
end
end
pix={14,10,7,1,0,0,0,0,4,4,4,4,0,0,0,8,14,14,14,14,14,14,0,0,10,10,10,10,10,10,10,10,7,7,7,7,7,7,2,2,1,1,1,1,1,1,12,12,1,1,1,9,9,9,10,10,10,0,0,0,0,0,0,0}
function mapa_create_minimap()
minimap = newsurf(128,96)
setdest(minimap)
for h=0,79 do
for y=0,5 do
for x=0,11 do
local tile=mapa[h+1][1+x+y*12]
if h==45 then
print(x..","..y.."="..tile)
end
if tile<64 then
pset(x+(h%10)*12,y+flr(h/10)*6,pix[1+tile])
end
end
end
end
_update=mapa_draw_minimap
end
function mapa_draw_minimap()
--print("HOLA")
setsource(minimap)
setdest(0)
cls(16)
sspr(0,0,128,96,0,0)
end

BIN
data/mus_alie.ogg Normal file

Binary file not shown.

BIN
data/mus_batm.ogg Normal file

Binary file not shown.

BIN
data/mus_life.ogg Normal file

Binary file not shown.

BIN
data/mus_menu.ogg Normal file

Binary file not shown.

BIN
data/mus_over.ogg Normal file

Binary file not shown.

BIN
data/mus_prem.ogg Normal file

Binary file not shown.

29
data/peu.lua Normal file
View File

@@ -0,0 +1,29 @@
peu={hab=5,x=48,y=24,bb={x=0,y=0,w=8,h=8}}
function peu.init()
local habs={{18,8},{16,2},{16,7},{15,5},{27,1},{27,10},{29,2},{38,8},{69,2},{79,3}}
local r=1+rnd(#habs)
peu.hab=habs[r][1]
peu.x=habs[r][2]*8
peu.update=peu.update
peu.draw=peu.draw
end
function peu.draw()
sspr(112,32,16,16,peu.x,peu.y,16,16)
end
function peu.update()
if peu.hab==abad.hab then
if aabb(abad,peu) then
abad.objects.peu=true
if elalien.scene_intro then
start_scene(scenes.peu_trobat)
else
start_scene(scenes.peu_trobat_nointro)
end
if abad.objects.gps~=nil then current_camera=4 end
remove_actor(peu)
end
end
end

162
data/premiere.lua Normal file
View File

@@ -0,0 +1,162 @@
premiere={hab=75,x=24,y=24,flip=true,frame=12,wait=0,step=0,anim={12,13,12,14},bb={x=4,y=0,w=8,h=16},scene_intro=false,scene_object=false}
function premiere.init()
premiere.x=24
premiere.y=24
premiere.frame=12
premiere.wait=0
premiere.step=0
premiere.update=premiere.update_normal
premiere.scene_intro=false
premiere.scene_object=false
local habs={75,44,20,0}
premiere.hab=habs[1+rnd(4)]
end
function premiere.draw()
sspr((premiere.frame&7)*16,(premiere.frame>>3)*16,16,16,premiere.x,premiere.y,16,16,premiere.flip)
end
function premiere.hit()
end
function premiere.update_normal()
premiere.wait=premiere.wait+1
if premiere.wait==6 then
premiere.wait=0
premiere.step=(premiere.step+1)%4
premiere.frame=premiere.anim[premiere.step+1]
local inc=12 if premiere.flip then inc=2 end
if not premiere.flip and premiere.x==84 then
premiere.hab=premiere.hab+1
premiere.x=-4
elseif check_tile(premiere.hab,premiere.x+inc,premiere.y+14)<tiletype.half then
if premiere.flip then
premiere.x=premiere.x-2
else
premiere.x=premiere.x+2
end
if premiere.x<-4 then
premiere.hab=premiere.hab-1
premiere.x=84
end
elseif check_tile(premiere.hab,premiere.x+inc,premiere.y+6)<tiletype.half then
premiere.update=premiere.update_jumping
premiere.step=0
else
--if check_tile(premiere.hab,premiere.x+4,premiere.y+16)==tiletype.void and ((premiere.x+4)&7==0 or check_tile(premiere.hab,premiere.x+12,premiere.y+16)==tiletype.void) then
--premiere.update=premiere.update_falling
--else
premiere.flip=not premiere.flip
--end
end
if check_tile(premiere.hab,premiere.x+4,premiere.y+16)==tiletype.void and ((premiere.x+4)&7==0 or check_tile(premiere.hab,premiere.x+12,premiere.y+16)==tiletype.void) then
premiere.update=premiere.update_falling
end
if premiere.hab==abad.hab then
if aabb(abad,premiere) then
if not premiere.scene_intro then
if abad.objects.gorro~=nil then
start_scene(scenes.premiere_intro_gorro)
premiere.scene_object=true
abad.objects.clau_premiere=true
abad.objects.gorro=nil
else
start_scene(scenes.premiere_intro)
end
premiere.scene_intro=true
elseif not premiere.scene_object and abad.objects.gorro~=nil then
start_scene(scenes.premiere_gorro)
premiere.scene_object=true
abad.objects.clau_premiere=true
abad.objects.gorro=nil
end
end
end
end
end
function premiere.update_jumping()
premiere.frame=13
premiere.wait=premiere.wait+1
if premiere.wait==6 then
premiere.wait=0
local inc=12 if premiere.flip then inc=2 end
if not premiere.flip and premiere.x==84 then
premiere.hab=premiere.hab+1
premiere.x=-4
elseif check_tile(premiere.hab,premiere.x+inc,premiere.y+14)<tiletype.half and check_tile(premiere.hab,premiere.x+inc,premiere.y+16)~=tiletype.void then
if premiere.flip then
premiere.x=premiere.x-2
else
premiere.x=premiere.x+2
end
if premiere.x<-4 then
premiere.hab=premiere.hab-1
premiere.x=84
end
end
if premiere.step<6 then
if premiere.y>0 then
if check_tile(premiere.hab,premiere.x+4,premiere.y-2)~=tiletype.block then
if (premiere.x+4)&7==0 or check_tile(premiere.hab,premiere.x+12,premiere.y-2)~=tiletype.block then
premiere.y=premiere.y-2
end
end
else
premiere.hab=premiere.hab-10
premiere.y=32
end
elseif premiere.step>6 then
premiere.update=premiere.update_falling
end
premiere.step=premiere.step+1
end
end
function premiere.update_falling()
premiere.frame=13
premiere.wait=premiere.wait+1
if premiere.wait==6 then
premiere.wait=0
local inc=12 if premiere.flip then inc=2 end
if not premiere.flip and premiere.x==84 then
premiere.hab=premiere.hab+1
premiere.x=-4
elseif check_tile(premiere.hab,premiere.x+inc,premiere.y+14)<tiletype.half and check_tile(premiere.hab,premiere.x+inc,premiere.y+16)~=tiletype.void then
if premiere.flip then
premiere.x=premiere.x-2
else
premiere.x=premiere.x+2
end
if premiere.x<-4 then
premiere.hab=premiere.hab-1
premiere.x=84
end
end
local xx=flr((premiere.x+4)/8)
local yy=flr((premiere.y+16)/8)
if premiere.y<32 then
if (premiere.y+16)&7==0 and (check_tile(premiere.hab,premiere.x+4,premiere.y+16)>=tiletype.half or ((premiere.x+4)&7~=0 and check_tile(premiere.hab,premiere.x+12,premiere.y+16)>=tiletype.half)) then
premiere.update=premiere.update_normal
return
end
premiere.y=premiere.y+2
else
premiere.hab=premiere.hab+10
premiere.y=0
end
end
end

303
data/scenes.lua Normal file
View File

@@ -0,0 +1,303 @@
scenes={
intro_01= {
{x=3,y=0,flip=false,audio="abad",text={"Ah!, què bo!","Nit de Netflix amb","un bon bol de cacaus!"},die=20},
},
intro_02= {
{x=3,y=0,flip=false,audio="abad",text={"Eh! On està el","bol de cacaus???",""},die=20},
},
intro_03= {
{x=4,y=48,flip=true,audio="batman",musica=audio_song_batman,text={"ME L'HE ENDUT JO!!!", "S'HAN ACABAT ELS","CACAUS PA TU!"},die=20},
{x=3,y=0,flip=false,audio="abad",text={"Què??","Però perquè???",""},die=20},
{x=4,y=48,flip=true,audio="batman",text={"Estàs com una vaca!","Has de deixar de menjar", "eixes gorrinades"},die=20},
{x=4,y=48,flip=true,audio="batman",text={"Mira'm a mi. Estic","tot buenorro i faig", "esport"},die=20},
{x=3,y=0,flip=false,audio="abad",text={"Esport?????","I una merda!!","He de cuidar la panxa!"},die=20},
{x=4,y=48,flip=true,audio="batman",text={"Pos t'aguantes.","Ja pots despedir-te", "dels cacaus..."},die=20},
},
intro_04= {
{x=3,y=0,flip=false,audio="abad",text={"Serà mamó...","",""},die=20},
},
abad_inici={
{x=4,y=0,flip=false,audio="abad",text={"Se va a enterar eixe","imbècil de Batman","quan el pille..."}},
{x=4,y=0,flip=false,audio="abad",text={"Gonna per el GPS","per a trobarlo.",""}},
{x=4,y=0,flip=false,audio="abad",text={"I igual hi ha","algú més per ací","que em puga ajudar."}},
},
abad_corfes={
{x=4,y=0,flip=false,audio="abad",text={"Osti, està ple de","monstruacos.",""}},
{x=4,y=0,flip=false,audio="abad",text={"Pos al que s'acoste","s'endurà una corfa","de cacau al cap!"}},
{x=4,y=0,flip=false,audio="abad",text={"I si van altets","igual val la pena","ajupir-se..."}}
},
abad_portes={
{x=4,y=0,flip=false,audio="abad",text={"Qui ha tancat totes","les portes?",""}},
{x=4,y=0,flip=false,audio="abad",text={"A saber on està","cada interruptor","per a obrir-les..."}},
},
abad_porta_casa={
{x=4,y=0,flip=false,audio="abad",text={"Vaja, la porta de","casa també està","tancada."}},
{x=4,y=0,flip=false,audio="abad",text={"Però he de eixir!","Batman viu en la","casa de davant!"}},
},
abad_porta_batman={
{x=4,y=0,flip=false,audio="abad",text={"Be, era de esperar","que Batman tinguera","la porta tancada."}},
{x=4,y=0,flip=false,audio="abad",text={"Crec que hi havia","un passadis secret","del meu sotan al seu."}},
},
gps_trobat={
{x=4,y=0,flip=false,audio="abad",text={"Ale, ja tinc el GPS.","Ara puc trobar tot","el que necessite..."}},
{x=4,y=0,flip=false,audio="abad",text={"polsant les tecles","de l'1 al 5",""}},
},
premiere_intro={
{x=4,y=0,flip=false,audio="abad",musica=audio_song_premiere,text={"Premiere??","Qué fas per ma casa?",""}},
{x=69,y=20,flip=true,audio="premiere",text={"Porca miseria!!","l'uomo pipistrello!!","m'ha llevatto il gorro!"}},
{x=4,y=0,flip=false,audio="abad",text={"Pipistrello??","Això ques??",""}},
{x=69,y=20,flip=true,audio="premiere",text={"Il batmano!!","Incontrame il gorro","per l'amore d'un porco!"}},
{x=4,y=0,flip=false,audio="abad",text={"Tinc faena. A mi m'ha","furtat els cacaus i","he de trobarlos."}},
{x=69,y=20,flip=true,audio="premiere",text={"Lei tenne in su quarto!","Io tengo micha clave!","Achudame i t'achudo!"}}
},
premiere_intro_gorro={
{x=4,y=0,flip=false,audio="abad",musica=audio_song_premiere,text={"Premiere??","Qué fas per ma casa?",""}},
{x=69,y=20,flip=true,audio="premiere",text={"Porca miseria!!","l'uomo pipistrello!!","m'ha llevatto il gorro!"}},
{x=4,y=0,flip=false,audio="abad",text={"Pipistrello??","Això... be, te igual","Ací el tens, atontat."}},
{x=69,y=20,flip=true,audio="premiere",text={"Per fortuna!","Grazie mille!","Come podo achudarte?"}},
{x=4,y=0,flip=false,audio="abad",text={"Pos Batman m'ha furtat","els cacaus. Supose que","els te amagats."}},
{x=69,y=20,flip=true,audio="premiere",text={"In lo suo quarto!","Io tengo micha clave!","Tenne, tenne!!"}}
},
premiere_gorro={
{x=4,y=0,flip=false,audio="abad",musica=audio_song_premiere,text={"Tin, el ditxos gorro.","",""}},
{x=69,y=20,flip=true,audio="premiere",text={"Bravissimo!","Che giornatta","fantastica! Figo!"}},
{x=4,y=0,flip=false,audio="abad",text={"Tu si que eres un","figo. On està eixa","mitja clau?"}},
{x=69,y=20,flip=true,audio="premiere",text={"Giusto! Aquí tenne!","Buona fortuna per","la tua avventura!"}},
{x=69,y=20,flip=true,audio="premiere",text={"E NON TOCARE il","Batmano! Sei molto","poderoso!"}}
},
gorro_trobat_nointro={
{x=4,y=0,flip=false,audio="abad",text={"Mira, el gorro","de Premiere.","Millor l'agafe."}}
},
gorro_trobat={
{x=4,y=0,flip=false,audio="abad",text={"Mira, el gorro","de Premiere.","A la saca."}}
},
elalien_intro={
{x=4,y=0,flip=false,audio="abad",musica=audio_song_elalien,text={"Que passa alien?","A tu també t'ha","putejat el Batman?"}},
{x=3,y=16,flip=true,audio="elalien",text={"CAGUEN L'OU!!","ESTAVA JO TAN TRANQUIL","PODANT AL MEU GOS..."}},
{x=3,y=16,flip=true,audio="elalien",text={"...I QUAN NO MIRABA","M'HA FURTAT EL","MARANÀ!!!"}},
{x=4,y=0,flip=false,audio="abad",text={"Es...taves podant","a un gos...?",""}},
{x=3,y=16,flip=true,audio="elalien",text={"EN JUPITER NO POTS","DEIXAR QUE LI CREIXEN","MES DE 12 PATES!!"}},
{x=4,y=0,flip=false,audio="abad",text={"Uh... clar...","A mi m'ha furtat","els cacaus."}},
{x=3,y=16,flip=true,audio="elalien",text={"ELS TÉ EN LA SEUA","HABITACIÓ SEGUR.","TROBA EL BERENAR..."}},
{x=3,y=16,flip=true,audio="elalien",text={"...I JO ET DONARÉ","LA MEITAT DE LA CLAU","PER A ENTRAR."}}
},
elalien_intro_peu={
{x=4,y=0,flip=false,audio="abad",musica=audio_song_elalien,text={"Que passa alien?","A tu també t'ha","putejat el Batman?"}},
{x=3,y=16,flip=true,audio="elalien",text={"CAGUEN L'OU!!","ESTAVA JO TAN TRANQUIL","PODANT AL MEU GOS..."}},
{x=3,y=16,flip=true,audio="elalien",text={"...I QUAN NO MIRABA","M'HA FURTAT EL","MARANÀ!!!"}},
{x=4,y=0,flip=false,audio="abad",text={"Podant...? be, te","igual. Açò deu ser","el teu berenar."}},
{x=3,y=16,flip=true,audio="elalien",text={"OSTI QUE BÓ!!!","GRACIES AUELO!","A TU QUE T'HA FET?"}},
{x=4,y=0,flip=false,audio="abad",text={"M'ha furtat els cacaus.","Segur que els té","al seu quarto."}},
{x=3,y=16,flip=true,audio="elalien",text={"SEGUR! PERO JO TINC","LA MEITAT DE LA CLAU.","TIN, I SORT!"}}
},
elalien_peu={
{x=4,y=0,flip=false,audio="abad",musica=audio_song_elalien,text={"Ací tens...","Uff, que peste fa...",""}},
{x=3,y=16,flip=true,audio="elalien",text={"GRACIES!!!","SÍ, EH? QUE","SUCOSET I BÓ."}},
{x=4,y=0,flip=false,audio="abad",text={"Clar...","Be, i eixa","mitja clau?"}},
{x=3,y=16,flip=true,audio="elalien",text={"TIN! QUAN TINGUES","ELS CACAUS, PEGA-LI","CACAUÀ A BATMAN!"}},
},
peu_trobat_nointro={
{x=4,y=0,flip=false,audio="abad",text={"Un peu podrit??","Qué asco!! Segur","que és d'el alien."}}
},
peu_trobat={
{x=4,y=0,flip=false,audio="abad",text={"Joer, açò deu ser","el berenar d'el alien.","Ecs..."}}
},
habitacio_batman={
{x=4,y=0,flip=false,audio="abad",text={"L'habitació de Batman!","Segur que els cacaus","estàn ahí dins."}},
{x=4,y=0,flip=false,audio="abad",text={"Però necessite","una clau...",""}}
},
bol_trobat={
{x=4,y=0,flip=false,audio="abad",text={"PER FI, JA TINC","ELS MEUS CACAUS!!!","OLE!! OLE!!"}},
{x=4,y=0,flip=false,audio="abad",text={"Se va a enterar","Batman ara quan","el pille..."}},
{x=4,y=0,flip=false,audio="abad",text={"Ara si que li puc","pegar una bona","cacauà..."}}
},
final= {
{x=4,y=48,flip=true,audio="batman",musica=audio_song_batman,text={"AI!", "M'has fet mal!!!",""},die=20},
{x=3,y=0,flip=false,audio="abad",text={"Aixó per furtar-me","el bol de cacaus,","imbèsil"},die=20},
{x=4,y=48,flip=true,audio="batman",text={"Cert, esta me la","mereixia... però", "mira que be estàs!"},die=20},
{x=4,y=48,flip=true,audio="batman",text={"Amb el que t'ha","costat pillar-me", "t'has ficat en forma"},die=20},
{x=3,y=0,flip=false,audio="abad",text={"No me vingues en","tonteries,","mamarratxo."},die=20},
{x=3,y=0,flip=false,audio="abad",text={"Creus que no he","notat que falta mig","bol de cacaus?"},die=20},
{x=4,y=48,flip=true,audio="batman",text={"Jejejeje, es que","estàn molt bons!", ""},die=20},
{x=4,y=48,flip=true,audio="batman",text={"Però si vols te","done del meu bol", "de tramussos."},die=20},
{x=3,y=0,flip=false,audio="abad",text={"TRAMUSSOS...","",""},die=10},
{x=3,y=0,flip=false,audio="abad",text={"M'atreviré a","passar l'última","frontera...?"},die=40},
},
}
function start_scene(scene,offset)
--bkg=newsurf(128,96)
--setdest(bkg)
--setsource(0)
--sspr(0,0,128,96,0,0)
--setsource(tiles)
--setdest(0)
scenes.current_scene=scene
scenes.dnum=1
scenes.step=0
scenes.char=1
scenes.wait=0
scenes.offset=28
scenes.die=scenes.current_scene[scenes.dnum].die or 0
if scene[1].musica then
--print(scene[1].musica)
playmus(scenes.current_scene[scenes.dnum].musica)
end
if offset then scenes.offset=offset end
old_update=_update
_update=update_scene
end
function playtext(snd)
if snd=="abad" then
playsnd(audio_text_abad)
elseif snd=="batman" then
playsnd(audio_text_batman)
elseif snd=="premiere" then
playsnd(audio_text_premiere)
elseif snd=="elalien" then
playsnd(audio_text_elalien)
end
end
function draw_scene()
local txt_x = not scenes.current_scene[scenes.dnum].flip and 38 or 8
camera(0,-scenes.offset)
if scenes.step==0 then
rectfill(0,16,128,17,12)
line(0,15,128,15,16)
line(0,18,128,18,16)
elseif scenes.step==1 then
rectfill(0,8,128,26,12)
line(0,7,128,7,16)
line(0,27,128,27,16)
elseif scenes.step==2 then
rectfill(0,0,128,34,12)
line(0,0,128,0,16)
line(0,34,128,34,16)
elseif scenes.step==3 then
if not scenes.current_scene[scenes.dnum].flip then
rectfill(8,12,31,23,16)
sspr(scenes.current_scene[scenes.dnum].x,scenes.current_scene[scenes.dnum].y,10,10,9,13,20,10)
else
rectfill(97,12,120,23,16)
sspr(scenes.current_scene[scenes.dnum].x,scenes.current_scene[scenes.dnum].y,10,10,98,13,20,10,true)
end
elseif scenes.step==4 then
if not scenes.current_scene[scenes.dnum].flip then
rectfill(8,7,31,28,16)
sspr(scenes.current_scene[scenes.dnum].x,scenes.current_scene[scenes.dnum].y,10,10,9,8,20,20)
else
rectfill(97,7,120,28,16)
sspr(scenes.current_scene[scenes.dnum].x,scenes.current_scene[scenes.dnum].y,10,10,98,8,20,20,true)
end
elseif scenes.step==5 then
text(string.sub(scenes.current_scene[scenes.dnum].text[1],1,scenes.char),txt_x,7,2)
if scenes.char<#scenes.current_scene[scenes.dnum].text[1] then
scenes.step=scenes.step-1
scenes.char=scenes.char+1
playtext(scenes.current_scene[scenes.dnum].audio)
else
scenes.char=1
end
elseif scenes.step==6 then
text(string.sub(scenes.current_scene[scenes.dnum].text[2],1,scenes.char),txt_x,15,2)
if scenes.char<#scenes.current_scene[scenes.dnum].text[2] then
scenes.step=scenes.step-1
scenes.char=scenes.char+1
playtext(scenes.current_scene[scenes.dnum].audio)
else
scenes.char=1
end
elseif scenes.step==7 then
text(string.sub(scenes.current_scene[scenes.dnum].text[3],1,scenes.char),txt_x,23,2)
if scenes.char<#scenes.current_scene[scenes.dnum].text[3] then
scenes.step=scenes.step-1
scenes.char=scenes.char+1
playtext(scenes.current_scene[scenes.dnum].audio)
else
scenes.char=1
end
elseif scenes.step==8 then
rectfill(0,0,128,34,12)
line(0,0,128,0,16)
line(0,34,128,34,16)
if not scenes.current_scene[scenes.dnum].flip then
rectfill(8,7,31,28,16)
sspr(scenes.current_scene[scenes.dnum].x,scenes.current_scene[scenes.dnum].y,10,10,9,8,20,20)
else
rectfill(97,7,120,28,16)
sspr(scenes.current_scene[scenes.dnum].x,scenes.current_scene[scenes.dnum].y,10,10,98,8,20,20,true)
end
text(scenes.current_scene[scenes.dnum].text[1],txt_x,7,2)
text(scenes.current_scene[scenes.dnum].text[2],txt_x,15,2)
text(scenes.current_scene[scenes.dnum].text[3],txt_x,23,2)
end
if scenes.step<=8 then scenes.step=scenes.step+1 end
camera(0,0)
end
function update_scene()
scenes.wait=scenes.wait+1
if scenes.wait==6 then
scenes.wait=0
draw_scene()
if scenes.step>8 then
--print(scenes.die)
if scenes.die>0 then
scenes.die=scenes.die-1
if scenes.die==0 then
if scenes.dnum==#scenes.current_scene then
stopmusic()
if batman.endgame then
final_init()
fade.fadeoutin()
else
_update=old_update
end
else
scenes.dnum=scenes.dnum+1
scenes.die=scenes.current_scene[scenes.dnum].die or 0
scenes.step=2
end
end
else
if flr(time()*2)%2==0 then
sspr(104,88,7,5,118,56)
else
rectfill(118,56,125,61,12)
end
end
end
end
if btnp(KEY_ESCAPE) and (scenes.current_scene~=scenes.final) then
if scenes.current_scene[scenes.dnum].die then
game_init(true)
else
pause()
end
elseif btnp(KEY_M) then
mute = not mute
end
if scenes.step>8 then
if btnp(KEY_SPACE) or btnp(KEY_DOWN) or btnp(KEY_UP) or btnp(KEY_LEFT) or btnp(KEY_RIGHT) or btnp(KEY_RETURN) then
if scenes.dnum==#scenes.current_scene then
stopmusic()
if batman.endgame then
final_init()
fade.fadeoutin()
else
_update=old_update
end
else
scenes.dnum=scenes.dnum+1
scenes.step=2
end
end
elseif btnp(KEY_SPACE) then
scenes.step=8
end
end

43
data/score.lua Normal file
View File

@@ -0,0 +1,43 @@
score={}
function score.create()
score.surf=newsurf(32,96)
setdest(score.surf)
cls(16)
sspr(0,0,16,9,5,9,16,9,true)
spr(132,0,0,1,1) spr(150,8,0,1,1) spr(150,16,0,1,1) spr(133,24,0,1,1)
spr(134,0,8,1,1) spr(135,24,8,1,1) spr(134,0,16,1,1) spr(135,24,16,1,1)
spr(132,0,24,1,1) spr(150,8,24,1,1) spr(150,16,24,1,1) spr(133,24,24,1,1)
spr(134,0,32,1,1) spr(135,24,32,1,1)
spr(132,0,40,1,1) spr(150,8,40,1,1) spr(150,16,40,1,1) spr(133,24,40,1,1)
spr(134,0,48,1,1) spr(135,24,48,1,1) spr(134,0,56,1,1) spr(135,24,56,1,1)
spr(134,0,64,1,1) spr(135,24,64,1,1) --spr(134,0,72,1,1) spr(135,24,72,1,1)
spr(132,0,72,1,1) spr(150,8,72,1,1) spr(150,16,72,1,1) spr(133,24,72,1,1)
spr(134,0,80,1,1) spr(135,24,80,1,1) spr(134,0,88,1,1) spr(135,24,88,1,1)
prnt("jail",6,77,2)
prnt("games",8,82,2)
prnt("2023",9,89,1)
rectfill(06,30,07,37,03)
rectfill(09,30,10,37,08)
rectfill(12,30,13,37,08)
rectfill(15,30,16,37,10)
rectfill(18,30,19,37,10)
rectfill(21,30,22,37,10)
rectfill(24,30,25,37,10)
setdest(0)
end
function score.draw()
setsource(score.surf)
sspr(0,0,32,96,96,0)
setsource(tiles)
if abad.objects.gorro~=nil then sspr(96,32,16,16,99,44) end
if abad.objects.peu~=nil then sspr(112,32,16,16,109,44) end
if abad.objects.gps~=nil then sspr(112,48,16,16,100,55) end
if abad.objects.clau_premiere~=nil then sspr(112,8,8,8,104,48) end
if abad.objects.clau_elalien~=nil then sspr(120,8,8,8,112,48) end
if abad.objects.bol~=nil then sspr(112,88,16,8,104,46) end
end

BIN
data/snd_afal.wav Normal file

Binary file not shown.

BIN
data/snd_ahit.wav Normal file

Binary file not shown.

BIN
data/snd_ajmp.wav Normal file

Binary file not shown.

BIN
data/snd_asht.wav Normal file

Binary file not shown.

BIN
data/snd_ast1.wav Normal file

Binary file not shown.

BIN
data/snd_ast2.wav Normal file

Binary file not shown.

BIN
data/snd_ast3.wav Normal file

Binary file not shown.

BIN
data/snd_hit.wav Normal file

Binary file not shown.

BIN
data/snd_low.wav Normal file

Binary file not shown.

BIN
data/snd_swch.wav Normal file

Binary file not shown.

BIN
data/snd_txta.wav Normal file

Binary file not shown.

BIN
data/snd_txtb.wav Normal file

Binary file not shown.

BIN
data/snd_txte.wav Normal file

Binary file not shown.

BIN
data/snd_txtp.wav Normal file

Binary file not shown.

46
data/switches.lua Normal file
View File

@@ -0,0 +1,46 @@
switches={
cooldown=0,
wait=0,
current_list=nil,
current_index=-1,
[1]={[0]={20, 53,41}},
[11]={[21]={11, 57,45}},
[35]={[14]={32, 50,38,26,53,41,29}},
[53]={[14]={72, 42,30}},
[61]={[14]={54, 54,42}},
[76]={[19]={77, 50,38,26},
[22]={57, 53,41}},
[80]={[18]={36, 56,44}},
[39]={[27]={39, 62,63}}
}
--switches[11]={[21]={11, 57,45}}
--switches[11][21]={11, 57,45}
function switches.start(hab,tile)
if switches.cooldown>0 then return end
mapa_set_tile_by_index(hab,tile,57)
switches.current_list=switches[hab+1][tile]
--print(tile)
switches.current_index=2
switches.wait=0
switches.cooldown=60
playsnd(audio_switch)
end
function switches.update()
if switches.cooldown>0 then switches.cooldown=switches.cooldown-1 end
if switches.current_list==nil then return end
--cls(4)
switches.wait=switches.wait+1
if switches.wait>=6 then
switches.wait=0
mapa_set_tile_by_index(switches.current_list[1]-1,switches.current_list[switches.current_index]+1,256)
switches.current_index=switches.current_index+1
if switches.current_index>#switches.current_list then
switches.current_list=nil
end
end
end

BIN
data/tiles.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

108
data/trigger.lua Normal file
View File

@@ -0,0 +1,108 @@
trigger={}
function trigger.new(_hab,_x,_y,_fun)
return {hab=_hab,x=_x,y=_y,fun=_fun,update=trigger.update,draw=trigger.draw,bb={x=0,y=0,w=8,h=8}}
end
function trigger:draw()
-- do nothing
--rectfill(self.x,self.y,self.x+8,self.y+8,3)
end
function trigger:update()
if self.hab==abad.hab then
if aabb(abad,self) then
self:fun()
end
end
end
--function trigger:do_touched()
-- start_scene(self.scene)
-- remove_actor(self)
--end
triggers={}
function triggers:escena_abad_inici()
start_scene(scenes.abad_inici)
remove_actor(self)
end
function triggers:escena_abad_corfes()
start_scene(scenes.abad_corfes)
remove_actor(self)
end
function triggers:escena_abad_portes()
if abad.escena_portes==nil and ((abad.hab==31 and mapa_get_tile(abad.hab,2,4)~=256) or (abad.hab==71 and mapa_get_tile(abad.hab,6,3)~=256)) then
start_scene(scenes.abad_portes)
end
abad.escena_portes=true
remove_actor(self)
end
function triggers:escena_abad_porta_casa()
if mapa_get_tile(abad.hab,6,4)~=256 then
start_scene(scenes.abad_porta_casa)
end
remove_actor(self)
end
function triggers:escena_abad_porta_batman()
if mapa_get_tile(abad.hab,5,4)~=256 then
start_scene(scenes.abad_porta_batman)
end
remove_actor(self)
end
function triggers:escena_habitacio_batman()
if abad.objects.clau_premiere~=nil and abad.objects.clau_elalien~=nil then
switches.start(0,0)
abad.objects.clau_premiere=nil
abad.objects.clau_elalien=nil
remove_actor(self)
else
if batman.habitacio_porta_intro==nil then
start_scene(scenes.habitacio_batman)
batman.habitacio_porta_intro=true
end
end
end
function triggers:teleport_a()
abad.teleport=true
playsnd(audio_hit)
cls(14)
imp.reset()
abad.hab=67
abad.x=24
end
function triggers:teleport_b()
if abad.teleport then
playsnd(audio_hit)
cls(14)
imp.reset()
abad.hab=14
abad.x=16
end
end
function triggers:teleport_c()
abad.teleport2=true
playsnd(audio_hit)
cls(14)
imp.reset()
abad.hab=61
abad.x=24
end
function triggers:teleport_d()
if abad.teleport2 then
playsnd(audio_hit)
cls(14)
imp.reset()
abad.hab=29
abad.x=24
end
end

71
data/zombie.lua Normal file
View File

@@ -0,0 +1,71 @@
zombie={}
function zombie.new(_hab,_x,_y,_flip)
return {hab=_hab,x=_x,y=_y,flip=_flip,frame=0,wait=0,step=0,hit=zombie.hit,update=zombie.update_normal, draw=zombie.draw,jumpfwd=false,anim={16,17,16,18},bb={x=4,y=0,w=8,h=16}}
end
function zombie:draw()
if self.frame>0 then sspr((self.frame&7)*16,(self.frame>>3)*16,16,16,self.x,self.y,16,16,self.flip) end
end
function zombie:update_normal()
self.wait=self.wait+1
if self.wait==6 then
self.wait=0
self.step=(self.step+1)%4
self.frame=self.anim[self.step+1]
local inc=12 if self.flip then inc=2 end
if not self.flip and self.x==84 then
self.hab=self.hab+1
self.x=-4
elseif check_tile(self.hab,self.x+inc,self.y+14)<tiletype.block and check_tile(self.hab,self.x+inc,self.y+16)~=tiletype.void then
if self.flip then
self.x=self.x-2
else
self.x=self.x+2
end
if self.x<-4 then
self.hab=self.hab-1
self.x=84
end
else
self.flip=not self.flip
end
if self.hab==abad.hab then
if aabb(abad,self) then
abad_hurt(1)
end
end
--if check_tile(self.hab,self.x+4,self.y+16)==tiletype.void and ((self.x+4)&7==0 or check_tile(self.hab,self.x+12,self.y+16)==tiletype.void) then
-- self.flip=not self.flip
--end
end
end
function zombie:update_hit()
self.wait=self.wait+1
if self.wait==6 then
self.wait=0
self.step=self.step+1
if self.step<40 then
if self.step%2==0 then
self.frame=16
else
self.frame=-1
end
elseif self.step>=40 then
self.step=0
self.wait=0
self.update=zombie.update_normal
end
end
end
function zombie:hit()
self.update=zombie.update_hit
end