Scale games on both axes and 2x text size
All 4 games (simon_says, tic_tac_toe, memory_match, 2048): - Changed sizing to use min(width, height) instead of just width - Grids now scale proportionally on both axes - All UI text now uses text_scale=2 for better visibility - Games fill more of the screen properly on portrait mode Fixes: - Simon Says buttons now square grid on any orientation - Tic-Tac-Toe grid centered vertically using full screen height - Memory Match cards use smallest dimension for square sizing - 2048 tiles scale and center on both axes - All text (scores, menus, game over) now 2x larger
This commit is contained in:
@@ -12,9 +12,10 @@ local GRID_SIZE = 4
|
||||
|
||||
-- Calculate tile size based on screen size
|
||||
local function get_tile_size()
|
||||
-- Use available space with padding
|
||||
local padding = math.floor(game.width() / 8)
|
||||
local available = game.width() - (padding * 2)
|
||||
-- Use smallest dimension for square grid
|
||||
local min_dim = math.min(game.width(), game.height())
|
||||
local padding = math.floor(min_dim / 8)
|
||||
local available = min_dim - (padding * 2)
|
||||
local tile_size = math.floor(available / GRID_SIZE)
|
||||
return tile_size
|
||||
end
|
||||
@@ -26,7 +27,9 @@ local function get_grid_start_x()
|
||||
end
|
||||
|
||||
local function get_grid_start_y()
|
||||
return 30
|
||||
local tile_size = get_tile_size()
|
||||
local grid_height = tile_size * GRID_SIZE
|
||||
return math.floor((game.height() - grid_height) / 2)
|
||||
end
|
||||
|
||||
function init()
|
||||
@@ -119,8 +122,8 @@ function draw()
|
||||
local start_y = get_grid_start_y()
|
||||
|
||||
if state == STATE_MENU then
|
||||
renderer.text(game.width() / 2 - 15, game.height() / 2 - 30, "2048", true)
|
||||
renderer.text(game.width() / 2 - 50, game.height() / 2, "Tap to Start", true)
|
||||
renderer.text(game.width() / 2 - 15, game.height() / 2 - 30, "2048", true, 2)
|
||||
renderer.text(game.width() / 2 - 50, game.height() / 2, "Tap to Start", true, 2)
|
||||
|
||||
elseif state == STATE_PLAYING or state == STATE_WIN or state == STATE_GAME_OVER then
|
||||
-- Draw grid
|
||||
@@ -140,27 +143,27 @@ function draw()
|
||||
-- Draw value (simplified)
|
||||
local text = tostring(value)
|
||||
if string.len(text) <= 2 then
|
||||
renderer.text(tile_x + 2, tile_y + 2, text, false)
|
||||
renderer.text(tile_x + 2, tile_y + 2, text, false, 2)
|
||||
else
|
||||
renderer.text(tile_x + 1, tile_y + 2, text, false)
|
||||
renderer.text(tile_x + 1, tile_y + 2, text, false, 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Draw score
|
||||
renderer.text(10, 10, "Score: " .. tostring(game.vars.score), true)
|
||||
renderer.text(10, 10, "Score: " .. tostring(game.vars.score), true, 2)
|
||||
|
||||
if state == STATE_WIN then
|
||||
renderer.text(game.width() / 2 - 30, game.height() / 2 - 20, "YOU WIN!", true)
|
||||
renderer.text(game.width() / 2 - 60, game.height() / 2, "Tap up: Continue", true)
|
||||
renderer.text(game.width() / 2 - 50, game.height() / 2 + 15, "Tap down: Menu", true)
|
||||
renderer.text(game.width() / 2 - 30, game.height() / 2 - 20, "YOU WIN!", true, 2)
|
||||
renderer.text(game.width() / 2 - 60, game.height() / 2, "Tap up: Continue", true, 2)
|
||||
renderer.text(game.width() / 2 - 50, game.height() / 2 + 15, "Tap down: Menu", true, 2)
|
||||
end
|
||||
|
||||
if state == STATE_GAME_OVER then
|
||||
renderer.text(game.width() / 2 - 40, game.height() / 2, "GAME OVER", true)
|
||||
renderer.text(game.width() / 2 - 30, game.height() / 2 + 15, "Score: " .. tostring(game.vars.score), true)
|
||||
renderer.text(game.width() / 2 - 60, game.height() / 2 + 30, "Tap to Menu", true)
|
||||
renderer.text(game.width() / 2 - 40, game.height() / 2, "GAME OVER", true, 2)
|
||||
renderer.text(game.width() / 2 - 30, game.height() / 2 + 15, "Score: " .. tostring(game.vars.score), true, 2)
|
||||
renderer.text(game.width() / 2 - 60, game.height() / 2 + 30, "Tap to Menu", true, 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user