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.
This commit is contained in:
@@ -148,9 +148,9 @@ function draw()
|
||||
local buttons = get_buttons()
|
||||
|
||||
if state == STATE_MENU then
|
||||
renderer.text(game.width() / 2 - 40, game.height() / 2 - 40, "SIMON SAYS", true, 2)
|
||||
renderer.text(game.width() / 2 - 50, game.height() / 2 - 10, "Repeat the sequence", true, 2)
|
||||
renderer.text(game.width() / 2 - 50, game.height() / 2 + 20, "Tap to Start", true, 2)
|
||||
renderer.text_scaled(game.width() / 2 - 40, game.height() / 2 - 40, "SIMON SAYS", true, 2)
|
||||
renderer.text_scaled(game.width() / 2 - 50, game.height() / 2 - 10, "Repeat the sequence", true, 2)
|
||||
renderer.text_scaled(game.width() / 2 - 50, game.height() / 2 + 20, "Tap to Start", true, 2)
|
||||
|
||||
else
|
||||
-- Draw buttons with highlight
|
||||
@@ -161,16 +161,16 @@ function draw()
|
||||
end
|
||||
|
||||
-- Draw score
|
||||
renderer.text(10, 10, "Level: " .. tostring(game.vars.score + 1), true, 2)
|
||||
renderer.text_scaled(10, 10, "Level: " .. tostring(game.vars.score + 1), true, 2)
|
||||
|
||||
if state == STATE_PLAYING and game.vars.waiting_for_input then
|
||||
renderer.text(game.width() / 2 - 40, game.height() - 20, "Your turn!", true, 2)
|
||||
renderer.text_scaled(game.width() / 2 - 40, game.height() - 20, "Your turn!", true, 2)
|
||||
end
|
||||
|
||||
if state == STATE_GAME_OVER then
|
||||
renderer.text(game.width() / 2 - 40, game.height() / 2 - 20, "GAME OVER", true, 2)
|
||||
renderer.text(game.width() / 2 - 30, game.height() / 2, "Level: " .. tostring(game.vars.score + 1), true, 2)
|
||||
renderer.text(game.width() / 2 - 60, game.height() / 2 + 20, "Tap to Restart", true, 2)
|
||||
renderer.text_scaled(game.width() / 2 - 40, game.height() / 2 - 20, "GAME OVER", true, 2)
|
||||
renderer.text_scaled(game.width() / 2 - 30, game.height() / 2, "Level: " .. tostring(game.vars.score + 1), true, 2)
|
||||
renderer.text_scaled(game.width() / 2 - 60, game.height() / 2 + 20, "Tap to Restart", true, 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user