From e1f1e0e95c855ca1ea8dbaa842d85ce7b87d1c20 Mon Sep 17 00:00:00 2001 From: JailDoctor Date: Sat, 22 Oct 2022 07:53:12 +0200 Subject: [PATCH] first commit --- abad.lua | 222 +++++++++++++++ cacau.lua | 41 +++ caco.lua | 80 ++++++ game.ini | 5 + main.lua | 127 +++++++++ map.lua | 802 +++++++++++++++++++++++++++++++++++++++++++++++++++++ mapa.lua | 93 +++++++ score.lua | 34 +++ tiles.gif | Bin 0 -> 3151 bytes zombie.lua | 72 +++++ 10 files changed, 1476 insertions(+) create mode 100644 abad.lua create mode 100644 cacau.lua create mode 100644 caco.lua create mode 100644 game.ini create mode 100644 main.lua create mode 100644 map.lua create mode 100644 mapa.lua create mode 100644 score.lua create mode 100644 tiles.gif create mode 100644 zombie.lua diff --git a/abad.lua b/abad.lua new file mode 100644 index 0000000..828d752 --- /dev/null +++ b/abad.lua @@ -0,0 +1,222 @@ + +abad={x=24,y=24,flip=false,frame=1,wait=0,hab=0,vides=3,energia=40,step=0,update=nil,jumpfwd=false,anim={0,1,0,2},bb={x=4,y=0,w=8,h=16}} + +function abad_init() + abad.update=abad_state_normal +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 + sspr(abad.frame*16,0,16,16,abad.x,abad.y,16,16,flip) +end + +function abad_state_normal() + abad.frame=0 + abad.wait=0 + abad.step=0 + abad.jumpfwd=false + + 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 + elseif btn(KEY_DOWN) then + abad.update=abad_state_crouch + elseif btn(KEY_SPACE) and cacau.hab==-1 then + 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 + abad.x=-4 + elseif check_tile(abad.hab,abad.x+inc,abad.y+14)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 + abad.y=abad.y-2 + end + end + else + abad.hab=abad.hab-10 + abad.y=32 + end + elseif abad.step>6 then + abad.update=abad_state_falling + 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 + else + abad.hab=abad.hab+10 + 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() + elseif btn(KEY_LEFT) then + abad.flip=true + abad_advance() + 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 + end + else + abad.hab=abad.hab-10 + 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 + end + else + abad.hab=abad.hab+10 + abad.y=0 + end + end + end +end \ No newline at end of file diff --git a/cacau.lua b/cacau.lua new file mode 100644 index 0000000..bd10290 --- /dev/null +++ b/cacau.lua @@ -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)>3)*16,16,16,self.x,self.y,16,16,self.flip) +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)0 then abad.energia=abad.energia-1 end + cls(3) + 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=7 + 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 diff --git a/game.ini b/game.ini new file mode 100644 index 0000000..76beff1 --- /dev/null +++ b/game.ini @@ -0,0 +1,5 @@ +title=Cacaus +width=128 +height=96 +zoom=4 +files=score.lua,map.lua,mapa.lua,cacau.lua,caco.lua,zombie.lua,abad.lua,main.lua diff --git a/main.lua b/main.lua new file mode 100644 index 0000000..6001331 --- /dev/null +++ b/main.lua @@ -0,0 +1,127 @@ +--hab=0 + +modes={playing=0,editing=1} +mode=modes.editing + +seltile = 0 + +actors={} + +function _init() + tiles=loadsurf("tiles.gif") + setsource(tiles) + local pal=loadpal("tiles.gif") + setpal(pal) + + --mapa_new() + abad_init() + table.insert(actors,abad) + z = zombie.new() + table.insert(actors,z) + c=caco.new(10,24,16) + table.insert(actors,c) + score.create() +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 cacau.hab==hab then cacau:draw() end + end + camera(0,0) +end + +function _update() + cls(16) + + if mode==modes.editing then + draw_hab(abad.hab,0,0,true) + text(abad.hab,100,10,2) + + sspr(0,64,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) + 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) then + mapa_save() + elseif btnp(KEY_C) then + mapa_cycle_colors(abad.hab) + end + + local mx,my=mousex(),mousey() + if mbtn(1) then + if my>=48 then + seltile=(mx>>3)+((my-48)>>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,255) + end + end + else + draw_hab(abad.hab,0,0) + text(abad.hab,1,1,2) + draw_hab(10,0,48) + + score.draw() + setsource(tiles) + prnt("x"..abad.vides,114,13,2) + rectfill(102+(abad.energia>>1),30,122,37,16) + for key,actor in pairs(actors) do + actor:update() + if actor.hab==cacau.hab and actor~=abad then + if aabb(actor,cacau) then + actor:hit() + cacau.hab=-1 + end + end + end + cacau.update() + + if btnp(KEY_RETURN) then + mode=modes.editing + end + + end +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 \ No newline at end of file diff --git a/map.lua b/map.lua new file mode 100644 index 0000000..e4b801d --- /dev/null +++ b/map.lua @@ -0,0 +1,802 @@ +mapa={ + -- 1 + { + 18,19,20,21,20,21,20,21,20,21,20,21, + 16,72,255,255,255,255,255,255,255,255,255,255, + 16,88,255,255,255,255,255,255,255,255,255,255, + 16,255,255,255,255,255,255,255,255,255,255,255, + 16,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 2 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,69,255,255,255,69,255,255,255,69,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,21,255,255,17,20,21, + + }, + -- 3 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 4 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,10,11,255,255, + 20,21,20,21,20,21,20,21,10,11,20,21, + + }, + -- 5 + { + 20,21,20,21,20,21,20,21,20,21,20,16, + 255,255,255,255,255,255,255,255,255,255,255,16, + 255,255,255,255,255,255,255,255,255,255,255,16, + 255,255,255,255,255,255,255,255,255,255,255,16, + 255,255,255,255,255,255,255,255,255,255,255,16, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 6 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 7 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 8 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 9 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 10 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 11 + { + 25,29,28,29,28,29,28,29,28,29,28,29, + 24,255,255,255,255,255,255,255,255,255,255,255, + 24,255,255,255,255,70,71,255,255,255,255,255, + 24,255,255,255,69,86,87,69,255,255,255,255, + 24,255,255,255,255,255,255,255,255,255,255,255, + 28,29,28,29,28,29,28,29,28,29,28,29, + + }, + -- 12 + { + 28,29,28,29,28,29,29,255,255,255,28,29, + 255,255,255,255,255,255,255,255,255,25,255,255, + 255,255,255,255,255,255,255,255,1,255,255,255, + 255,255,255,255,255,255,255,1,255,255,255,255, + 255,255,255,255,255,255,1,255,255,255,255,255, + 28,29,28,29,28,29,28,29,28,29,28,29, + + }, + -- 13 + { + 28,29,28,29,28,29,28,29,28,29,28,29, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 28,29,28,29,28,29,29,255,255,25,28,29, + + }, + -- 14 + { + 28,29,28,29,28,29,28,29,10,11,28,29, + 255,255,255,255,255,255,255,255,10,11,255,255, + 255,255,255,255,255,255,255,255,10,11,255,255, + 255,255,255,255,255,255,255,255,10,11,255,255, + 255,255,255,255,255,255,255,255,10,11,255,255, + 28,29,28,29,28,29,28,29,28,29,28,29, + + }, + -- 15 + { + 28,29,28,29,28,29,28,29,28,29,28,24, + 255,255,255,255,255,255,255,255,255,255,255,24, + 255,255,255,255,255,255,255,255,255,255,255,24, + 255,255,255,255,255,255,255,255,255,255,255,24, + 255,255,255,255,255,255,255,255,255,255,255,24, + 28,29,28,29,28,29,28,29,28,29,28,29, + + }, + -- 16 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 17 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 18 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 19 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 20 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 21 + { + 33,37,36,37,36,37,36,37,36,37,36,37, + 32,255,255,255,255,255,255,255,255,255,255,255, + 32,255,255,255,255,255,255,255,255,255,255,255, + 32,255,255,255,255,255,255,255,255,255,255,255, + 32,255,8,9,255,255,255,255,255,255,255,255, + 36,37,8,9,36,37,36,37,36,37,36,37, + + }, + -- 22 + { + 36,37,36,37,36,37,36,37,36,37,36,37, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 36,37,36,37,36,37,36,37,36,37,36,37, + + }, + -- 23 + { + 36,37,36,37,36,37,37,255,255,255,36,37, + 255,255,255,255,255,255,255,255,255,33,255,255, + 255,255,255,255,255,255,255,255,2,255,255,255, + 255,255,255,255,255,255,255,2,255,255,255,255, + 255,255,255,255,255,255,2,255,255,255,255,255, + 36,37,36,37,36,37,36,37,36,37,36,37, + + }, + -- 24 + { + 36,37,36,37,36,37,36,37,36,37,36,37, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 36,37,36,37,36,37,36,37,36,37,36,37, + + }, + -- 25 + { + 36,37,36,37,36,37,36,37,36,37,36,33, + 255,255,255,255,255,255,255,255,255,255,255,32, + 255,255,255,255,255,255,255,255,255,255,255,32, + 255,255,255,255,255,255,255,255,255,255,255,32, + 255,255,255,255,255,255,255,255,8,9,255,32, + 36,37,36,37,36,37,36,37,8,9,36,37, + + }, + -- 26 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 27 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 28 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 29 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 30 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 31 + { + 41,45,8,9,44,45,44,45,44,45,44,45, + 40,255,8,9,255,255,255,255,255,255,255,255, + 40,255,8,9,255,255,255,255,255,255,255,255, + 40,255,8,9,255,255,255,255,255,255,255,255, + 40,255,8,9,255,255,255,255,255,255,255,255, + 44,45,8,9,44,45,44,45,44,45,44,45, + + }, + -- 32 + { + 44,45,44,45,44,45,44,45,44,45,44,45, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 44,45,44,45,44,45,45,255,255,41,44,45, + + }, + -- 33 + { + 44,45,44,45,44,45,44,45,44,45,44,45, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 44,45,44,45,44,45,44,45,44,45,44,45, + + }, + -- 34 + { + 44,45,44,45,44,45,44,45,44,45,44,41, + 255,255,255,255,255,255,255,255,255,255,255,40, + 255,255,255,255,255,255,255,255,255,255,255,40, + 255,255,255,255,255,255,255,255,255,255,255,40, + 255,255,255,255,255,255,255,255,255,255,255,40, + 44,45,41,255,255,44,44,45,44,45,44,45, + + }, + -- 35 + { + 25,29,28,29,28,29,28,29,8,9,28,25, + 24,255,255,255,255,255,255,255,8,9,255,24, + 24,255,255,255,255,255,255,255,8,9,255,24, + 24,255,255,255,255,255,255,255,8,9,255,24, + 24,255,255,255,255,255,255,255,8,9,255,24, + 28,29,28,29,28,29,28,29,8,9,28,29, + + }, + -- 36 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 37 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 38 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 39 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 40 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 41 + { + 25,29,8,9,28,29,28,29,28,29,28,29, + 24,255,8,9,255,255,255,255,255,255,255,255, + 24,255,8,9,255,255,255,255,255,255,255,255, + 24,255,8,9,255,255,255,255,255,255,255,255, + 24,255,8,9,255,255,255,255,255,255,255,255, + 28,29,28,29,28,29,29,255,255,25,28,29, + + }, + -- 42 + { + 28,29,28,29,28,29,29,255,255,255,28,29, + 255,255,255,255,255,255,255,255,255,25,255,255, + 255,255,255,255,255,255,255,255,1,255,255,255, + 255,255,255,255,255,255,255,1,255,255,255,255, + 255,255,255,255,255,255,1,255,255,255,255,255, + 28,29,28,29,28,29,28,29,28,29,28,29, + + }, + -- 43 + { + 28,29,28,29,28,29,28,29,28,29,28,25, + 255,255,255,255,255,255,255,255,255,255,255,24, + 255,255,255,255,255,255,255,255,255,255,255,24, + 255,255,255,255,255,255,255,255,255,255,255,24, + 255,255,10,11,255,255,255,255,255,255,255,24, + 28,29,10,11,28,29,28,29,28,29,28,29, + + }, + -- 44 + { + 33,37,255,255,255,36,36,37,36,37,36,37, + 32,255,33,255,255,255,255,255,255,255,255,255, + 32,255,255,2,255,255,255,255,255,255,255,255, + 32,255,255,255,2,255,255,255,255,255,255,255, + 32,255,255,255,255,2,255,255,255,255,255,255, + 36,37,36,37,36,37,36,37,36,37,36,37, + + }, + -- 45 + { + 36,37,36,37,36,37,36,37,8,9,36,33, + 255,255,255,255,255,255,255,255,8,9,255,32, + 255,255,255,255,255,255,255,255,8,9,255,32, + 255,255,255,255,255,255,255,255,8,9,255,32, + 255,255,255,255,255,255,255,255,8,9,255,32, + 36,37,36,37,36,37,36,37,36,37,36,37, + + }, + -- 46 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 47 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 48 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 49 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 50 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 51 + { + 41,45,44,45,44,45,45,255,255,255,44,45, + 40,255,255,255,255,255,255,255,255,41,255,255, + 40,255,255,255,255,255,255,255,3,255,255,255, + 40,255,255,255,255,255,255,3,255,255,255,255, + 40,255,255,255,255,255,3,255,255,255,255,255, + 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, + 255,255,255,255,255,255,255,255,255,255,255,40, + 255,255,255,255,255,255,255,255,255,255,255,40, + 255,255,255,255,255,255,255,255,255,255,255,40, + 255,255,255,255,255,255,255,255,255,255,255,40, + 44,45,41,255,255,44,44,45,44,45,44,45, + + }, + -- 53 + { + 17,21,10,11,20,21,20,21,20,21,20,21, + 16,255,10,11,255,255,255,255,255,255,255,255, + 16,255,10,11,255,255,255,255,255,255,255,255, + 16,255,10,11,255,255,255,255,255,255,255,255, + 16,255,10,11,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 54 + { + 20,21,20,21,20,21,18,19,67,255,255,255, + 255,255,255,255,255,255,18,19,255,65,68,64, + 255,255,255,255,255,255,18,19,255,255,255,255, + 255,255,255,255,255,255,255,255,67,255,64,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,54,55,54,56, + + }, + -- 55 + { + 255,65,255,255,255,67,255,67,255,255,255,255, + 255,255,255,64,255,255,255,255,65,68,64,255, + 255,255,255,255,255,255,64,255,255,255,255,67, + 255,255,65,67,255,255,64,255,255,64,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 54,55,54,56,56,55,54,56,54,56,55,54, + + }, + -- 56 + { + 65,255,255,255,67,255,67,255,255,255,255,64, + 255,255,64,255,255,255,255,65,68,64,255,255, + 255,255,255,255,255,64,255,255,255,255,67,255, + 255,65,67,255,255,64,255,255,64,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 55,54,55,54,56,54,55,56,54,55,54,56, + + }, + -- 57 + { + 255,255,255,67,34,35,34,35,34,35,34,35, + 255,64,255,255,34,35,255,255,255,255,255,255, + 255,255,255,255,34,35,255,255,255,255,255,255, + 65,67,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 54,55,56,54,36,37,36,37,36,37,36,37, + + }, + -- 58 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 59 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 60 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 61 + { + 17,21,20,21,20,21,20,21,20,21,20,21, + 16,255,255,255,255,255,255,255,255,255,255,255, + 16,255,255,255,255,255,255,255,255,255,255,255, + 16,255,255,255,255,255,255,255,255,255,255,255, + 16,255,10,11,255,255,255,255,255,255,255,255, + 20,21,10,11,20,21,20,21,20,21,20,21, + + }, + -- 62 + { + 20,21,255,255,255,20,20,21,20,21,20,21, + 255,255,17,255,255,255,255,255,255,255,255,255, + 255,255,255,0,255,255,255,255,255,255,255,255, + 255,255,255,255,0,255,255,255,255,255,255,255, + 255,255,255,255,255,0,255,255,255,255,255,255, + 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, + 255,255,255,255,255,255,255,255,255,255,255,16, + 255,255,255,255,255,255,255,255,255,255,255,16, + 255,255,255,255,255,255,255,255,255,255,255,16, + 255,255,255,255,255,255,255,255,255,255,255,16, + 20,21,17,255,255,20,20,21,20,21,20,21, + + }, + -- 64 + { + 41,48,49,48,50,49,48,49,48,50,49,48, + 41,255,255,255,255,255,255,255,255,255,255,255, + 41,255,255,255,255,255,255,255,255,255,255,255, + 41,255,255,255,255,255,255,255,255,255,255,255, + 41,255,8,9,255,255,255,255,255,255,255,255, + 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, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,42,43,42,43, + 255,255,255,255,42,43,42,43,255,255,255,255, + 42,43,42,43,255,255,255,255,255,255,255,255, + + }, + -- 66 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 67 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 68 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 69 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 70 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 71 + { + 26,27,10,11,26,27,26,27,26,27,26,27, + 25,255,10,11,255,255,255,255,255,255,255,255, + 25,255,10,11,255,255,255,255,255,255,255,255, + 25,255,10,11,255,255,255,255,255,255,255,255, + 25,255,10,11,255,255,255,255,255,255,255,255, + 26,27,26,27,26,27,26,27,26,27,26,27, + + }, + -- 72 + { + 26,27,26,27,26,27,26,27,26,27,26,27, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 26,27,26,27,26,27,26,27,26,27,26,27, + + }, + -- 73 + { + 26,27,255,255,255,25,26,27,26,27,26,27, + 255,255,25,255,255,255,255,255,255,255,255,255, + 255,255,255,1,255,255,255,255,255,255,255,255, + 255,255,255,255,1,255,255,255,255,255,255,255, + 255,255,255,255,255,1,255,255,255,255,255,255, + 26,27,26,27,26,27,26,27,26,27,26,27, + + }, + -- 74 + { + 26,27,8,9,26,27,26,27,26,27,26,27, + 255,255,8,9,255,255,255,255,255,255,255,255, + 255,255,8,9,255,255,255,255,255,255,255,255, + 255,255,8,9,255,255,255,255,255,255,255,255, + 255,255,8,9,255,255,255,255,255,255,255,255, + 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, + 255,255,255,255,255,255,255,255,255,255,26,27, + 255,255,255,255,255,255,255,255,255,255,26,27, + 255,255,255,255,255,255,255,255,255,255,26,27, + 255,255,255,255,255,255,255,255,255,255,26,27, + 26,27,26,27,26,27,26,27,26,27,26,27, + + }, + -- 76 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 77 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 78 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 79 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, + -- 80 + { + 20,21,20,21,20,21,20,21,20,21,20,21, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255, + 20,21,20,21,20,21,20,21,20,21,20,21, + + }, +} diff --git a/mapa.lua b/mapa.lua new file mode 100644 index 0000000..66bacb2 --- /dev/null +++ b/mapa.lua @@ -0,0 +1,93 @@ +--mapa={} +tiletype={void=0,stair=1,half=2,block=3} + +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=255 + 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 + +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~=255 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_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<16 then + return tiletype.stair + elseif tile<64 then + return tiletype.block + else + return tiletype.void + end +end diff --git a/score.lua b/score.lua new file mode 100644 index 0000000..1322243 --- /dev/null +++ b/score.lua @@ -0,0 +1,34 @@ +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("2022",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) +end \ No newline at end of file diff --git a/tiles.gif b/tiles.gif new file mode 100644 index 0000000000000000000000000000000000000000..e36cd321674e648858df94ead17a3f491f3314f5 GIT binary patch literal 3151 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 AF8}}l literal 0 HcmV?d00001 diff --git a/zombie.lua b/zombie.lua new file mode 100644 index 0000000..093a351 --- /dev/null +++ b/zombie.lua @@ -0,0 +1,72 @@ +zombie={} + +function zombie:new() + return {hab=2,x=24,y=24,flip=false,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() + sspr((self.frame&7)*16,(self.frame>>3)*16,16,16,self.x,self.y,16,16,self.flip) +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)0 then abad.energia=abad.energia-1 end + cls(3) + 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=7 + 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