diff --git a/data/animations.lua b/data/animations.lua index 4894f54..68da322 100644 --- a/data/animations.lua +++ b/data/animations.lua @@ -44,45 +44,54 @@ animations = { ["bullet"] = { cycle = {1}, frames = { - { frame={x=0,y=19,w=4,h=3}, wait=4 } + { frame={x=156,y=0,w=4,h=3}, wait=4 } } }, ["mummy_walk"] = { cycle = {1,2,1,3}, frames = { - { frame={x=0,y=24,w=16,h=16}, wait=4 }, - { frame={x=16,y=24,w=16,h=16}, wait=4 }, - { frame={x=32,y=24,w=16,h=16}, wait=4 } + { frame={x=0,y=0,w=16,h=16}, wait=4 }, + { frame={x=16,y=0,w=16,h=16}, wait=4 }, + { frame={x=32,y=0,w=16,h=16}, wait=4 } } }, ["mummy_dying"] = { cycle = {1,2,3,4,5,6,7,6}, frames = { - { frame={x=48,y=24,w=16,h=16}, wait=2 }, - { frame={x=64,y=24,w=16,h=16}, wait=2 }, - { frame={x=80,y=24,w=16,h=16}, wait=2 }, - { frame={x=96,y=24,w=16,h=16}, wait=2 }, - { frame={x=112,y=24,w=16,h=16}, wait=2 }, - { frame={x=128,y=24,w=16,h=16}, wait=4 }, - { frame={x=144,y=24,w=16,h=16}, wait=2 } + { frame={x=48,y=0,w=16,h=16}, wait=2 }, + { frame={x=64,y=0,w=16,h=16}, wait=2 }, + { frame={x=80,y=0,w=16,h=16}, wait=2 }, + { frame={x=96,y=0,w=16,h=16}, wait=2 }, + { frame={x=112,y=0,w=16,h=16}, wait=2 }, + { frame={x=128,y=0,w=16,h=16}, wait=4 }, + { frame={x=144,y=0,w=16,h=16}, wait=2 } } }, ["mummy_dead"] = { cycle = {1}, frames = { - { frame={x=128,y=24,w=16,h=16}, wait=100 }, + { frame={x=128,y=0,w=16,h=16}, wait=100 }, } }, ["mummy_undying"] = { cycle = {7,6,7,6,7,6,7,6,5,4,3,2,1}, frames = { - { frame={x=48,y=24,w=16,h=16}, wait=2 }, - { frame={x=64,y=24,w=16,h=16}, wait=2 }, - { frame={x=80,y=24,w=16,h=16}, wait=2 }, - { frame={x=96,y=24,w=16,h=16}, wait=2 }, - { frame={x=112,y=24,w=16,h=16}, wait=2 }, - { frame={x=128,y=24,w=16,h=16}, wait=1 }, - { frame={x=128,y=40,w=16,h=16}, wait=1 } + { frame={x=48,y=0,w=16,h=16}, wait=2 }, + { frame={x=64,y=0,w=16,h=16}, wait=2 }, + { frame={x=80,y=0,w=16,h=16}, wait=2 }, + { frame={x=96,y=0,w=16,h=16}, wait=2 }, + { frame={x=112,y=0,w=16,h=16}, wait=2 }, + { frame={x=128,y=0,w=16,h=16}, wait=1 }, + { frame={x=160,y=0,w=16,h=16}, wait=1 } + } + }, + ["coin"] = { + cycle = {1,2,3,4,3,2}, + frames = { + { frame={x=0,y=0,w=8,h=8}, wait=2 }, + { frame={x=8,y=0,w=8,h=8}, wait=2 }, + { frame={x=16,y=0,w=8,h=8}, wait=2 }, + { frame={x=24,y=0,w=8,h=8}, wait=2 } } }, } \ No newline at end of file diff --git a/data/items.lua b/data/items.lua index 6d383a6..f47e582 100644 --- a/data/items.lua +++ b/data/items.lua @@ -4,7 +4,7 @@ items = { visual = {x=0,y=24,w=16,h=16} }, [2] = { - name="mummy2", - visual = {x=16,y=24,w=16,h=16} + name="coin", + visual = {x=0,y=40,w=8,h=8} } } \ No newline at end of file diff --git a/data/misc.gif b/data/misc.gif new file mode 100644 index 0000000..9dab1d4 Binary files /dev/null and b/data/misc.gif differ diff --git a/data/morcus.gif b/data/morcus.gif new file mode 100644 index 0000000..045fae0 Binary files /dev/null and b/data/morcus.gif differ diff --git a/data/mummy.gif b/data/mummy.gif new file mode 100644 index 0000000..dc57991 Binary files /dev/null and b/data/mummy.gif differ diff --git a/data/rooms_background.gif b/data/rooms_background.gif index 7b15853..9031773 100644 Binary files a/data/rooms_background.gif and b/data/rooms_background.gif differ diff --git a/data/rooms_foreground.gif b/data/rooms_foreground.gif index 3f54985..2684d08 100644 Binary files a/data/rooms_foreground.gif and b/data/rooms_foreground.gif differ diff --git a/data/rooms_items.gif b/data/rooms_items.gif index b870048..41feab0 100644 Binary files a/data/rooms_items.gif and b/data/rooms_items.gif differ diff --git a/data/sprites.gif b/data/sprites.gif index 4a95694..774e8a8 100644 Binary files a/data/sprites.gif and b/data/sprites.gif differ diff --git a/data/sprites.lua b/data/sprites.lua index f7ee8a6..903f924 100644 --- a/data/sprites.lua +++ b/data/sprites.lua @@ -54,6 +54,7 @@ sprites = { current_frame = 1, current_wait = 1, flipped = false, + surf = surf.load("morcus.gif"), animation = "hero_stand", ia = sprites.update_hero, jumping = 0, @@ -185,6 +186,22 @@ sprites = { end end, + update_coin = function(spr) + local tx, ty = (spr.pos.x)>>3, (spr.pos.y)>>3 + + local x1,y1,w1,h1 = util.aabb(spr) + for i,v in ipairs(sprites.list) do + if v.enemy and v.state ~= templates.DEAD then + local x2,y2,w2,h2 = util.aabb(v) + if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then + if v.state == templates.ALIVE then v.state = templates.DYING end + sprites.remove(spr) + return + end + end + end + end, + update_hero = function() -- Update hero local anim = "hero_stand" @@ -319,7 +336,6 @@ sprites = { draw = function(ignore_selected) editor.item_hovered = nil local mx,my = mouse.pos() - surf.source(surf_sprites) if editor.item_selected or editor.layer~=LAYER_ITEMS then ignore_selected = true end for i,v in ipairs(sprites.list) do if not ignore_selected and app.update == editor.update and mx>=v.pos.x and mx<=v.pos.x+v.size.w and my>=v.pos.y and my<=v.pos.y+v.size.h then @@ -339,6 +355,7 @@ sprites = { print(sprite.current_frame) end local reversed = frame.reversed or false + surf.source(sprite.surf) draw.surf(frame.frame.x, frame.frame.y, frame.frame.w, frame.frame.h, sprite.pos.x, sprite.pos.y, frame.frame.w, frame.frame.h, (not reversed) ~= (not sprite.flipped)) local x,y,w,h = util.aabb(sprite) --draw.rect(x,y,w,h,8) @@ -351,6 +368,7 @@ sprites = { local frame = animations[sprite.animation].frames[cycle] local reversed = frame.reversed or false local x, y, w, h, sx, sy, f = sprite.pos.x, sprite.pos.y, frame.frame.w, frame.frame.h, frame.frame.x, frame.frame.y, (not reversed) ~= (not sprite.flipped) + surf.source(sprite.surf) draw.surf(sx, sy, w, h, x-1, y-1, w, h, f) draw.surf(sx, sy, w, h, x, y-1, w, h, f) draw.surf(sx, sy, w, h, x+1, y-1, w, h, f) diff --git a/data/templates.lua b/data/templates.lua index 6cad3bf..031b283 100644 --- a/data/templates.lua +++ b/data/templates.lua @@ -10,11 +10,12 @@ templates = { sprite = { type = type, pos = options.pos,--{ x=100, y=4*12*8+71 }, - size = { w=16,h=17 }, + size = { w=16,h=16 }, bbo = { left=3, top=2, right=3, bottom=0 }, current_frame = 1, current_wait = 1, flipped = options.flipped, + surf = surf.load("mummy.gif"), animation = "mummy_walk", state = templates.ALIVE, enemy = true, @@ -30,9 +31,23 @@ templates = { current_frame = 1, current_wait = 1, flipped = options.flipped, + surf = surf.load("morcus.gif"), animation = "bullet", ia = sprites.update_bullet } + elseif type == "coin" then + sprite = { + type = type, + pos = options.pos,--{ x=100, y=4*12*8+71 }, + size = { w=8,h=8 }, + bbo = { left=0, top=0, right=0, bottom=0 }, + current_frame = 1, + current_wait = 1, + flipped = options.flipped, + surf = surf.load("misc.gif"), + animation = "coin", + ia = sprites.update_coin + } else error("Template not recognized") end