From 16be589a728669d30dad69f498e5897798cf516d Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Tue, 17 Jun 2025 13:53:45 +0200 Subject: [PATCH] =?UTF-8?q?-=20VERSI=C3=93=201.1=20-=20[NEW]=20map.surf()?= =?UTF-8?q?=20per=20a=20obtindre=20i=20fixar=20la=20surface=20que=20usa=20?= =?UTF-8?q?el=20tilemap=20-=20[NEW]=20Llevats=20map.new,=20map.load=20i=20?= =?UTF-8?q?map.save.=20Es=20fa=20des=20de=20les=20surfaces.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua.cpp | 22 +++++++++++++++------- mini.cpp | 1 - version.h | 2 +- vscode/library.lua | 17 ++++------------- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/lua.cpp b/lua.cpp index 8b1699b..ff8d27d 100644 --- a/lua.cpp +++ b/lua.cpp @@ -125,6 +125,7 @@ extern "C" { // map // =============================================== + /* static int cpp_map_new(lua_State *L) { int w = luaL_checknumber(L, 1); int h = luaL_checknumber(L, 2); @@ -148,10 +149,17 @@ extern "C" { savesurf(surface, str, nullptr); return 0; } + */ + + static int cpp_map_surf(lua_State *L) { + if (lua_gettop(L)==1) { + uint8_t surface = luaL_checkinteger(L, 1); + setmap(surface); + } else { + lua_pushinteger(L, getmap()); + return 1; + } - static int cpp_map_set(lua_State *L) { - uint8_t surface = luaL_checkinteger(L, 1); - setmap(surface); return 0; } @@ -826,10 +834,10 @@ void push_lua_funcs() { lua_setglobal(L, "surf"); lua_newtable(L); - lua_pushcfunction(L,cpp_map_new); lua_setfield(L, -2, "new"); - lua_pushcfunction(L,cpp_map_load); lua_setfield(L, -2, "load"); - lua_pushcfunction(L,cpp_map_save); lua_setfield(L, -2, "save"); - lua_pushcfunction(L,cpp_map_set); lua_setfield(L, -2, "set"); + //lua_pushcfunction(L,cpp_map_new); lua_setfield(L, -2, "new"); + //lua_pushcfunction(L,cpp_map_load); lua_setfield(L, -2, "load"); + //lua_pushcfunction(L,cpp_map_save); lua_setfield(L, -2, "save"); + lua_pushcfunction(L,cpp_map_surf); lua_setfield(L, -2, "surf"); lua_pushcfunction(L,cpp_map_draw); lua_setfield(L, -2, "draw"); lua_pushcfunction(L,cpp_map_tile); lua_setfield(L, -2, "tile"); lua_setglobal(L, "map"); diff --git a/mini.cpp b/mini.cpp index 2074823..43302b9 100644 --- a/mini.cpp +++ b/mini.cpp @@ -4,7 +4,6 @@ #include "lua.h" #include "gif.h" #include "gifenc.h" -//#include "SDL2/SDL_mixer.h" #include "jail_audio.h" #define MAX_TEXTURES 100 diff --git a/version.h b/version.h index 83d90e5..900e6a7 100644 --- a/version.h +++ b/version.h @@ -1,3 +1,3 @@ #pragma once -#define MINI_VERSION "1.0.1" +#define MINI_VERSION "1.1" diff --git a/vscode/library.lua b/vscode/library.lua index a2315cc..b590793 100644 --- a/vscode/library.lua +++ b/vscode/library.lua @@ -62,22 +62,13 @@ function surf.pixel(x, y, color) end ---@class map map = {} ----@param w number ----@param h number ----Create new map specifying width and height -function map.new(w, h) end - ----@param filename string ----Load a tilemap from a file and set it as current tilemap -function map.load(filename) end - ----@param filename string ----Save the current tilemap in a file -function map.save(filename) end +---@return number surface +---Get tilemaps current surface +function map.surf() end ---@param surface number ---Set surface as the current tilemap -function map.set(surface) end +function map.surf(surface) end ---Draw the tilemap, using the source surface as tile graphics source function map.draw() end