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:
Adolfo Reyna
2026-02-12 21:23:34 -05:00
parent a274fb04a1
commit fa7d2fd32f
4 changed files with 59 additions and 53 deletions

View File

@@ -11,24 +11,25 @@ local GRID_SIZE = 3
-- Calculate cell size based on screen size
local function get_cell_size()
-- Use available space minus padding
local padding = math.floor(game.width() / 8)
local available = game.width() - (padding * 2)
-- Use smallest dimension to maintain 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 cell_size = math.floor(available / GRID_SIZE)
return cell_size
end
local function get_grid_start_y()
-- Center grid vertically with some top margin
-- Center grid vertically
local cell_size = get_cell_size()
local grid_height = cell_size * GRID_SIZE + 2 * 2 -- spacing
local grid_height = cell_size * GRID_SIZE
return math.floor((game.height() - grid_height) / 2)
end
local function get_grid_start_x()
-- Center grid horizontally
local cell_size = get_cell_size()
local grid_width = cell_size * GRID_SIZE + 2 * 2 -- spacing
local grid_width = cell_size * GRID_SIZE
return math.floor((game.width() - grid_width) / 2)
end
@@ -127,9 +128,9 @@ function draw()
local cell_spacing = 2
if state == STATE_MENU then
renderer.text(game.width() / 2 - 50, game.height() / 2 - 30, "TIC-TAC-TOE", true)
renderer.text(game.width() / 2 - 50, game.height() / 2, "Play vs AI", true)
renderer.text(game.width() / 2 - 50, game.height() / 2 + 20, "Tap to Start", true)
renderer.text(game.width() / 2 - 50, game.height() / 2 - 30, "TIC-TAC-TOE", true, 2)
renderer.text(game.width() / 2 - 50, game.height() / 2, "Play vs AI", true, 2)
renderer.text(game.width() / 2 - 50, game.height() / 2 + 20, "Tap to Start", true, 2)
elseif state == STATE_PLAYING or state == STATE_GAME_OVER then
-- Draw grid
@@ -157,14 +158,14 @@ function draw()
if state == STATE_GAME_OVER then
if game.vars.winner == 1 then
renderer.text(game.width() / 2 - 30, 10, "YOU WIN!", true)
renderer.text(game.width() / 2 - 30, 10, "YOU WIN!", true, 2)
elseif game.vars.winner == 2 then
renderer.text(game.width() / 2 - 30, 10, "AI WINS!", true)
renderer.text(game.width() / 2 - 30, 10, "AI WINS!", true, 2)
else
renderer.text(game.width() / 2 - 20, 10, "DRAW!", true)
renderer.text(game.width() / 2 - 20, 10, "DRAW!", true, 2)
end
renderer.text(game.width() / 2 - 60, game.height() - 15, "Tap to Menu", true)
renderer.text(game.width() / 2 - 60, game.height() - 15, "Tap to Menu", true, 2)
end
end
end