- [NEW] Animació de moneda agafada
- [NEW] Agafar monedes augmenta el marcador - [NEW] Marcador bàsic visible - [NEW] Al cambiar d'habitació es manté el efecte d'iluminació. A més, va un poc més lento - [NEW] Al agafar moneda, no torna al eixir i entrar. Al tornar al editor se recupera. - [NEW] Gestió de l'iluminació fora dels update i dins dels draw - [NEW] Afegides més habitacions
This commit is contained in:
@@ -58,6 +58,9 @@ sprites = {
|
||||
animation = "hero_stand",
|
||||
ia = sprites.update_hero,
|
||||
jumping = 0,
|
||||
light = 100,
|
||||
light_ox = 0,
|
||||
light_oy = 0,
|
||||
stairs = false
|
||||
}
|
||||
--table.insert(sprites.list, templates.create("mummy", {pos={x=100, y=4*12*8+71},flipped=true}))
|
||||
@@ -95,9 +98,6 @@ sprites = {
|
||||
update = function()
|
||||
if not sys.beat() then return end
|
||||
|
||||
surf.target(game.circ_buf)
|
||||
surf.cls()
|
||||
|
||||
sprites.update_sprite(sprites.hero)
|
||||
for i,v in ipairs(sprites.list) do
|
||||
sprites.update_sprite(v)
|
||||
@@ -191,23 +191,37 @@ sprites = {
|
||||
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
|
||||
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)
|
||||
|
||||
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.points = score.points + 10
|
||||
return
|
||||
end
|
||||
--end
|
||||
--end
|
||||
elseif spr.state == templates.DYING then
|
||||
spr.pos.y = spr.pos.y - 0.5
|
||||
spr.timer = spr.timer + 1
|
||||
if spr.timer == 32 then
|
||||
sprites.remove(spr)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
update_hero = function()
|
||||
game.draw_light(sprites.hero.pos.x, sprites.hero.pos.y,100)
|
||||
--game.draw_light(sprites.hero.pos.x, sprites.hero.pos.y,100)
|
||||
|
||||
-- Update hero
|
||||
local anim = "hero_stand"
|
||||
@@ -342,6 +356,12 @@ sprites = {
|
||||
end,
|
||||
|
||||
draw = function(ignore_selected)
|
||||
if app.update ~= editor.update then
|
||||
surf.target(game.circ_buf)
|
||||
surf.cls()
|
||||
surf.target(game.back_buf)
|
||||
end
|
||||
|
||||
editor.item_hovered = nil
|
||||
local mx,my = mouse.pos()
|
||||
if editor.item_selected or editor.layer~=LAYER_ITEMS then ignore_selected = true end
|
||||
@@ -365,8 +385,11 @@ sprites = {
|
||||
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)
|
||||
--local x,y,w,h = util.aabb(sprite)
|
||||
--draw.rect(x,y,w,h,8)
|
||||
if (app.update ~= editor.update) and (sprite.light) then
|
||||
game.draw_light(sprite.pos.x+sprite.light_ox, sprite.pos.y+sprite.light_oy,sprite.light)
|
||||
end
|
||||
end,
|
||||
|
||||
draw_sprite_selected = function(sprite)
|
||||
|
||||
Reference in New Issue
Block a user