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

@@ -13,14 +13,15 @@ local FLIP_DURATION = 15 -- Frames to show flip animation
-- Calculate card size based on screen size
local function get_card_size()
-- Use available space with padding
local padding = math.floor(game.width() / 8)
local available_width = game.width() - (padding * 2)
local available_height = game.height() - 80 -- Leave room for text
-- Use available space with padding, based on smallest dimension
local min_dim = math.min(game.width(), game.height())
local padding = math.floor(min_dim / 8)
local available_w = game.width() - (padding * 2)
local available_h = game.height() - 80 -- Leave room for text
-- Calculate based on grid
local card_width = math.floor(available_width / GRID_COLS)
local card_height = math.floor(available_height / GRID_ROWS)
local card_width = math.floor(available_w / GRID_COLS)
local card_height = math.floor(available_h / GRID_ROWS)
-- Use the smaller dimension for square cards
return math.min(card_width, card_height)
@@ -33,7 +34,7 @@ local function get_grid_start_x()
end
local function get_grid_start_y()
return 40
return 60
end
function init()
@@ -133,9 +134,9 @@ function draw()
local start_y = get_grid_start_y()
if state == STATE_MENU then
renderer.text(game.width() / 2 - 40, game.height() / 2 - 40, "MEMORY MATCH", true)
renderer.text(game.width() / 2 - 50, game.height() / 2 - 10, "Find all pairs", true)
renderer.text(game.width() / 2 - 50, game.height() / 2 + 20, "Tap to Start", true)
renderer.text(game.width() / 2 - 40, game.height() / 2 - 40, "MEMORY MATCH", true, 2)
renderer.text(game.width() / 2 - 50, game.height() / 2 - 10, "Find all pairs", 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
@@ -150,7 +151,7 @@ function draw()
-- Show card value
renderer.rect(x, y, card_size, card_size, true, true)
local text = tostring(card.id)
renderer.text(x + math.floor(card_size / 2 - 2), y + math.floor(card_size / 2 - 2), text, false)
renderer.text(x + math.floor(card_size / 2 - 2), y + math.floor(card_size / 2 - 2), text, false, 2)
else
-- Face down (outline)
renderer.rect(x, y, card_size, card_size, true, false)
@@ -159,12 +160,12 @@ function draw()
end
-- Draw stats
renderer.text(10, 10, "Pairs: " .. tostring(game.vars.score) .. "/" .. tostring((GRID_COLS * GRID_ROWS) / 2), true)
renderer.text(10, 20, "Moves: " .. tostring(game.vars.moves), true)
renderer.text(10, 10, "Pairs: " .. tostring(game.vars.score) .. "/" .. tostring((GRID_COLS * GRID_ROWS) / 2), true, 2)
renderer.text(10, 25, "Moves: " .. tostring(game.vars.moves), true, 2)
if state == STATE_GAME_OVER then
renderer.text(game.width() / 2 - 40, 5, "YOU WIN!", true)
renderer.text(game.width() / 2 - 50, game.height() - 20, "Tap to Menu", true)
renderer.text(game.width() / 2 - 40, 5, "YOU WIN!", true, 2)
renderer.text(game.width() / 2 - 50, game.height() - 20, "Tap to Menu", true, 2)
end
end
end