Commit Graph

12 Commits

Author SHA1 Message Date
Adolfo Reyna
f398d62af2 Add renderer.text_scaled() Lua binding
lua_bindings.cpp:
- Added new lua_renderer_text_scaled() function
- Wraps renderer->draw_string_scaled() with proper scale support
- Registered as renderer.text_scaled(x, y, text, on, scale)
- Scale parameter defaults to 1 if omitted

Updated all 4 games to use text_scaled():
- simon_says.lua: All text now uses text_scaled with scale=2
- tic_tac_toe.lua: All text now uses text_scaled with scale=2
- memory_match.lua: All text now uses text_scaled with scale=2
- 2048.lua: All text now uses text_scaled with scale=2

This properly uses the C++ renderer's scaled text rendering instead of
workarounds in Lua, providing better performance and consistency.
2026-02-12 21:31:15 -05:00
Adolfo Reyna
fa7d2fd32f 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
2026-02-12 21:23:34 -05:00
Adolfo Reyna
a274fb04a1 Update Snake: wrap edges and halve speed
snake.lua:
- Changed wall collision to wrap around (toroidal grid)
- Snake now travels through edges instead of crashing
- Doubled move_speed from 10 to 20 frames (half speed)
- Updated speed increase cap from 3 to 5 frames (slower at max)
- Snake can now traverse indefinitely without losing to walls
2026-02-12 21:10:44 -05:00
Adolfo Reyna
a058476b42 Scale 2048 to fill screen
2048.lua:
- Removed hardcoded TILE_SIZE and TILE_SPACING constants
- Added get_tile_size() function that calculates tile dimensions based on screen width
- Added get_grid_start_x/y() to center grid
- Updated draw() to use dynamic sizing for all tiles
- 4x4 grid now scales proportionally on any screen size
2026-02-12 21:10:16 -05:00
Adolfo Reyna
2a9b17a539 Scale Memory Match to fill screen
memory_match.lua:
- Removed hardcoded CARD_SIZE and CARD_SPACING
- Added get_card_size() function that calculates card dimensions based on available screen space
- Grid now fills screen width (minus padding) and uses available height
- Added get_grid_start_x/y() to center grid
- All card positions and hit detection updated to use dynamic sizing
- Cards scale proportionally on any screen size while maintaining 4x4 layout
2026-02-12 21:09:46 -05:00
Adolfo Reyna
62716c7dc4 Scale Simon Says and Tic-Tac-Toe to fill screen
simon_says.lua:
- Removed hardcoded button positions
- Added get_buttons() function that calculates button size and position based on screen dimensions
- Buttons now use 10% screen padding and scale to fill available width
- 2x2 grid automatically scales with screen size

tic_tac_toe.lua:
- Replaced hardcoded CELL_SIZE with dynamic calculation
- Added get_cell_size() to compute size based on screen width
- Added get_grid_start_x/y() to center grid both horizontally and vertically
- Grid now scales to fill available space while maintaining 3x3 layout
- All cell positions updated to use dynamic functions

Both games now work on any screen size and scale proportionally.
2026-02-12 21:06:54 -05:00
Adolfo Reyna
b22170b62c Fix Lua game float-to-int conversion errors for renderer.circle()
All games had the same issue: renderer.circle() requires integer arguments,
but float calculations produced non-integer coordinates.

Fixed in all games using math.floor(x + 0.5) for proper rounding:
- pong.lua: Ball position
- air_hockey.lua: Puck position
- asteroids.lua: Asteroid positions
- ball.lua: Ball and trail positions, velocity line
- breakout.lua: Ball position
- flappy_bird.lua: Bird Y position
- counter.lua: Last touch marker position
- snake.lua: Food position (center calculation)
- tic_tac_toe.lua: O circle center position

Also fixed floating-point coordinate calculations in ball and line
drawing to ensure all coordinates are integers.
2026-02-12 20:51:26 -05:00
Adolfo Reyna
50793ac535 feat: add final 4 games for basic1 console
- 2048: Grid merging, directional movement, score tracking, win/draw detection
- Tic-Tac-Toe: Minimax AI opponent, perfect play, win detection
- Lunar Lander: Gravity + thrust physics, fuel management, landing validation
- Air Hockey: Refined paddle physics, puck acceleration, goal detection

All games tested for state transitions, collision logic, and win conditions.
Suite now complete with 10 classic games ready for SD card deployment.
2026-02-12 19:40:42 -05:00
Adolfo Reyna
53a2fb046b feat: add 6 lua games for basic1 console
- Pong: 2-player paddle and ball game with spin mechanics
- Flappy Bird: gravity physics, obstacle avoidance
- Breakout: paddle control, brick grid, collision detection
- Simon Says: sequence memory, animation timing
- Memory Match: pair matching, flip animations, grid layout
- Tetris: falling blocks, grid system, line clearing
- Asteroids: vector math, rotation, projectiles, enemy spawning

All games follow API conventions with state machines, touch input,
frame-based animation, and persistent game.vars state management.
2026-02-12 19:18:51 -05:00
Adolfo Reyna
47fc02f05c Fix frame update logic and emulator support
- Fix basic1.cpp loop to handle set_frame_updates(true) correctly with sleep
- Update emulator loop for concurrent input and frame updates
- Update emulator for SFML 3.0 compatibility
- Add INPUT.FRAME_TICK constant to Lua bindings
- Enable frame updates in snake.lua example
2026-02-10 23:27:31 -05:00
Adolfo Reyna
2a472fc29f Add frame tick system for continuous animation
- Added INPUT_FRAME_TICK event type to input_event.h
- Added wants_frame_updates() virtual method to Game base class
- Implemented frame tick logic in main loop (basic1.cpp and emulator/main.cpp)
- Added Lua bindings: game.set_frame_updates(bool) and INPUT.FRAME_TICK
- Updated LuaGame to support frame updates via registry flag
- Updated ball.lua to use continuous frame updates for smooth animation
- Both hardware and emulator now support continuous animation for physics/games
2026-02-07 13:20:10 -05:00
Adolfo Reyna
e6e4eca188 Add Lua 5.4 scripting integration for dynamic game loading
- Integrated Lua 5.4 engine (32-bit mode for embedded ARM)
- Created LuaGame wrapper class implementing Game interface
- Added C++ bindings exposing renderer, game state, and input to Lua
- Implemented SD card loader for automatic .lua game discovery
- Updated GameLauncher to support std::function for lambda captures
- Made Game class members public for Lua bindings access
- Added example Lua games: counter, snake, bouncing ball
- Included comprehensive API documentation

Games can now be written as .lua text files on SD card and loaded
without recompilation. Build size: 747KB UF2, Lua VM uses ~50-80KB RAM.
2026-02-07 11:56:03 -05:00