- [NEW] Cada sprite pot usar el seu propi gif
- [NEW] Monedes
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user