- [NEW] (EDITOR) selector de items
- [WIP] borrat i creació de items segons s'eix o entra de les habitacions - [FIX] Items indexats per número, per a poder-se guardar en un mapa - [NEW] room.current() - [NEW] resaltat del item seleccionat
This commit is contained in:
@@ -16,6 +16,19 @@ sprites = {
|
||||
end
|
||||
end,
|
||||
|
||||
remove_out_of_room = function()
|
||||
for i,v in ipairs(sprites.list) do
|
||||
if v.room ~= rooms.current() then
|
||||
table.remove(sprites.list, i)
|
||||
print("Sprite removed: "..v.type)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
add_from_room = function()
|
||||
|
||||
end,
|
||||
|
||||
init = function()
|
||||
sprites.hero = {
|
||||
type = "hero",
|
||||
@@ -287,10 +300,16 @@ sprites = {
|
||||
sprites.set_animation(sprites.hero, anim)
|
||||
end,
|
||||
|
||||
draw = function()
|
||||
draw = function(ignore_selected)
|
||||
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
|
||||
sprites.draw_sprite(v)
|
||||
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
|
||||
sprites.draw_sprite_selected(v)
|
||||
else
|
||||
sprites.draw_sprite(v)
|
||||
end
|
||||
end
|
||||
sprites.draw_sprite(sprites.hero)
|
||||
end,
|
||||
@@ -305,5 +324,24 @@ sprites = {
|
||||
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)
|
||||
end,
|
||||
|
||||
draw_sprite_selected = function(sprite)
|
||||
pal.subpal(0,32,28)
|
||||
|
||||
local cycle = animations[sprite.animation].cycle[sprite.current_frame]
|
||||
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)
|
||||
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)
|
||||
draw.surf(sx, sy, w, h, x-1, y, w, h, f)
|
||||
draw.surf(sx, sy, w, h, x+1, y, w, h, f)
|
||||
draw.surf(sx, sy, w, h, x-1, y+1, w, h, f)
|
||||
draw.surf(sx, sy, w, h, x, y, w, h, f)
|
||||
draw.surf(sx, sy, w, h, x+1, y+1, w, h, f)
|
||||
pal.subpal()
|
||||
draw.surf(sx, sy, w, h, x, y, w, h, f)
|
||||
end
|
||||
}
|
||||
Reference in New Issue
Block a user