diff --git a/data/gfx/mono.gif b/data/gfx/mono.gif new file mode 100644 index 0000000..d700cb2 Binary files /dev/null and b/data/gfx/mono.gif differ diff --git a/data/gfx/morcus.gif b/data/gfx/morcus.gif index afb6b7d..2a15b8a 100644 Binary files a/data/gfx/morcus.gif and b/data/gfx/morcus.gif differ diff --git a/data/gfx/sprites.gif b/data/gfx/sprites.gif index d4c8145..51c5f30 100644 Binary files a/data/gfx/sprites.gif and b/data/gfx/sprites.gif differ diff --git a/data/maps/rooms_background.gif b/data/maps/rooms_background.gif index 864e6f9..1c45fc8 100644 Binary files a/data/maps/rooms_background.gif and b/data/maps/rooms_background.gif differ diff --git a/data/maps/rooms_foreground.gif b/data/maps/rooms_foreground.gif index e64fdc3..334adbe 100644 Binary files a/data/maps/rooms_foreground.gif and b/data/maps/rooms_foreground.gif differ diff --git a/data/maps/rooms_items.gif b/data/maps/rooms_items.gif index 64d23fb..1697395 100644 Binary files a/data/maps/rooms_items.gif and b/data/maps/rooms_items.gif differ diff --git a/data/modules/animations.lua b/data/modules/animations.lua index 14c019f..1a22139 100644 --- a/data/modules/animations.lua +++ b/data/modules/animations.lua @@ -1,10 +1,11 @@ animations = { ["hero_stand"] = { - cycle = {1}, - loop = false, + cycle = {1,2}, + loop = true, frames = { - { frame={x=0,y=0,w=16,h=17}, wait=4 }, + { frame={x=0,y=0,w=16,h=17}, wait=100 }, + { frame={x=120,y=0,w=16,h=17}, wait=4 }, } }, ["hero_jump"] = { @@ -276,4 +277,20 @@ animations = { { frame={x=116,y=13,w=4,h=4}, wait=1 } } }, + ["mono_wait"] = { + cycle = {1,1,2,1,2,1,1,2,1,3}, + loop = true, + frames = { + { frame={x=0 ,y=0,w=16,h=16}, wait=40 }, + { frame={x=16,y=0,w=16,h=16}, wait=4 }, + { frame={x=32,y=0,w=16,h=16}, wait=80 } + } + }, + ["invisible"] = { + cycle = {1}, + loop = false, + frames = { + { frame={x=89 ,y=48,w=7,h=7}, wait=1 } + } + }, } \ No newline at end of file diff --git a/data/modules/ia/berserk.lua b/data/modules/ia/berserk.lua index 8e24cb5..e9ab2bc 100644 --- a/data/modules/ia/berserk.lua +++ b/data/modules/ia/berserk.lua @@ -9,6 +9,7 @@ function ia.update_berserk(spr) if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then sprites.hero.hit() spr.flipped = not spr.flipped + sprites.dust(spr) end end @@ -20,6 +21,7 @@ function ia.update_berserk(spr) spr.pos.x = spr.pos.x - advance else spr.flipped = not spr.flipped + sprites.dust(spr) end else local tx, ty = sprites.get_tile(spr.pos.x+12), sprites.get_tile(spr.pos.y+15) @@ -27,6 +29,7 @@ function ia.update_berserk(spr) spr.pos.x = spr.pos.x + advance else spr.flipped = not spr.flipped + sprites.dust(spr) end end diff --git a/data/modules/ia/bullet.lua b/data/modules/ia/bullet.lua index a830605..8b48e9b 100644 --- a/data/modules/ia/bullet.lua +++ b/data/modules/ia/bullet.lua @@ -16,6 +16,9 @@ function ia.update_bullet(spr) v.state = templates.DYING end end + local dir = 0.1 + if spr.flipped then dir = -dir end + sprites.dust_ex(spr, {pos={x=spr.pos.x, y=spr.pos.y}, dir={x=-0.1,y=-1.2}, flipped=not spr.flipped}) sprites.remove(spr) return end @@ -35,6 +38,9 @@ function ia.update_bullet(spr) end function bullet_ricochet(spr) + local dir = 0.1 + if spr.flipped then dir = -dir end + sprites.dust_ex(spr, {pos={x=spr.pos.x, y=spr.pos.y}, dir={x=-0.1,y=-1.2}, flipped=not spr.flipped}) sprites.remove(spr) table.insert(sprites.list, templates.create("bullet_particle", {pos={x=spr.pos.x, y=spr.pos.y}, dir={x= 1,y= math.random(3,5)}, flipped=spr.flipped})) table.insert(sprites.list, templates.create("bullet_particle", {pos={x=spr.pos.x, y=spr.pos.y}, dir={x=-1,y= math.random(3,5)}, flipped=spr.flipped})) diff --git a/data/modules/ia/dimoni.lua b/data/modules/ia/dimoni.lua index acdbe0b..e79555b 100644 --- a/data/modules/ia/dimoni.lua +++ b/data/modules/ia/dimoni.lua @@ -9,6 +9,7 @@ function ia.update_dimoni(spr) if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then sprites.hero.hit() spr.flipped = not spr.flipped + sprites.dust(spr) end end @@ -18,6 +19,7 @@ function ia.update_dimoni(spr) spr.pos.x = spr.pos.x - 1 else spr.flipped = not spr.flipped + sprites.dust(spr) end else local tx, ty = sprites.get_tile(spr.pos.x+12), sprites.get_tile(spr.pos.y+15) @@ -25,6 +27,7 @@ function ia.update_dimoni(spr) spr.pos.x = spr.pos.x + 1 else spr.flipped = not spr.flipped + sprites.dust(spr) end end end diff --git a/data/modules/ia/gota.lua b/data/modules/ia/gota.lua index f7d7f1f..efa190c 100644 --- a/data/modules/ia/gota.lua +++ b/data/modules/ia/gota.lua @@ -19,6 +19,9 @@ function ia.update_gota(spr) end function gota_esguita(spr) + local dir = 0.1 + if spr.flipped then dir = -dir end + sprites.dust_ex(spr, {pos={x=spr.pos.x, y=spr.pos.y}, dir={x=-0.1,y=-1.2}, flipped=not spr.flipped}) sprites.remove(spr) table.insert(sprites.list, templates.create("gota_esguit", {pos={x=spr.pos.x, y=spr.pos.y}, dir={x= 1,y= math.random(3,5)}, flipped=spr.flipped})) table.insert(sprites.list, templates.create("gota_esguit", {pos={x=spr.pos.x, y=spr.pos.y}, dir={x=-1,y= math.random(3,5)}, flipped=spr.flipped})) diff --git a/data/modules/ia/hero.lua b/data/modules/ia/hero.lua index 8eee8a4..c4a63b2 100644 --- a/data/modules/ia/hero.lua +++ b/data/modules/ia/hero.lua @@ -92,6 +92,10 @@ function ia.update_hero() end end + local on_the_floor = false + local was_falling = sprites.hero.falling + sprites.hero.falling = false + -- SI ESTÀ BOTANT... if sprites.hero.jumping > 0 then anim = "hero_jump" @@ -156,9 +160,11 @@ function ia.update_hero() return end sprites.hero.pos.y = sprites.hero.pos.y + 2 + sprites.hero.falling = true end else -- SI NO ESTÀ CAIGUENT... + on_the_floor = true if tile_under_me1==84 then map.tile(tx1,ty+2,68) local broken_tile = templates.create("brick", {pos={x=sprites.tile_to_pixel(tx1), y=sprites.tile_to_pixel(ty+2)}, flipped=sprites.hero.flipped}) @@ -169,7 +175,7 @@ function ia.update_hero() local broken_tile = templates.create("brick", {pos={x=sprites.tile_to_pixel(tx2), y=sprites.tile_to_pixel(ty+2)}, flipped=sprites.hero.flipped}) table.insert(sprites.list, broken_tile) end - if tile_under_me1>=16 or tile_under_me1>=16 then + if tile_under_me1>=16 or tile_under_me2>=16 then sprites.hero.pos.y = sprites.tile_to_pixel(ty)-1 end anim = "hero_stand" @@ -188,16 +194,19 @@ function ia.update_hero() -- SI POLSA BOTAR... if ( key.down(key.X) or pad.down(pad.A) ) and sprites.hero.jump_throttle == 0 then sprites.hero.jumping = 17 - table.insert(sprites.list, templates.create("polseta", {pos={x=sprites.hero.pos.x+6, y=sprites.hero.pos.y+16}, dir={x=-0.7,y=-0.3}, flipped=sprites.hero.flipped})) - table.insert(sprites.list, templates.create("polseta", {pos={x=sprites.hero.pos.x+8, y=sprites.hero.pos.y+15}, dir={x=-0.5,y=-0.1}, flipped=sprites.hero.flipped})) - table.insert(sprites.list, templates.create("polseta", {pos={x=sprites.hero.pos.x+10, y=sprites.hero.pos.y+16}, dir={x=0.7,y=-0.3}, flipped=sprites.hero.flipped})) - table.insert(sprites.list, templates.create("polseta", {pos={x=sprites.hero.pos.x+12, y=sprites.hero.pos.y+15}, dir={x=0.5,y=-0.1}, flipped=sprites.hero.flipped})) + sprites.dust(sprites.hero) + ---table.insert(sprites.list, templates.create("polseta", {pos={x=sprites.hero.pos.x+6, y=sprites.hero.pos.y+16}, dir={x=-0.9,y=-0.5}, flipped=sprites.hero.flipped})) + ---table.insert(sprites.list, templates.create("polseta", {pos={x=sprites.hero.pos.x+8, y=sprites.hero.pos.y+17}, dir={x=-0.5,y=-0.7}, flipped=sprites.hero.flipped})) + ---table.insert(sprites.list, templates.create("polseta", {pos={x=sprites.hero.pos.x+10, y=sprites.hero.pos.y+16}, dir={x=0.9,y=-0.5}, flipped=sprites.hero.flipped})) + ---table.insert(sprites.list, templates.create("polseta", {pos={x=sprites.hero.pos.x+12, y=sprites.hero.pos.y+17}, dir={x=0.5,y=-0.7}, flipped=sprites.hero.flipped})) -- SI POLSA DISPAR... elseif (sprites.hero.gun_cooldown==0) and (key.down(key.Z) or pad.down(pad.B)) then sprites.hero.shooting = true sprites.hero.gun_cooldown = 20 - local bullet = templates.create("bullet", {pos={x=sprites.hero.pos.x, y=sprites.hero.pos.y+7}, flipped=sprites.hero.flipped}) + local start_x = sprites.hero.pos.x + if not sprites.hero.flipped then start_x = start_x + 16 end + local bullet = templates.create("bullet", {pos={x=start_x, y=sprites.hero.pos.y+7}, flipped=sprites.hero.flipped}) table.insert(sprites.list, bullet) anim = "hero_shoot" end @@ -206,9 +215,15 @@ function ia.update_hero() end -- ESTIGA COM ESTIGA, SI POLSA ESQUERRA O DRETA... if not sprites.hero.shooting and not sprites.hero.has_been_hit then + local was_flipped = sprites.hero.flipped + local was_standing = sprites.hero.animation == "hero_stand" if key.down(key.LEFT) or pad.down(pad.LEFT) then sprites.hero.flipped = true + if on_the_floor and (was_standing or not was_flipped) then sprites.dust(sprites.hero) end anim = move_anim + --if on_the_floor and sprites.hero.current_wait == 1 and (sprites.hero.current_frame == 1 or sprites.hero.current_frame == 3) then + -- table.insert(sprites.list, templates.create("polseta", {pos={x=sprites.hero.pos.x+10, y=sprites.hero.pos.y+16}, dir={x=0.1,y=-0.7}, flipped=sprites.hero.flipped})) + --end local tx, ty = sprites.get_tile(sprites.hero.pos.x+3), sprites.get_tile(sprites.hero.pos.y+16) if map.tile(tx,ty) < 16 and map.tile(tx,ty-1) < 16 then if txrooms.pos.x+19 then @@ -230,6 +249,14 @@ function ia.update_hero() end end end + + if (was_falling and not sprites.hero.falling) then + sprites.hero.flipped = not sprites.hero.flipped + sprites.dust(sprites.hero) + sprites.hero.flipped = not sprites.hero.flipped + sprites.dust(sprites.hero) + end + sprites.set_animation(sprites.hero, anim) end diff --git a/data/modules/ia/mummy.lua b/data/modules/ia/mummy.lua index c7d39e0..11895ff 100644 --- a/data/modules/ia/mummy.lua +++ b/data/modules/ia/mummy.lua @@ -9,6 +9,7 @@ function ia.update_mummy(spr) if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then sprites.hero.hit() spr.flipped = not spr.flipped + sprites.dust(spr) end end @@ -18,6 +19,7 @@ function ia.update_mummy(spr) spr.pos.x = spr.pos.x - 1 else spr.flipped = not spr.flipped + sprites.dust(spr) end else local tx, ty = sprites.get_tile(spr.pos.x+12), sprites.get_tile(spr.pos.y+15) @@ -25,6 +27,7 @@ function ia.update_mummy(spr) spr.pos.x = spr.pos.x + 1 else spr.flipped = not spr.flipped + sprites.dust(spr) end end elseif spr.state == templates.DYING then diff --git a/data/modules/ia/nothing.lua b/data/modules/ia/nothing.lua new file mode 100644 index 0000000..657e236 --- /dev/null +++ b/data/modules/ia/nothing.lua @@ -0,0 +1,4 @@ + +function ia.do_nothing(spr) + -- este actor no fa res +end diff --git a/data/modules/ia/porta.lua b/data/modules/ia/porta.lua index 15b02d3..cd8aac7 100644 --- a/data/modules/ia/porta.lua +++ b/data/modules/ia/porta.lua @@ -8,9 +8,15 @@ function ia.update_porta(spr) sprites.hero.keys[spr.color] = nil sprites.set_animation(spr, "porta_obrint") spr.state = templates.DYING + spr.last_frame=0 end end elseif spr.state == templates.DYING then + if spr.current_frame ~= spr.last_frame then + spr.last_frame = spr.current_frame + sprites.dust_ex(spr, {pos={x=spr.pos.x+1, y=spr.pos.y+16-spr.last_frame}, dir={x=math.random()-0.5,y=0.9}, flipped=spr.flipped}) + end + if spr.current_frame == 15 then local tx, ty = sprites.get_tile(spr.pos.x), sprites.get_tile(spr.pos.y) map.surf(rooms.surf_items) diff --git a/data/modules/items.lua b/data/modules/items.lua index 512ac3c..19d4b0e 100644 --- a/data/modules/items.lua +++ b/data/modules/items.lua @@ -21,4 +21,6 @@ items = { { name="abad", label="abad", visual={x=16, y=0, w=16, h=16} }, { name="dimoni", label="dimoni", visual={x=32, y=0, w=16, h=17} }, { name="ratpenat", label="ratpenat", visual={x=16, y=64, w=8, h=8} }, + { name="mono", label="mono", visual={x=0, y=80, w=16, h=16} }, + { name="llum", label="llum", visual={x=89, y=48, w=7, h=7} }, } diff --git a/data/modules/score.lua b/data/modules/score.lua index fe76619..ced7754 100644 --- a/data/modules/score.lua +++ b/data/modules/score.lua @@ -1,6 +1,6 @@ score = { points = 0, - color = 28, + color = 27, ypos = 3, surf = nil, font = nil @@ -14,21 +14,24 @@ function me.init(reinit) end local function draw_text() - font.current(me.font) - font.spacing(0) local txt = string.format("%03d", me.points) --- draw.text(txt,2,me.ypos-1,27) --- draw.text(txt,3,me.ypos-1,27) --- draw.text(txt,4,me.ypos-1,27) --- draw.text(txt,2,me.ypos,27) --- draw.text(txt,4,me.ypos,27) --- draw.text(txt,2,me.ypos+1,27) --- draw.text(txt,4,me.ypos+1,27) --- draw.text(txt,2,me.ypos+2,27) --- draw.text(txt,3,me.ypos+2,27) --- draw.text(txt,4,me.ypos+2,27) - draw.text(txt,3,me.ypos+1,1) - draw.text(txt,3,me.ypos,me.color) + draw.text(txt,10,me.ypos,me.color) + +-- font.current(me.font) +-- font.spacing(0) +-- draw.text(txt,2,me.ypos+2,1) +-- draw.text(txt,3,me.ypos+2,1) +-- draw.text(txt,4,me.ypos+2,1) +-- draw.text(txt,2,me.ypos-1,26) +-- draw.text(txt,3,me.ypos-1,26) +-- draw.text(txt,4,me.ypos-1,26) +-- draw.text(txt,2,me.ypos,26) +-- draw.text(txt,4,me.ypos,26) +-- draw.text(txt,2,me.ypos+1,26) +-- draw.text(txt,4,me.ypos+1,26) +---- draw.text(txt,3,me.ypos+1,1) +-- draw.text(txt,3,me.ypos,me.color) + font.current(font.DEFAULT) font.spacing(1) surf.source(me.surf) @@ -46,24 +49,30 @@ local function draw_key(sx,sy,dx,dy) end function me.draw() + local paleta = palfade.get() + palfade.restore() + if sprites.hero.state == templates.DEAD then if me.ypos > -100 then me.ypos=me.ypos-1 end end view.origin(0,0) surf.target(0) surf.clip() - + draw_text() + draw.surf(0,40,8,8, 1,1) local y = score.ypos if sprites.hero.keys["verda"] then draw_key(16,48,140,y) y=y+8 end if sprites.hero.keys["groga"] then draw_key(16,56,140,y) y=y+8 end if sprites.hero.keys["roja"] then draw_key(32,48,140,y) y=y+8 end if sprites.hero.keys["blava"] then draw_key(32,56,140,y) y=y+8 end + + palfade.set(paleta) end function me.inc(value) me.points = me.points + value - tweening.add(8, 0, 0.5, easing.linear, function(val,progress,finished) me.color = (math.floor(val)&1) == 0 and 28 or 14 end) + tweening.add(8, 0, 0.5, easing.linear, function(val,progress,finished) me.color = (math.floor(val)&1) == 0 and 27 or 14 end) tweening.add(5, 3, 0.5, easing.easeOutElastic, function(val,progress,finished) me.ypos = math.floor(val) end) end diff --git a/data/modules/sprites.lua b/data/modules/sprites.lua index 0f62007..730619c 100644 --- a/data/modules/sprites.lua +++ b/data/modules/sprites.lua @@ -43,7 +43,7 @@ end function sprites.add_from_room(rx,ry) sprites.list = {} map.surf(rooms.surf_items) - for y = ry, ry+11 do + for y = ry, ry+12 do for x = rx, rx+19 do if map.tile(x,y) ~= 0 then local room = (rx//20) + (ry//12) * 8 @@ -260,3 +260,15 @@ function sprites.draw_sprite_selected(sprite) draw.mode(draw.NORMAL) draw.surf(sx, sy, w, h, x, y, w, h, f) end + +function sprites.dust(spr) + if spr.flipped then + table.insert(sprites.list, templates.create("polseta", {pos={x=spr.pos.x+10, y=spr.pos.y+16}, dir={x=-0.1,y=-0.7}, flipped=not spr.flipped})) + else + table.insert(sprites.list, templates.create("polseta", {pos={x=spr.pos.x+4, y=spr.pos.y+16}, dir={x=-0.1,y=-0.7}, flipped=not spr.flipped})) + end +end + +function sprites.dust_ex(spr, options) + table.insert(sprites.list, templates.create("polseta", options)) +end diff --git a/data/modules/templates.lua b/data/modules/templates.lua index 3eb7f77..0850e78 100644 --- a/data/modules/templates.lua +++ b/data/modules/templates.lua @@ -345,6 +345,43 @@ function me.create(type, options) room = options.room, ia = ia.update_polseta } + elseif key == "mono" then + sprite = { + type = key, + pos = options.pos,--{ x=100, y=4*12*8+71 }, + size = { w=16,h=16 }, + bbo = { left=0, top=0, right=0, bottom=0 }, + current_frame = 1, + current_wait = 1, + flipped = options.flipped, + surf = surf.load("gfx/mono.gif"), + animation = "mono_wait", + state = me.ALIVE, + enemy = true, + bulletproof = true, + room = options.room, + ia = ia.do_nothing + } + elseif key == "llum" then + sprite = { + type = key, + pos = options.pos,--{ x=100, y=4*12*8+71 }, + size = { w=7,h=7 }, + bbo = { left=0, top=0, right=0, bottom=0 }, + current_frame = 1, + current_wait = 1, + flipped = options.flipped, + surf = surf.load("gfx/sprites.gif"), + animation = "invisible", + state = me.ALIVE, + enemy = true, + bulletproof = true, + room = options.room, + light = 40, + light_ox = 4, + light_oy = 4, + ia = ia.do_nothing + } else error("Template not recognized") end diff --git a/data/utils/palfade.lua b/data/utils/palfade.lua index bcf8652..5c7602d 100644 --- a/data/utils/palfade.lua +++ b/data/utils/palfade.lua @@ -59,3 +59,16 @@ end function me.restore() pal.set(me.original) end + +function me.get() + paleta = {} + for i=1,32 do + paleta[i] = {} + paleta[i].r, paleta[i].g, paleta[i].b = pal.color(i-1) + end + return paleta +end + +function me.set(paleta) + pal.set(paleta) +end