From f8fb04db1b08b1bf90047b56337c5bac7ca28a60 Mon Sep 17 00:00:00 2001 From: Adolfo Reyna Date: Thu, 12 Feb 2026 23:09:13 -0500 Subject: [PATCH] improve game --- games/lua_examples/2048.lua | 22 +- screenlog.0 | 528 ++++++++++++++++++++++++++++++++++++ 2 files changed, 547 insertions(+), 3 deletions(-) create mode 100644 screenlog.0 diff --git a/games/lua_examples/2048.lua b/games/lua_examples/2048.lua index 4715eb8..acd3109 100644 --- a/games/lua_examples/2048.lua +++ b/games/lua_examples/2048.lua @@ -138,15 +138,31 @@ function draw() -- Empty tile renderer.rect(tile_x, tile_y, tile_size, tile_size, true, false) else + local reduce_size + if value == 2 then + reduce_size = 10 + elseif value == 4 then + reduce_size = 8 + elseif value == 8 then + reduce_size = 6 + elseif value == 16 then + reduce_size = 4 + elseif value == 32 then + reduce_size = 2 + else + reduce_size = 0 + end + -- Empty tile + renderer.rect(tile_x, tile_y, tile_size, tile_size, true, false) -- Filled tile - renderer.rect(tile_x+2, tile_y+2, tile_size-4, tile_size-4, true, true) + renderer.rect(tile_x+reduce_size, tile_y+reduce_size, tile_size-reduce_size*2, tile_size-reduce_size*2, true, true) -- Draw value (simplified) local text = tostring(value) if string.len(text) <= 2 then - renderer.text_scaled(tile_x + tile_size / 2 - 4, tile_y + tile_size / 2, text, false, 2) + renderer.text_scaled(tile_x + tile_size / 2 - 4, tile_y + tile_size / 2 - 4, text, false, 2) else - renderer.text_scaled(tile_x + tile_size / 2 - 8, tile_y + tile_size / 2, text, false, 2) + renderer.text_scaled(tile_x + tile_size / 2 - 8, tile_y + tile_size / 2 - 4, text, false, 2) end end end diff --git a/screenlog.0 b/screenlog.0 new file mode 100644 index 0000000..1a0e92f --- /dev/null +++ b/screenlog.0 @@ -0,0 +1,528 @@ +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (215,122) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (203,137) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (312,131) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (355,140) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (376,273) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (357,277) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (323,258) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (321,261) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (89,291) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (327,264) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (315,250) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (262,151) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (319,150) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +Long press detected - returning to launcher +Launcher reset - returning to menu +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (358,157) +Touch at (358,157) in launcher +Selected game: Snake Game +Lua bindings registered +LuaGame Error [load script]: [string "/games/SNAKE.LUA"]:113: unexpected symbol near ',' +LuaGame: Failed to load /games/SNAKE.LUA: load script: [string "/games/SNAKE.LUA"]:113: unexpected symbol near ',' +Game launched successfully +INT: RISE +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (164,97) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (194,215) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (288,289) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (285,169) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (255,117) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (168,100) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +Long press detected - returning to launcher +Launcher reset - returning to menu +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (424,264) +Touch at (424,264) in launcher +INT: RISE +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (389,237) +INT: RISE +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (392,247) +INT: RISE +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (399,249) +INT: RISE +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (138,49) +INT: RISE +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (125,111) +INT: RISE +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (80,146) +INT: RISE +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (125,37) +INT: RISE +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (100,73) +INT: RISE +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (82,154) +INT: RISE +INT: FALL +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +INT: RISE +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (120,255) +Touch at (120,255) in launcher +INT: RISE +INT: FALL +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +INT: RISE +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (191,125) +Touch at (191,125) in launcher +Selected game: Touch Counter +Lua bindings registered +LuaGame Error [load script]: [string "/games/COUNTER.LUA"]:36: unexpected symbol near ',' +LuaGame: Failed to load /games/COUNTER.LUA: load script: [string "/games/COUNTER.LUA"]:36: unexpected symbol near ',' +Game launched successfully +INT: RISE +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (165,106) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (121,224) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (253,160) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (258,158) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (256,156) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (255,154) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (295,161) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (296,157) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +INT: RISE +Touch DOWN at (477,202) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (236,221) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (338,182) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +TFT: Dimmed to 5% +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (306,162) +TFT: Restored brightness +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (338,116) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (208,258) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (232,55) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (37,160) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (224,208) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (53,150) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (225,239) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (247,231) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (152,187) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (426,157) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (198,272) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (384,191) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (44,195) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (283,266) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (50,215) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (287,265) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (189,275) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (421,142) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (43,192) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (390,155) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (48,204) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (258,58) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (275,284) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (23,202) +LuaGame Error [draw]: [string "/games/2048.LUA"]:145: bad argument #1 to 'rect' (number has no integer representation) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (173,173) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (121,151) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (71,119) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (220,109) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (313,124) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (235,140) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (131,185) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (269,54) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP +INT: FALL +Processing touch: flag=1, event_down=1 +Touch DOWN at (227,165) +INT: RISE +Processing touch: flag=1, event_down=0 +Touch UP