From cd27490426a1255340f7a7fe05925c06def5c1d1 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Sat, 15 Nov 2025 09:34:02 +0100 Subject: [PATCH] =?UTF-8?q?-=20[NEW]=20Ja=20es=20poden=20crear=20items=20i?= =?UTF-8?q?=20es=20guarden=20-=20[NEW]=20Ja=20es=20pot=20modificar=20el=20?= =?UTF-8?q?flip=20dels=20items=20-=20[NEW]=20si=20tenim=20un=20item=20pa?= =?UTF-8?q?=20pintar,=20amb=20F=20fem=20flip=20abans=20de=20soltar-lo=20-?= =?UTF-8?q?=20[NEW]=20gesti=C3=B3=20correcta=20dels=20items=20de=20cada=20?= =?UTF-8?q?habitaci=C3=B3=20-=20[FIX]=20Ja=20es=20carreguen=20els=20items?= =?UTF-8?q?=20de=20la=20primer=20habitaci=C3=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/editor.lua | 30 +++++++++++++++++++++++++++++- data/main.lua | 1 + data/rooms_foreground.gif | Bin 1728 -> 1728 bytes data/rooms_items.gif | Bin 999 -> 1001 bytes data/sprites.lua | 11 ++++++++--- 5 files changed, 38 insertions(+), 4 deletions(-) diff --git a/data/editor.lua b/data/editor.lua index 372b125..01e9622 100644 --- a/data/editor.lua +++ b/data/editor.lua @@ -10,6 +10,8 @@ editor = { ants=0xc936, modified = false, item_selected=nil, + item_hovered=nil, + flip=false, enable = function() app.update = editor.update @@ -77,6 +79,8 @@ editor = { map.surf(rooms.surf_items) --print(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 --surf.target(0) end @@ -86,7 +90,7 @@ editor = { end if editor.item_selected then 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 @@ -99,12 +103,20 @@ editor = { editor.quit() elseif key.press(key.RIGHT) and rooms.pos.x < 20*7 then 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 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 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 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 if editor.layer==LAYER_BACKGROUND or editor.layer==LAYER_FOREGROUND then editor.tilepicker.show() @@ -119,6 +131,22 @@ editor = { elseif key.press(key.F11) then reload_textures() 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, create_stamp=function() diff --git a/data/main.lua b/data/main.lua index ced4471..4e5cfe2 100644 --- a/data/main.lua +++ b/data/main.lua @@ -20,6 +20,7 @@ function mini.init() rooms.init() shader.init("lynx.glsl") editor.enable() + sprites.add_from_room(rooms.pos.x, rooms.pos.y) end function mini.update() diff --git a/data/rooms_foreground.gif b/data/rooms_foreground.gif index 3f549853f25e3384d0a54b48ecd0329e0f873b65..702b50011823078065cdc27cd7fc9beb48311112 100644 GIT binary patch delta 16 YcmX@Wdw_QX7c=wkKYup!GH+%E06MG&#{d8T delta 16 XcmX@Wdw_QX7c(;h1H)!s=FQ9iCI|!6 diff --git a/data/rooms_items.gif b/data/rooms_items.gif index 047665e6f4c529a924ecd66fb9b191b2d33f9cad..82ac77387abdaf2863e25102c8adf764d37e52c5 100644 GIT binary patch delta 43 ycmaFP{*rwI7c>9wKYw%>fM5Yb0s{lbxyh2ubC}r#G$!w0)?%OMdpp&E!5RQN^$k$~ delta 41 wcmaFK{+xXS7c+kt1A`6&5G-IwU|`@lGg*>(4zu5x9g}x3Yq7RT3NTm$0NgkVhyVZp diff --git a/data/sprites.lua b/data/sprites.lua index 339b4ce..2c65c9c 100644 --- a/data/sprites.lua +++ b/data/sprites.lua @@ -33,8 +33,11 @@ sprites = { for x = rx, rx+19 do if map.tile(x,y) ~= 0 then local room = (rx//20) + (ry//12) * 8 - io.write("crear "..items[map.tile(x,y)].name.." en hab "..room.." ("..x..","..y..")...\n") - table.insert(sprites.list, templates.create(items[map.tile(x,y)].name, {pos={x=x*8, y=y*8},flipped=true, room=room})) + local item = map.tile(x,y) + 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 --io.write("\n") @@ -55,7 +58,7 @@ sprites = { jumping = 0, 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 = { -- pos = { x=100, y=4*12*8+71 }, @@ -313,12 +316,14 @@ sprites = { end, 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 sprites.draw_sprite_selected(v) + editor.item_hovered = i else sprites.draw_sprite(v) end