- [NEW] Cada sprite pot usar el seu propi gif
- [NEW] Monedes
@@ -44,45 +44,54 @@ animations = {
|
|||||||
["bullet"] = {
|
["bullet"] = {
|
||||||
cycle = {1},
|
cycle = {1},
|
||||||
frames = {
|
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"] = {
|
["mummy_walk"] = {
|
||||||
cycle = {1,2,1,3},
|
cycle = {1,2,1,3},
|
||||||
frames = {
|
frames = {
|
||||||
{ frame={x=0,y=24,w=16,h=16}, wait=4 },
|
{ frame={x=0,y=0,w=16,h=16}, wait=4 },
|
||||||
{ frame={x=16,y=24,w=16,h=16}, wait=4 },
|
{ frame={x=16,y=0,w=16,h=16}, wait=4 },
|
||||||
{ frame={x=32,y=24,w=16,h=16}, wait=4 }
|
{ frame={x=32,y=0,w=16,h=16}, wait=4 }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
["mummy_dying"] = {
|
["mummy_dying"] = {
|
||||||
cycle = {1,2,3,4,5,6,7,6},
|
cycle = {1,2,3,4,5,6,7,6},
|
||||||
frames = {
|
frames = {
|
||||||
{ frame={x=48,y=24,w=16,h=16}, wait=2 },
|
{ frame={x=48,y=0,w=16,h=16}, wait=2 },
|
||||||
{ frame={x=64,y=24,w=16,h=16}, wait=2 },
|
{ frame={x=64,y=0,w=16,h=16}, wait=2 },
|
||||||
{ frame={x=80,y=24,w=16,h=16}, wait=2 },
|
{ frame={x=80,y=0,w=16,h=16}, wait=2 },
|
||||||
{ frame={x=96,y=24,w=16,h=16}, wait=2 },
|
{ frame={x=96,y=0,w=16,h=16}, wait=2 },
|
||||||
{ frame={x=112,y=24,w=16,h=16}, wait=2 },
|
{ frame={x=112,y=0,w=16,h=16}, wait=2 },
|
||||||
{ frame={x=128,y=24,w=16,h=16}, wait=4 },
|
{ frame={x=128,y=0,w=16,h=16}, wait=4 },
|
||||||
{ frame={x=144,y=24,w=16,h=16}, wait=2 }
|
{ frame={x=144,y=0,w=16,h=16}, wait=2 }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
["mummy_dead"] = {
|
["mummy_dead"] = {
|
||||||
cycle = {1},
|
cycle = {1},
|
||||||
frames = {
|
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"] = {
|
["mummy_undying"] = {
|
||||||
cycle = {7,6,7,6,7,6,7,6,5,4,3,2,1},
|
cycle = {7,6,7,6,7,6,7,6,5,4,3,2,1},
|
||||||
frames = {
|
frames = {
|
||||||
{ frame={x=48,y=24,w=16,h=16}, wait=2 },
|
{ frame={x=48,y=0,w=16,h=16}, wait=2 },
|
||||||
{ frame={x=64,y=24,w=16,h=16}, wait=2 },
|
{ frame={x=64,y=0,w=16,h=16}, wait=2 },
|
||||||
{ frame={x=80,y=24,w=16,h=16}, wait=2 },
|
{ frame={x=80,y=0,w=16,h=16}, wait=2 },
|
||||||
{ frame={x=96,y=24,w=16,h=16}, wait=2 },
|
{ frame={x=96,y=0,w=16,h=16}, wait=2 },
|
||||||
{ frame={x=112,y=24,w=16,h=16}, wait=2 },
|
{ frame={x=112,y=0,w=16,h=16}, wait=2 },
|
||||||
{ frame={x=128,y=24,w=16,h=16}, wait=1 },
|
{ frame={x=128,y=0,w=16,h=16}, wait=1 },
|
||||||
{ frame={x=128,y=40,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 }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ items = {
|
|||||||
visual = {x=0,y=24,w=16,h=16}
|
visual = {x=0,y=24,w=16,h=16}
|
||||||
},
|
},
|
||||||
[2] = {
|
[2] = {
|
||||||
name="mummy2",
|
name="coin",
|
||||||
visual = {x=16,y=24,w=16,h=16}
|
visual = {x=0,y=40,w=8,h=8}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BIN
data/misc.gif
Normal file
|
After Width: | Height: | Size: 671 B |
BIN
data/morcus.gif
Normal file
|
After Width: | Height: | Size: 812 B |
BIN
data/mummy.gif
Normal file
|
After Width: | Height: | Size: 654 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1001 B After Width: | Height: | Size: 1004 B |
BIN
data/sprites.gif
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.8 KiB |
@@ -54,6 +54,7 @@ sprites = {
|
|||||||
current_frame = 1,
|
current_frame = 1,
|
||||||
current_wait = 1,
|
current_wait = 1,
|
||||||
flipped = false,
|
flipped = false,
|
||||||
|
surf = surf.load("morcus.gif"),
|
||||||
animation = "hero_stand",
|
animation = "hero_stand",
|
||||||
ia = sprites.update_hero,
|
ia = sprites.update_hero,
|
||||||
jumping = 0,
|
jumping = 0,
|
||||||
@@ -185,6 +186,22 @@ sprites = {
|
|||||||
end
|
end
|
||||||
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 = function()
|
||||||
-- Update hero
|
-- Update hero
|
||||||
local anim = "hero_stand"
|
local anim = "hero_stand"
|
||||||
@@ -319,7 +336,6 @@ sprites = {
|
|||||||
draw = function(ignore_selected)
|
draw = function(ignore_selected)
|
||||||
editor.item_hovered = nil
|
editor.item_hovered = nil
|
||||||
local mx,my = mouse.pos()
|
local mx,my = mouse.pos()
|
||||||
surf.source(surf_sprites)
|
|
||||||
if editor.item_selected or editor.layer~=LAYER_ITEMS then ignore_selected = true end
|
if editor.item_selected or editor.layer~=LAYER_ITEMS then ignore_selected = true end
|
||||||
for i,v in ipairs(sprites.list) do
|
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
|
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)
|
print(sprite.current_frame)
|
||||||
end
|
end
|
||||||
local reversed = frame.reversed or false
|
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))
|
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)
|
local x,y,w,h = util.aabb(sprite)
|
||||||
--draw.rect(x,y,w,h,8)
|
--draw.rect(x,y,w,h,8)
|
||||||
@@ -351,6 +368,7 @@ sprites = {
|
|||||||
local frame = animations[sprite.animation].frames[cycle]
|
local frame = animations[sprite.animation].frames[cycle]
|
||||||
local reversed = frame.reversed or false
|
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)
|
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-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, y-1, w, h, f)
|
||||||
draw.surf(sx, sy, w, h, x+1, y-1, w, h, f)
|
draw.surf(sx, sy, w, h, x+1, y-1, w, h, f)
|
||||||
|
|||||||
@@ -10,11 +10,12 @@ templates = {
|
|||||||
sprite = {
|
sprite = {
|
||||||
type = type,
|
type = type,
|
||||||
pos = options.pos,--{ x=100, y=4*12*8+71 },
|
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 },
|
bbo = { left=3, top=2, right=3, bottom=0 },
|
||||||
current_frame = 1,
|
current_frame = 1,
|
||||||
current_wait = 1,
|
current_wait = 1,
|
||||||
flipped = options.flipped,
|
flipped = options.flipped,
|
||||||
|
surf = surf.load("mummy.gif"),
|
||||||
animation = "mummy_walk",
|
animation = "mummy_walk",
|
||||||
state = templates.ALIVE,
|
state = templates.ALIVE,
|
||||||
enemy = true,
|
enemy = true,
|
||||||
@@ -30,9 +31,23 @@ templates = {
|
|||||||
current_frame = 1,
|
current_frame = 1,
|
||||||
current_wait = 1,
|
current_wait = 1,
|
||||||
flipped = options.flipped,
|
flipped = options.flipped,
|
||||||
|
surf = surf.load("morcus.gif"),
|
||||||
animation = "bullet",
|
animation = "bullet",
|
||||||
ia = sprites.update_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
|
else
|
||||||
error("Template not recognized")
|
error("Template not recognized")
|
||||||
end
|
end
|
||||||
|
|||||||