From de873a7a2581d4dd83a21ee62f1296258c45e748 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Wed, 11 Mar 2026 07:42:24 +0100 Subject: [PATCH] =?UTF-8?q?-=20[NEW]=20Redimensionades=20les=20habitacions?= =?UTF-8?q?=20per=20a=20ocupar=20tota=20la=20pantalla=20-=20[FIX]=20Ajusta?= =?UTF-8?q?da=20posici=C3=B3=20inici=20segons=20nou=20tamany=20de=20habita?= =?UTF-8?q?cions=20-=20[FIX]=20Ajustat=20nivell=20de=20l'aigua=20segons=20?= =?UTF-8?q?nou=20tamany=20de=20habitacions=20-=20[WIP]=20Treballant=20en?= =?UTF-8?q?=20el=20nou=20men=C3=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/editor.lua | 25 +++--- data/game.lua | 4 +- data/menu.lua | 166 ++++++++++++++++++++++++++++---------- data/rooms.lua | 40 ++++++--- data/rooms_background.gif | Bin 1196 -> 1271 bytes data/rooms_foreground.gif | Bin 2019 -> 2027 bytes data/rooms_items.gif | Bin 1052 -> 1056 bytes data/sprites.lua | 6 +- 8 files changed, 174 insertions(+), 67 deletions(-) diff --git a/data/editor.lua b/data/editor.lua index 89479c8..77be13f 100644 --- a/data/editor.lua +++ b/data/editor.lua @@ -23,6 +23,7 @@ editor = { end, update = function() + tweening.update(sys.delta()) if sys.beat() then editor.ants = (editor.ants<<12) | (editor.ants>>4) end @@ -38,10 +39,6 @@ editor = { end end - -- Pintar el menú (el marcador serà en el modul game.lua) - --score.draw() - menu.draw() - -- Pintar el mapa i sprites rooms.draw() @@ -50,7 +47,7 @@ editor = { local tx, ty = (mx>>3), (my>>3) mx, my = tx<<3, ty<<3 - if my>=0 then + if menu.hidden then if editor.layer==LAYER_BACKGROUND or editor.layer==LAYER_FOREGROUND then if editor.selection then local rx1,ry1,rx2,ry2=editor.selection.x1<<3,editor.selection.y1<<3,editor.selection.x2<<3,editor.selection.y2<<3 @@ -132,10 +129,11 @@ editor = { view.origin(0,0) draw.text(rooms.pos.x//20,1,96,28) - draw.text(rooms.pos.y//12,5,96,28) + draw.text(rooms.pos.y//13,5,96,28) if key.press(key.ESCAPE) then - editor.quit() + --editor.quit() + menu.toggle() elseif key.press(key.RIGHT) and rooms.pos.x < 20*7 then rooms.pos.x = rooms.pos.x + 20 sprites.remove_out_of_room() @@ -144,12 +142,12 @@ editor = { 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 + elseif key.press(key.DOWN) and rooms.pos.y < 13*7 then + rooms.pos.y = rooms.pos.y + 13 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 + rooms.pos.y = rooms.pos.y - 13 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 @@ -188,6 +186,11 @@ editor = { sprites.remove(sprite) end end + + -- Pintar el menú (el marcador serà en el modul game.lua) + --score.draw() + menu.draw() + end, create_stamp=function() @@ -224,7 +227,7 @@ editor = { for y=1,h do for x=1,w do local fx, fy = tx+x-1, ty+y-1 - if fx < rooms.pos.x+20 and fy < rooms.pos.y+12 then + if fx < rooms.pos.x+20 and fy < rooms.pos.y+13 then map.tile(fx,fy,editor.brush.tiles[p]) end p=p+1 diff --git a/data/game.lua b/data/game.lua index 2760c01..285e6cf 100644 --- a/data/game.lua +++ b/data/game.lua @@ -124,12 +124,12 @@ game = { apply_water = function() view.origin(0,0) - if rooms.pos.y == 84 then + if rooms.pos.y == 91 then surf.target(game.back_buf) surf.source(game.back_buf) for x=0,159 do local water_level = math.sin(game.water_counter)*2 - for y=96+water_level,103 do + for y=88+water_level,103 do local pixel = surf.pixel(x,y) surf.pixel(x,y,game.water_pal[pixel+1]) end diff --git a/data/menu.lua b/data/menu.lua index 4049f1e..72e4135 100644 --- a/data/menu.lua +++ b/data/menu.lua @@ -1,56 +1,140 @@ require "popup" menu = { - current_x = 0, - - init = function() - end, + hidden = true, + pos_y = 0, draw = function() - view.origin(0,0) + view.origin(0,menu.pos_y) view.clip() - draw.rectf(0,0,160,7,23) - draw.hline(0,7,160,16) - menu.current_x = 1 + local y = menu.pos_y + draw.rrectf(1,0,8,8,1,21) + draw.rrectf(1,-1,8,8,1,6) + draw.hline(3,1,6,21) + draw.hline(3,3,6,21) + draw.hline(3,5,6,21) + draw.rectf(6,0,2,2,8) - menu.option("FILE") - popup.create("FILE", 1, 8) - popup.addOption("FILE", "Play", editor.play) - popup.addOption("FILE", "Save", function() rooms.save() editor.modified=false end) - popup.addOption("FILE", "Quit", editor.quit) + if y<=0 then return end - menu.option("VIEW") - popup.create("VIEW", 1, 8) - popup.addOption("VIEW", "Background", function() rooms.toggle_visibility(LAYER_BACKGROUND) end) - popup.addOption("VIEW", "Shadows", function() rooms.toggle_visibility(LAYER_SHADOWS) end) - popup.addOption("VIEW", "Foreground", function() rooms.toggle_visibility(LAYER_FOREGROUND) end) - popup.addOption("VIEW", "Sprites", function() rooms.toggle_visibility(LAYER_SPRITES) end) + view.origin(0,menu.pos_y-24) + draw.rectf(0,0,160,24,6) - menu.option("EDIT") - popup.create("EDIT", 1, 8) - popup.addOption("EDIT", "Background", function() editor.layer=LAYER_BACKGROUND end) - popup.addOption("EDIT", "Foreground", function() editor.layer=LAYER_FOREGROUND end) - popup.addOption("EDIT", "Items", function() editor.layer=LAYER_ITEMS end) - --popup.addOption("EDIT", "Sprites", function() rooms.toggle_visibility(LAYER_SPRITES) end) + menu.pushbutton("PLAY",1,3,16,13,10,editor.play) + menu.pushbutton("SAVE",22,3,7,22,21,function() rooms.save() editor.modified=false end) + menu.pushbutton("QUIT",22,12,7,12,5,editor.quit) - menu.option("TOOLS") - if editor.modified then - draw.text("*",160-5,1,8) - end + draw.rrect(44,6,29,14,3,21) + draw.rectf(48,6,17,1,6) + draw.text("EDIT",49,3,21) + menu.togglebutton("F",44+3,6+3,7,14,9,15,7,editor.layer==LAYER_FOREGROUND,function() editor.layer=LAYER_FOREGROUND end) + menu.togglebutton("B",52+3,6+3,7,14,9,15,7,editor.layer==LAYER_BACKGROUND,function() editor.layer=LAYER_BACKGROUND end) + menu.togglebutton("I",60+3,6+3,7,14,9,15,7,editor.layer==LAYER_ITEMS,function() editor.layer=LAYER_ITEMS end) + + draw.rrect(75,6,37,14,3,21) + draw.rectf(79,6,17,1,6) + draw.text("SHOW",80,3,21) + + menu.togglebutton("F",75+3,6+3,7,14,9,15,7,rooms.is_visible(LAYER_FOREGROUND),function() rooms.toggle_visibility(LAYER_FOREGROUND) end) + menu.togglebutton("B",83+3,6+3,7,14,9,15,7,rooms.is_visible(LAYER_BACKGROUND),function() rooms.toggle_visibility(LAYER_BACKGROUND) end) + menu.togglebutton("S",91+3,6+3,7,14,9,15,7,rooms.is_visible(LAYER_SHADOWS),function() rooms.toggle_visibility(LAYER_SHADOWS) end) + menu.togglebutton("I",99+3,6+3,7,14,9,15,7,rooms.is_visible(LAYER_ITEMS),function() rooms.toggle_visibility(LAYER_ITEMS) end) end, - option = function(label) - local next_x = menu.current_x + (#label + 2)*4 - local mx, my = mouse.pos() - if my < 8 and mx >= menu.current_x and mx < next_x then - draw.rectf(menu.current_x, 0, next_x-menu.current_x, 7, 21) - if mouse.down(mouse.LEFT) then - mouse.discard() - popup.show(label) - end + toggle = function() + if menu.hidden then + menu.hidden = false + tweening.add(0,24,0.25,easing.easeOutBounce,function(value,n,finished)menu.pos_y=value end) + else + menu.hidden = true + tweening.add(24,0,0.25,easing.easeOutBounce,function(value,n,finished)menu.pos_y=value end) end - draw.text(label,menu.current_x+4,1,28) - menu.current_x = next_x - end + end, + + pushbutton = function(label,x,y,h,col1,col2,callback) + local size = (#label*4)-1+4 + local text_y = (h-5)//2 + local button_h=0 + local mx, my = mouse.pos() + if mx>=x and mx=y and my=x and mx=y and my-1 then bh=bh-1 end + end + draw.rrectf(x,y+1,size,h,1,col2) + draw.rrectf(x,y-bh,size,h,1,col1) + draw.text(label,x+2,y+text_y-bh,col2) + end, + +-- current_x = 0, +-- +-- init = function() +-- end, +-- +-- draw = function() +-- view.origin(0,0) +-- view.clip() +-- draw.rectf(0,0,160,7,23) +-- draw.hline(0,7,160,16) +-- menu.current_x = 1 +-- +-- menu.option("FILE") +-- popup.create("FILE", 1, 8) +-- popup.addOption("FILE", "Play", editor.play) +-- popup.addOption("FILE", "Save", function() rooms.save() editor.modified=false end) +-- popup.addOption("FILE", "Quit", editor.quit) +-- +-- menu.option("VIEW") +-- popup.create("VIEW", 1, 8) +-- popup.addOption("VIEW", "Background", function() rooms.toggle_visibility(LAYER_BACKGROUND) end) +-- popup.addOption("VIEW", "Shadows", function() rooms.toggle_visibility(LAYER_SHADOWS) end) +-- popup.addOption("VIEW", "Foreground", function() rooms.toggle_visibility(LAYER_FOREGROUND) end) +-- popup.addOption("VIEW", "Sprites", function() rooms.toggle_visibility(LAYER_SPRITES) end) +-- +-- menu.option("EDIT") +-- popup.create("EDIT", 1, 8) +-- popup.addOption("EDIT", "Background", function() editor.layer=LAYER_BACKGROUND end) +-- popup.addOption("EDIT", "Foreground", function() editor.layer=LAYER_FOREGROUND end) +-- popup.addOption("EDIT", "Items", function() editor.layer=LAYER_ITEMS end) +-- --popup.addOption("EDIT", "Sprites", function() rooms.toggle_visibility(LAYER_SPRITES) end) +-- +-- menu.option("TOOLS") +-- if editor.modified then +-- draw.text("*",160-5,1,8) +-- end +-- +-- end, +-- +-- option = function(label) +-- local next_x = menu.current_x + (#label + 2)*4 +-- local mx, my = mouse.pos() +-- if my < 8 and mx >= menu.current_x and mx < next_x then +-- draw.rectf(menu.current_x, 0, next_x-menu.current_x, 7, 21) +-- if mouse.down(mouse.LEFT) then +-- mouse.discard() +-- popup.show(label) +-- end +-- end +-- draw.text(label,menu.current_x+4,1,28) +-- menu.current_x = next_x +-- end } \ No newline at end of file diff --git a/data/rooms.lua b/data/rooms.lua index 76adf58..b45b290 100644 --- a/data/rooms.lua +++ b/data/rooms.lua @@ -14,28 +14,48 @@ rooms = { surf_items = nil, surf_original_items = nil, visibility = LAYER_ALL, - pos = {x=0, y=4*12}, + pos = {x=0, y=4*13}, current = function() - return (rooms.pos.x//20) + (rooms.pos.y//12) * 8 + return (rooms.pos.x//20) + (rooms.pos.y//13) * 8 + end, + + convert = function(src) + local dst = surf.new(20*8,13*8) + surf.source(src) + surf.target(dst) + + for ry=0,7 do + for rx=0,7 do + for ty=0,11 do + for tx=0,19 do + surf.pixel(rx*20+tx, ry*13+ty, surf.pixel(rx*20+tx, ry*12+ty)) + end + end + end + end + return dst end, reload = function() if rooms.surf_background ~= nil then surf.free(rooms.surf_background) end rooms.surf_background = surf.load("rooms_background"..ROOM_FILE_EXT) - --rooms.surf_background = surf.new(20*8,12*8) + --rooms.surf_background = surf.new(20*8,13*8) + --rooms.surf_background = rooms.convert(surf.load("rooms_background"..ROOM_FILE_EXT)) if rooms.surf_foreground ~= nil then surf.free(rooms.surf_foreground) end rooms.surf_foreground = surf.load("rooms_foreground"..ROOM_FILE_EXT) --rooms.surf_foreground = surf.new(20*8,12*8) + --rooms.surf_foreground = rooms.convert(surf.load("rooms_foreground"..ROOM_FILE_EXT)) if rooms.surf_items ~= nil then surf.free(rooms.surf_items) end rooms.surf_items = surf.load("rooms_items"..ROOM_FILE_EXT) --rooms.surf_items = surf.new(20*8,12*8) + --rooms.surf_items = rooms.convert(surf.load("rooms_items"..ROOM_FILE_EXT)) end, init = function() - rooms.pos.x, rooms.pos.y = 0,4*12 + rooms.pos.x, rooms.pos.y = 0,4*13 rooms.reload() sprites.init() end, @@ -50,15 +70,15 @@ rooms = { end, is_outside = function(x, y) - return x < rooms.pos.x or y < rooms.pos.y or x > rooms.pos.x + 20 or y > rooms.pos.y + 12 + return x < rooms.pos.x or y < rooms.pos.y or x > rooms.pos.x + 20 or y > rooms.pos.y + 13 end, draw = function() -- Retallem la pantalla a la zona de joc - view.clip(0,8,160,96) + --view.clip(0,8,160,96) -- Movem la càmara a l'habitació on estem - view.origin(-rooms.pos.x*8,-rooms.pos.y*8+8) + view.origin(-rooms.pos.x*8,-rooms.pos.y*8) -- Pintem el background surf.source(surf_tiles) @@ -70,7 +90,7 @@ rooms = { end -- Movem 4x4 pixels la càmara per a pintar les sombres dels sprites i el foreground - view.origin(-rooms.pos.x*8+4,-rooms.pos.y*8+12) + view.origin(-rooms.pos.x*8+4,-rooms.pos.y*8+4) -- Pintem el foreground de negre map.surf(rooms.surf_foreground) @@ -78,13 +98,13 @@ rooms = { if rooms.is_visible(LAYER_FOREGROUND | LAYER_SHADOWS) then map.draw() end -- Pintem els sprites de negre - if rooms.is_visible(LAYER_SPRITES | LAYER_SHADOWS) then + if rooms.is_visible(LAYER_SPRITES | LAYER_SHADOWS) then sprites.draw(true) --draw.surf(0, 0, 16, 17, 20, 15, 16, 17) end -- Movem la càmara al lloc que toca de nou, i tornem la paleta normal - view.origin(-rooms.pos.x*8,-rooms.pos.y*8+8) + view.origin(-rooms.pos.x*8,-rooms.pos.y*8) pal.subpal() -- Pintem el foreground diff --git a/data/rooms_background.gif b/data/rooms_background.gif index 8d97e8f24d1c733eb2b786e74f161b43bbfddcb4..b962bd12149a8414b428bc9c52d972ad466e4f3e 100644 GIT binary patch delta 445 zcmV;u0Yd()3HJ#JM@dFFIbomxXt4XpfOt?uiw9b0}CEZxUk{Aa}z6G%y@1^6p$lJo;>;RNXnQoTNatQbL7n-J$nWX zQgmn1A5CXQ?NPO6)_)vbQ-&Q|wq)8HZQsV7QTJ!wy?p~G*todypF!SvRv?7)F@yql>VHKhAchl$heCnseF&m| z6wXG_g(o&NnTZ%?sG)~3N*7{{6a9wcV;fSqBSby^7!iswHfZFLNCqXObR=E3Bt$t} z2;P%aKBgRWH&#jAl`?9nP<2^)Nzjd9ikaenk+FyoWKrffnVLMJ`KFl$C28lK#m%=K nod>Z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(6fe=g`1Rp5D z2QILJ46IjMBm;vPz~EU11c2^Zbvwk2FkvC!8bvTeGXu>41X+LDn+zyWfwnErd4FME zMLI_<8&!pe*sI+H$c&_?8IYg^Cpls6N@zLqMMR0Ong9r%bt^wPPD!mxSg#thxuo6j zi%LTl4x1MNZ+S^o5O9|8c6ct_HReenpaK=*NCl_a?v74O7ZXWnyLU0fj3I&m54pE7 zKY>wjhcwp>6+~sGoS4agGLS(R>4wLg{K$g^d&wg!GJ_dNFH~b><0munBn_UiK+~!j zvoKW^$3*}Ja*U-cALgn2*^+;^%q1>&smoqUk#_bvnAb?9E2rt`CXTb<1edAIW-{}c L&Wt7m0|Ed$Xp%H_WYjU}?d>dkZi8^K$Uv$dgwMl#sXb=g_0OJszETLhGHK`V3QRClXQ&%{&F0kkg(vx zh!ZPbj8FjMhX^1Behk1d0m_&&Yu?P(G3Sh)F&id$AmZfDs8g#BdRk!X)v#krmVNOx z?S!Eb=f2Gwr0txOclRDnoNSrooms.pos.y+11 then game.change_room(0,1) else - if sprites.hero.cooldown % 2 == 0 then + if sprites.hero.cooldown % 4 == 0 then sprites.hero.pos.y = sprites.hero.pos.y + 1 end end @@ -488,7 +488,7 @@ sprites = { if rooms.pos.y<84 and ty+2>rooms.pos.y+11 then game.change_room(0,1) else - if sprites.hero.pos.y >= 742 then + if sprites.hero.pos.y >= 808 then sprites.hero_hit(0) return end