- [NEW] Ja es poden crear items i es guarden
- [NEW] Ja es pot modificar el flip dels items - [NEW] si tenim un item pa pintar, amb F fem flip abans de soltar-lo - [NEW] gestió correcta dels items de cada habitació - [FIX] Ja es carreguen els items de la primer habitació
This commit is contained in:
@@ -10,6 +10,8 @@ editor = {
|
|||||||
ants=0xc936,
|
ants=0xc936,
|
||||||
modified = false,
|
modified = false,
|
||||||
item_selected=nil,
|
item_selected=nil,
|
||||||
|
item_hovered=nil,
|
||||||
|
flip=false,
|
||||||
|
|
||||||
enable = function()
|
enable = function()
|
||||||
app.update = editor.update
|
app.update = editor.update
|
||||||
@@ -77,6 +79,8 @@ editor = {
|
|||||||
map.surf(rooms.surf_items)
|
map.surf(rooms.surf_items)
|
||||||
--print(editor.item_selected)
|
--print(editor.item_selected)
|
||||||
map.tile(tx,ty,editor.item_selected)
|
map.tile(tx,ty,editor.item_selected)
|
||||||
|
local room = tx + ty * 8
|
||||||
|
table.insert(sprites.list, templates.create(items[editor.item_selected].name, {pos={x=tx*8, y=ty*8},flipped=editor.flip, room=room}))
|
||||||
editor.modified = true
|
editor.modified = true
|
||||||
--surf.target(0)
|
--surf.target(0)
|
||||||
end
|
end
|
||||||
@@ -86,7 +90,7 @@ editor = {
|
|||||||
end
|
end
|
||||||
if editor.item_selected then
|
if editor.item_selected then
|
||||||
local k = items[editor.item_selected]
|
local k = items[editor.item_selected]
|
||||||
draw.surf(k.visual.x, k.visual.y, k.visual.w, k.visual.h, mx, my)
|
draw.surf(k.visual.x, k.visual.y, k.visual.w, k.visual.h, mx, my, k.visual.w, k.visual.h, editor.flip)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -99,12 +103,20 @@ editor = {
|
|||||||
editor.quit()
|
editor.quit()
|
||||||
elseif key.press(key.RIGHT) and rooms.pos.x < 20*7 then
|
elseif key.press(key.RIGHT) and rooms.pos.x < 20*7 then
|
||||||
rooms.pos.x = rooms.pos.x + 20
|
rooms.pos.x = rooms.pos.x + 20
|
||||||
|
sprites.remove_out_of_room()
|
||||||
|
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
|
||||||
elseif key.press(key.LEFT) and rooms.pos.x > 0 then
|
elseif key.press(key.LEFT) and rooms.pos.x > 0 then
|
||||||
rooms.pos.x = rooms.pos.x - 20
|
rooms.pos.x = rooms.pos.x - 20
|
||||||
|
sprites.remove_out_of_room()
|
||||||
|
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
|
||||||
elseif key.press(key.DOWN) and rooms.pos.y < 12*7 then
|
elseif key.press(key.DOWN) and rooms.pos.y < 12*7 then
|
||||||
rooms.pos.y = rooms.pos.y + 12
|
rooms.pos.y = rooms.pos.y + 12
|
||||||
|
sprites.remove_out_of_room()
|
||||||
|
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
|
||||||
elseif key.press(key.UP) and rooms.pos.y > 0 then
|
elseif key.press(key.UP) and rooms.pos.y > 0 then
|
||||||
rooms.pos.y = rooms.pos.y - 12
|
rooms.pos.y = rooms.pos.y - 12
|
||||||
|
sprites.remove_out_of_room()
|
||||||
|
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
|
||||||
elseif key.press(key.TAB) or key.press(key.ESCAPE) then
|
elseif key.press(key.TAB) or key.press(key.ESCAPE) then
|
||||||
if editor.layer==LAYER_BACKGROUND or editor.layer==LAYER_FOREGROUND then
|
if editor.layer==LAYER_BACKGROUND or editor.layer==LAYER_FOREGROUND then
|
||||||
editor.tilepicker.show()
|
editor.tilepicker.show()
|
||||||
@@ -119,6 +131,22 @@ editor = {
|
|||||||
elseif key.press(key.F11) then
|
elseif key.press(key.F11) then
|
||||||
reload_textures()
|
reload_textures()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if editor.layer==LAYER_ITEMS then
|
||||||
|
if key.press(key.F) then
|
||||||
|
if editor.item_selected then
|
||||||
|
editor.flip = not editor.flip
|
||||||
|
elseif editor.item_hovered then
|
||||||
|
local sprite = sprites.list[editor.item_hovered]
|
||||||
|
sprite.flipped = not sprite.flipped
|
||||||
|
map.surf(rooms.surf_items)
|
||||||
|
local tile = map.tile(sprite.pos.x//8, sprite.pos.y//8)
|
||||||
|
if tile > 0x7f then tile = tile & 0x7f else tile = tile | 0x80 end
|
||||||
|
map.tile(sprite.pos.x//8, sprite.pos.y//8, tile)
|
||||||
|
editor.modified = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
create_stamp=function()
|
create_stamp=function()
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ function mini.init()
|
|||||||
rooms.init()
|
rooms.init()
|
||||||
shader.init("lynx.glsl")
|
shader.init("lynx.glsl")
|
||||||
editor.enable()
|
editor.enable()
|
||||||
|
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
|
||||||
end
|
end
|
||||||
|
|
||||||
function mini.update()
|
function mini.update()
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 999 B After Width: | Height: | Size: 1001 B |
@@ -33,8 +33,11 @@ sprites = {
|
|||||||
for x = rx, rx+19 do
|
for x = rx, rx+19 do
|
||||||
if map.tile(x,y) ~= 0 then
|
if map.tile(x,y) ~= 0 then
|
||||||
local room = (rx//20) + (ry//12) * 8
|
local room = (rx//20) + (ry//12) * 8
|
||||||
io.write("crear "..items[map.tile(x,y)].name.." en hab "..room.." ("..x..","..y..")...\n")
|
local item = map.tile(x,y)
|
||||||
table.insert(sprites.list, templates.create(items[map.tile(x,y)].name, {pos={x=x*8, y=y*8},flipped=true, room=room}))
|
local flip = item > 0x7f
|
||||||
|
item = item & 0x7f
|
||||||
|
io.write("crear "..items[item].name.." en hab "..room.." ("..x..","..y..")...\n")
|
||||||
|
table.insert(sprites.list, templates.create(items[item].name, {pos={x=x*8, y=y*8},flipped=flip, room=room}))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--io.write("\n")
|
--io.write("\n")
|
||||||
@@ -55,7 +58,7 @@ sprites = {
|
|||||||
jumping = 0,
|
jumping = 0,
|
||||||
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}))
|
||||||
|
|
||||||
--local mummy = {
|
--local mummy = {
|
||||||
-- pos = { x=100, y=4*12*8+71 },
|
-- pos = { x=100, y=4*12*8+71 },
|
||||||
@@ -313,12 +316,14 @@ sprites = {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
draw = function(ignore_selected)
|
draw = function(ignore_selected)
|
||||||
|
editor.item_hovered = nil
|
||||||
local mx,my = mouse.pos()
|
local mx,my = mouse.pos()
|
||||||
surf.source(surf_sprites)
|
surf.source(surf_sprites)
|
||||||
if editor.item_selected or editor.layer~=LAYER_ITEMS then ignore_selected = true end
|
if editor.item_selected or editor.layer~=LAYER_ITEMS then ignore_selected = true end
|
||||||
for i,v in ipairs(sprites.list) do
|
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
|
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)
|
sprites.draw_sprite_selected(v)
|
||||||
|
editor.item_hovered = i
|
||||||
else
|
else
|
||||||
sprites.draw_sprite(v)
|
sprites.draw_sprite(v)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user