- [NEW] Claus i portes funcionant
This commit is contained in:
@@ -65,6 +65,7 @@ sprites = {
|
||||
cooldown = 0,
|
||||
jump_throttle = 0,
|
||||
lives = 4,
|
||||
keys = {},
|
||||
stairs = false
|
||||
}
|
||||
--table.insert(sprites.list, templates.create("mummy", {pos={x=100, y=4*12*8+71},flipped=true}))
|
||||
@@ -134,7 +135,7 @@ sprites = {
|
||||
end
|
||||
end,
|
||||
|
||||
hit_hero = function(live)
|
||||
hero_hit = function(live)
|
||||
live = live or sprites.hero.lives-1
|
||||
local light_table = {[0]=20, 30, 50, 80, 100}
|
||||
local red_table = {[0]=0, 0.25, 0.5, 0.75, 1}
|
||||
@@ -164,6 +165,13 @@ sprites = {
|
||||
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()
|
||||
for i,spr in ipairs(sprites.list) do
|
||||
if spr.light then
|
||||
@@ -194,7 +202,7 @@ sprites = {
|
||||
local x2,y2,w2,h2 = util.aabb(sprites.hero) -- el aabb del heroi
|
||||
-- Si toca al heroi...
|
||||
if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then
|
||||
sprites.hit_hero()
|
||||
sprites.hero_hit()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -266,24 +274,20 @@ sprites = {
|
||||
update_coin = function(spr)
|
||||
if spr.state == templates.ALIVE then
|
||||
local x1,y1,w1,h1 = util.aabb(spr)
|
||||
--for i,v in ipairs(sprites.list) do
|
||||
--if v.type == "hero" then
|
||||
local x2,y2,w2,h2 = util.aabb(sprites.hero)
|
||||
if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then
|
||||
local tx, ty = (spr.pos.x)>>3, (spr.pos.y)>>3
|
||||
map.surf(rooms.surf_items)
|
||||
map.tile(tx,ty,0)
|
||||
local x2,y2,w2,h2 = util.aabb(sprites.hero)
|
||||
if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then
|
||||
local tx, ty = (spr.pos.x)>>3, (spr.pos.y)>>3
|
||||
map.surf(rooms.surf_items)
|
||||
map.tile(tx,ty,0)
|
||||
|
||||
spr.state = templates.DYING
|
||||
sprites.set_animation(spr, "coin_picked")
|
||||
spr.pos.y=spr.pos.y-16
|
||||
spr.pos.x=spr.pos.x-4
|
||||
spr.timer = 0
|
||||
score.inc(10)
|
||||
return
|
||||
end
|
||||
--end
|
||||
--end
|
||||
spr.state = templates.DYING
|
||||
sprites.set_animation(spr, "coin_picked")
|
||||
spr.pos.y=spr.pos.y-16
|
||||
spr.pos.x=spr.pos.x-4
|
||||
spr.timer = 0
|
||||
score.inc(10)
|
||||
return
|
||||
end
|
||||
elseif spr.state == templates.DYING then
|
||||
spr.pos.y = spr.pos.y - 0.5
|
||||
spr.timer = spr.timer + 1
|
||||
@@ -299,7 +303,7 @@ sprites = {
|
||||
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
|
||||
sprites.hit_hero(4)
|
||||
sprites.hero_hit(4)
|
||||
spr.state = templates.DYING
|
||||
spr.timer = 0
|
||||
return
|
||||
@@ -307,7 +311,46 @@ sprites = {
|
||||
elseif spr.state == templates.DYING then
|
||||
spr.timer = spr.timer + 1
|
||||
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,
|
||||
@@ -446,7 +489,7 @@ sprites = {
|
||||
game.change_room(0,1)
|
||||
else
|
||||
if sprites.hero.pos.y >= 742 then
|
||||
sprites.hit_hero(0)
|
||||
sprites.hero_hit(0)
|
||||
return
|
||||
end
|
||||
sprites.hero.pos.y = sprites.hero.pos.y + 2
|
||||
|
||||
Reference in New Issue
Block a user