- [NEW] Claus i portes funcionant
@@ -130,4 +130,39 @@ animations = {
|
|||||||
{ frame={x=24,y=0,w=8,h=16}, wait=2 }
|
{ frame={x=24,y=0,w=8,h=16}, wait=2 }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
["clau"] = {
|
||||||
|
cycle = {1},
|
||||||
|
loop = false,
|
||||||
|
frames = {
|
||||||
|
{ frame={x=0,y=0,w=16,h=8}, wait=100 },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
["porta"] = {
|
||||||
|
cycle = {1},
|
||||||
|
loop = false,
|
||||||
|
frames = {
|
||||||
|
{ frame={x=16,y=0,w=8,h=16}, wait=100 },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
["porta_obrint"] = {
|
||||||
|
cycle = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},
|
||||||
|
loop = false,
|
||||||
|
frames = {
|
||||||
|
{ frame={x=16,y=1,w=8,h=15}, wait=1 },
|
||||||
|
{ frame={x=16,y=2,w=8,h=14}, wait=1 },
|
||||||
|
{ frame={x=16,y=3,w=8,h=13}, wait=1 },
|
||||||
|
{ frame={x=16,y=4,w=8,h=12}, wait=1 },
|
||||||
|
{ frame={x=16,y=5,w=8,h=11}, wait=1 },
|
||||||
|
{ frame={x=16,y=6,w=8,h=10}, wait=1 },
|
||||||
|
{ frame={x=16,y=7,w=8,h=9}, wait=1 },
|
||||||
|
{ frame={x=16,y=8,w=8,h=8}, wait=1 },
|
||||||
|
{ frame={x=16,y=9,w=8,h=7}, wait=1 },
|
||||||
|
{ frame={x=16,y=10,w=8,h=6}, wait=1 },
|
||||||
|
{ frame={x=16,y=11,w=8,h=5}, wait=1 },
|
||||||
|
{ frame={x=16,y=12,w=8,h=4}, wait=1 },
|
||||||
|
{ frame={x=16,y=13,w=8,h=3}, wait=1 },
|
||||||
|
{ frame={x=16,y=14,w=8,h=2}, wait=1 },
|
||||||
|
{ frame={x=16,y=15,w=8,h=1}, wait=1 },
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
BIN
data/blava.gif
Normal file
|
After Width: | Height: | Size: 234 B |
@@ -299,9 +299,13 @@ editor = {
|
|||||||
local mx, my = mouse.pos()
|
local mx, my = mouse.pos()
|
||||||
local x,y = 0,0
|
local x,y = 0,0
|
||||||
for i,k in pairs(items) do
|
for i,k in pairs(items) do
|
||||||
local w = math.max(k.visual.w, #k.name*4)
|
local w = math.max(k.visual.w, #k.label*4)
|
||||||
|
if x+w > 160 then
|
||||||
|
y=y+32
|
||||||
|
x=0
|
||||||
|
end
|
||||||
local ox = (w-k.visual.w)/2
|
local ox = (w-k.visual.w)/2
|
||||||
draw.text(k.name, x, y, 15)
|
draw.text(k.label, x, y, 15)
|
||||||
draw.surf(k.visual.x, k.visual.y, k.visual.w, k.visual.h, x+ox, y+7)
|
draw.surf(k.visual.x, k.visual.y, k.visual.w, k.visual.h, x+ox, y+7)
|
||||||
if mx>x and mx<x+w and my>y and my<y+7+k.visual.h then
|
if mx>x and mx<x+w and my>y and my<y+7+k.visual.h then
|
||||||
draw.rect(x+ox, y+7, k.visual.w, k.visual.h, 28)
|
draw.rect(x+ox, y+7, k.visual.w, k.visual.h, 28)
|
||||||
|
|||||||
BIN
data/groga.gif
Normal file
|
After Width: | Height: | Size: 234 B |
@@ -1,14 +1,57 @@
|
|||||||
items = {
|
items = {
|
||||||
[1] = {
|
[1] = {
|
||||||
name="mummy",
|
name="mummy",
|
||||||
|
label="momia",
|
||||||
visual = {x=0,y=24,w=16,h=16}
|
visual = {x=0,y=24,w=16,h=16}
|
||||||
},
|
},
|
||||||
[2] = {
|
[2] = {
|
||||||
name="coin",
|
name="coin",
|
||||||
|
label="moneda",
|
||||||
visual = {x=0,y=40,w=8,h=8}
|
visual = {x=0,y=40,w=8,h=8}
|
||||||
},
|
},
|
||||||
[3] = {
|
[3] = {
|
||||||
name="torxa",
|
name="torxa",
|
||||||
|
label="torxa",
|
||||||
visual = {x=0,y=48,w=8,h=16}
|
visual = {x=0,y=48,w=8,h=16}
|
||||||
}
|
},
|
||||||
|
[4] = {
|
||||||
|
name="clau verda",
|
||||||
|
label="clau",
|
||||||
|
visual = {x=16,y=48,w=16,h=8}
|
||||||
|
},
|
||||||
|
[5] = {
|
||||||
|
name="clau groga",
|
||||||
|
label="clau",
|
||||||
|
visual = {x=16,y=56,w=16,h=8}
|
||||||
|
},
|
||||||
|
[6] = {
|
||||||
|
name="clau roja",
|
||||||
|
label="clau",
|
||||||
|
visual = {x=32,y=48,w=16,h=8}
|
||||||
|
},
|
||||||
|
[7] = {
|
||||||
|
name="clau blava",
|
||||||
|
label="clau",
|
||||||
|
visual = {x=32,y=56,w=16,h=8}
|
||||||
|
},
|
||||||
|
[8] = {
|
||||||
|
name="porta verda",
|
||||||
|
label="porta",
|
||||||
|
visual = {x=48,y=48,w=8,h=16}
|
||||||
|
},
|
||||||
|
[9] = {
|
||||||
|
name="porta groga",
|
||||||
|
label="porta",
|
||||||
|
visual = {x=56,y=48,w=8,h=16}
|
||||||
|
},
|
||||||
|
[10] = {
|
||||||
|
name="porta roja",
|
||||||
|
label="porta",
|
||||||
|
visual = {x=64,y=48,w=8,h=16}
|
||||||
|
},
|
||||||
|
[11] = {
|
||||||
|
name="porta blava",
|
||||||
|
label="porta",
|
||||||
|
visual = {x=72,y=48,w=8,h=16}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
BIN
data/misc.gif
|
Before Width: | Height: | Size: 724 B After Width: | Height: | Size: 1.1 KiB |
BIN
data/roja.gif
Normal file
|
After Width: | Height: | Size: 234 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
@@ -2,14 +2,21 @@ score = {
|
|||||||
points = 0,
|
points = 0,
|
||||||
color = 28,
|
color = 28,
|
||||||
zoom = 1,
|
zoom = 1,
|
||||||
|
surf = nil,
|
||||||
|
|
||||||
init = function()
|
init = function()
|
||||||
score.points = 0
|
score.points = 0
|
||||||
|
score.surf = surf.load("sprites.gif")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
draw = function()
|
draw = function()
|
||||||
draw.rectf(0,0,160,8,1)
|
draw.rectf(0,0,160,8,1)
|
||||||
draw.text(string.format("%03d", score.points),0,0,score.color)
|
draw.text(string.format("%03d", score.points),1,1,score.color)
|
||||||
|
surf.source(score.surf)
|
||||||
|
if sprites.hero.keys["verda"] then draw.surf(16,48,16,8, 32,-1) end
|
||||||
|
if sprites.hero.keys["groga"] then draw.surf(16,56,16,8, 32,-1) end
|
||||||
|
if sprites.hero.keys["roja"] then draw.surf(32,48,16,8, 32,-1) end
|
||||||
|
if sprites.hero.keys["blava"] then draw.surf(32,56,16,8, 32,-1) end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
inc = function(value)
|
inc = function(value)
|
||||||
|
|||||||
BIN
data/sprites.gif
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.6 KiB |
@@ -65,6 +65,7 @@ sprites = {
|
|||||||
cooldown = 0,
|
cooldown = 0,
|
||||||
jump_throttle = 0,
|
jump_throttle = 0,
|
||||||
lives = 4,
|
lives = 4,
|
||||||
|
keys = {},
|
||||||
stairs = false
|
stairs = false
|
||||||
}
|
}
|
||||||
--table.insert(sprites.list, templates.create("mummy", {pos={x=100, y=4*12*8+71},flipped=true}))
|
--table.insert(sprites.list, templates.create("mummy", {pos={x=100, y=4*12*8+71},flipped=true}))
|
||||||
@@ -134,7 +135,7 @@ sprites = {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
hit_hero = function(live)
|
hero_hit = function(live)
|
||||||
live = live or sprites.hero.lives-1
|
live = live or sprites.hero.lives-1
|
||||||
local light_table = {[0]=20, 30, 50, 80, 100}
|
local light_table = {[0]=20, 30, 50, 80, 100}
|
||||||
local red_table = {[0]=0, 0.25, 0.5, 0.75, 1}
|
local red_table = {[0]=0, 0.25, 0.5, 0.75, 1}
|
||||||
@@ -164,6 +165,13 @@ sprites = {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
hero_give_key = function(color)
|
||||||
|
if sprites.hero.keys[color] then return false end
|
||||||
|
sprites.hero.keys[color] = true
|
||||||
|
tweening.add(1,0,0.25,easing.linear,function(value,n,finished)palfade.fade_white(value)end)
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
|
||||||
lights_out = function()
|
lights_out = function()
|
||||||
for i,spr in ipairs(sprites.list) do
|
for i,spr in ipairs(sprites.list) do
|
||||||
if spr.light then
|
if spr.light then
|
||||||
@@ -194,7 +202,7 @@ sprites = {
|
|||||||
local x2,y2,w2,h2 = util.aabb(sprites.hero) -- el aabb del heroi
|
local x2,y2,w2,h2 = util.aabb(sprites.hero) -- el aabb del heroi
|
||||||
-- Si toca al heroi...
|
-- Si toca al heroi...
|
||||||
if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then
|
if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then
|
||||||
sprites.hit_hero()
|
sprites.hero_hit()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -266,24 +274,20 @@ sprites = {
|
|||||||
update_coin = function(spr)
|
update_coin = function(spr)
|
||||||
if spr.state == templates.ALIVE then
|
if spr.state == templates.ALIVE then
|
||||||
local x1,y1,w1,h1 = util.aabb(spr)
|
local x1,y1,w1,h1 = util.aabb(spr)
|
||||||
--for i,v in ipairs(sprites.list) do
|
local x2,y2,w2,h2 = util.aabb(sprites.hero)
|
||||||
--if v.type == "hero" then
|
if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then
|
||||||
local x2,y2,w2,h2 = util.aabb(sprites.hero)
|
local tx, ty = (spr.pos.x)>>3, (spr.pos.y)>>3
|
||||||
if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then
|
map.surf(rooms.surf_items)
|
||||||
local tx, ty = (spr.pos.x)>>3, (spr.pos.y)>>3
|
map.tile(tx,ty,0)
|
||||||
map.surf(rooms.surf_items)
|
|
||||||
map.tile(tx,ty,0)
|
|
||||||
|
|
||||||
spr.state = templates.DYING
|
spr.state = templates.DYING
|
||||||
sprites.set_animation(spr, "coin_picked")
|
sprites.set_animation(spr, "coin_picked")
|
||||||
spr.pos.y=spr.pos.y-16
|
spr.pos.y=spr.pos.y-16
|
||||||
spr.pos.x=spr.pos.x-4
|
spr.pos.x=spr.pos.x-4
|
||||||
spr.timer = 0
|
spr.timer = 0
|
||||||
score.inc(10)
|
score.inc(10)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
--end
|
|
||||||
--end
|
|
||||||
elseif spr.state == templates.DYING then
|
elseif spr.state == templates.DYING then
|
||||||
spr.pos.y = spr.pos.y - 0.5
|
spr.pos.y = spr.pos.y - 0.5
|
||||||
spr.timer = spr.timer + 1
|
spr.timer = spr.timer + 1
|
||||||
@@ -299,7 +303,7 @@ sprites = {
|
|||||||
local x1,y1,w1,h1 = util.aabb(spr)
|
local x1,y1,w1,h1 = util.aabb(spr)
|
||||||
local x2,y2,w2,h2 = util.aabb(sprites.hero)
|
local x2,y2,w2,h2 = util.aabb(sprites.hero)
|
||||||
if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then
|
if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then
|
||||||
sprites.hit_hero(4)
|
sprites.hero_hit(4)
|
||||||
spr.state = templates.DYING
|
spr.state = templates.DYING
|
||||||
spr.timer = 0
|
spr.timer = 0
|
||||||
return
|
return
|
||||||
@@ -307,7 +311,46 @@ sprites = {
|
|||||||
elseif spr.state == templates.DYING then
|
elseif spr.state == templates.DYING then
|
||||||
spr.timer = spr.timer + 1
|
spr.timer = spr.timer + 1
|
||||||
if spr.timer == 32 then
|
if spr.timer == 32 then
|
||||||
spr.state = templates.DYING
|
spr.state = templates.ALIVE
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
update_clau = function(spr)
|
||||||
|
if spr.state == templates.ALIVE then
|
||||||
|
local x1,y1,w1,h1 = util.aabb(spr)
|
||||||
|
local x2,y2,w2,h2 = util.aabb(sprites.hero)
|
||||||
|
if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then
|
||||||
|
if sprites.hero_give_key(spr.color) then
|
||||||
|
local tx, ty = (spr.pos.x)>>3, (spr.pos.y)>>3
|
||||||
|
map.surf(rooms.surf_items)
|
||||||
|
map.tile(tx,ty,0)
|
||||||
|
sprites.remove(spr)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
update_porta = function(spr)
|
||||||
|
if spr.state == templates.ALIVE then
|
||||||
|
local x1,y1,w1,h1 = util.aabb(spr)
|
||||||
|
local x2,y2,w2,h2 = util.aabb(sprites.hero)
|
||||||
|
if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then
|
||||||
|
if sprites.hero.keys[spr.color] then
|
||||||
|
sprites.hero.keys[spr.color] = nil
|
||||||
|
sprites.set_animation(spr, "porta_obrint")
|
||||||
|
spr.state = templates.DYING
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif spr.state == templates.DYING then
|
||||||
|
if spr.current_frame == 15 then
|
||||||
|
local tx, ty = (spr.pos.x)>>3, (spr.pos.y)>>3
|
||||||
|
map.surf(rooms.surf_items)
|
||||||
|
map.tile(tx,ty,0)
|
||||||
|
map.surf(rooms.surf_foreground)
|
||||||
|
map.tile(tx,ty,0)
|
||||||
|
map.tile(tx,ty+1,0)
|
||||||
|
sprites.remove(spr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@@ -446,7 +489,7 @@ sprites = {
|
|||||||
game.change_room(0,1)
|
game.change_room(0,1)
|
||||||
else
|
else
|
||||||
if sprites.hero.pos.y >= 742 then
|
if sprites.hero.pos.y >= 742 then
|
||||||
sprites.hit_hero(0)
|
sprites.hero_hit(0)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
sprites.hero.pos.y = sprites.hero.pos.y + 2
|
sprites.hero.pos.y = sprites.hero.pos.y + 2
|
||||||
|
|||||||
@@ -6,9 +6,11 @@ templates = {
|
|||||||
|
|
||||||
create = function(type, options)
|
create = function(type, options)
|
||||||
local sprite
|
local sprite
|
||||||
if type == "mummy" then
|
local key, value = type:match("^(%S+)%s*(.*)$")
|
||||||
|
|
||||||
|
if key == "mummy" then
|
||||||
sprite = {
|
sprite = {
|
||||||
type = type,
|
type = key,
|
||||||
pos = options.pos,--{ x=100, y=4*12*8+71 },
|
pos = options.pos,--{ x=100, y=4*12*8+71 },
|
||||||
size = { w=16,h=16 },
|
size = { w=16,h=16 },
|
||||||
bbo = { left=3, top=2, right=3, bottom=0 },
|
bbo = { left=3, top=2, right=3, bottom=0 },
|
||||||
@@ -22,9 +24,9 @@ templates = {
|
|||||||
room = options.room,
|
room = options.room,
|
||||||
ia = sprites.update_mummy
|
ia = sprites.update_mummy
|
||||||
}
|
}
|
||||||
elseif type == "bullet" then
|
elseif key == "bullet" then
|
||||||
sprite = {
|
sprite = {
|
||||||
type = type,
|
type = key,
|
||||||
pos = options.pos,--{ x=100, y=4*12*8+71 },
|
pos = options.pos,--{ x=100, y=4*12*8+71 },
|
||||||
size = { w=4,h=3 },
|
size = { w=4,h=3 },
|
||||||
bbo = { left=0, top=0, right=0, bottom=0 },
|
bbo = { left=0, top=0, right=0, bottom=0 },
|
||||||
@@ -35,9 +37,9 @@ templates = {
|
|||||||
animation = "bullet",
|
animation = "bullet",
|
||||||
ia = sprites.update_bullet
|
ia = sprites.update_bullet
|
||||||
}
|
}
|
||||||
elseif type == "coin" then
|
elseif key == "coin" then
|
||||||
sprite = {
|
sprite = {
|
||||||
type = type,
|
type = key,
|
||||||
pos = options.pos,--{ x=100, y=4*12*8+71 },
|
pos = options.pos,--{ x=100, y=4*12*8+71 },
|
||||||
size = { w=8,h=8 },
|
size = { w=8,h=8 },
|
||||||
bbo = { left=0, top=0, right=0, bottom=0 },
|
bbo = { left=0, top=0, right=0, bottom=0 },
|
||||||
@@ -52,9 +54,9 @@ templates = {
|
|||||||
light_oy = 4,
|
light_oy = 4,
|
||||||
ia = sprites.update_coin
|
ia = sprites.update_coin
|
||||||
}
|
}
|
||||||
elseif type == "brick" then
|
elseif key == "brick" then
|
||||||
sprite = {
|
sprite = {
|
||||||
type = type,
|
type = key,
|
||||||
pos = options.pos,--{ x=100, y=4*12*8+71 },
|
pos = options.pos,--{ x=100, y=4*12*8+71 },
|
||||||
size = { w=8,h=8 },
|
size = { w=8,h=8 },
|
||||||
bbo = { left=0, top=0, right=0, bottom=0 },
|
bbo = { left=0, top=0, right=0, bottom=0 },
|
||||||
@@ -67,9 +69,9 @@ templates = {
|
|||||||
timeout = 10,
|
timeout = 10,
|
||||||
ia = sprites.update_brick
|
ia = sprites.update_brick
|
||||||
}
|
}
|
||||||
elseif type == "torxa" then
|
elseif key == "torxa" then
|
||||||
sprite = {
|
sprite = {
|
||||||
type = type,
|
type = key,
|
||||||
pos = options.pos,--{ x=100, y=4*12*8+71 },
|
pos = options.pos,--{ x=100, y=4*12*8+71 },
|
||||||
size = { w=8,h=16 },
|
size = { w=8,h=16 },
|
||||||
bbo = { left=0, top=0, right=0, bottom=0 },
|
bbo = { left=0, top=0, right=0, bottom=0 },
|
||||||
@@ -85,6 +87,39 @@ templates = {
|
|||||||
no_shadow = true,
|
no_shadow = true,
|
||||||
ia = sprites.update_torxa
|
ia = sprites.update_torxa
|
||||||
}
|
}
|
||||||
|
elseif key == "clau" then
|
||||||
|
sprite = {
|
||||||
|
type = key,
|
||||||
|
color = value,
|
||||||
|
pos = options.pos,--{ x=100, y=4*12*8+71 },
|
||||||
|
size = { w=16,h=8 },
|
||||||
|
bbo = { left=0, top=0, right=0, bottom=0 },
|
||||||
|
current_frame = 1,
|
||||||
|
current_wait = 1,
|
||||||
|
flipped = options.flipped,
|
||||||
|
surf = surf.load(value..".gif"),
|
||||||
|
animation = "clau",
|
||||||
|
state = templates.ALIVE,
|
||||||
|
light = 15,
|
||||||
|
light_ox = 7,
|
||||||
|
light_oy = 4,
|
||||||
|
ia = sprites.update_clau
|
||||||
|
}
|
||||||
|
elseif key == "porta" then
|
||||||
|
sprite = {
|
||||||
|
type = key,
|
||||||
|
color = value,
|
||||||
|
pos = options.pos,--{ x=100, y=4*12*8+71 },
|
||||||
|
size = { w=8,h=16 },
|
||||||
|
bbo = { left=0, top=0, right=0, bottom=0 },
|
||||||
|
current_frame = 1,
|
||||||
|
current_wait = 1,
|
||||||
|
flipped = options.flipped,
|
||||||
|
surf = surf.load(value..".gif"),
|
||||||
|
animation = "porta",
|
||||||
|
state = templates.ALIVE,
|
||||||
|
ia = sprites.update_porta
|
||||||
|
}
|
||||||
else
|
else
|
||||||
error("Template not recognized")
|
error("Template not recognized")
|
||||||
end
|
end
|
||||||
|
|||||||
BIN
data/verda.gif
Normal file
|
After Width: | Height: | Size: 234 B |