explore graphics stack

This commit is contained in:
Donald Ball 2025-11-20 20:12:23 -05:00
parent 63b296e19c
commit 21c432f583

View file

@ -67,6 +67,7 @@ local function initState()
joystick = love.joystick.getJoysticks()[1] joystick = love.joystick.getJoysticks()[1]
end end
return { return {
debug = true,
ship = { ship = {
x = game.width / 2, x = game.width / 2,
y = game.height / 2, y = game.height / 2,
@ -204,21 +205,31 @@ function love.gamepadpressed(joystick, button)
end end
function love.draw() function love.draw()
if state.debug then
love.graphics.setColor(1, 1, 1)
love.graphics.line(game.width / 2, 0, game.width / 2, game.height)
love.graphics.line(0, game.height / 2, game.width, game.height / 2)
end
for y = -1, 1 do for y = -1, 1 do
for x = -1, 1 do for x = -1, 1 do
love.graphics.origin() love.graphics.origin()
love.graphics.translate(x * game.width, y * game.height) love.graphics.translate(x * game.width, y * game.height)
love.graphics.push()
love.graphics.translate(state.ship.x, state.ship.y)
love.graphics.setColor(1, 1, 1) love.graphics.setColor(1, 1, 1)
local scale = 2 * game.ship.radius / math.max(game.ship.sprite:getWidth(), game.ship.sprite:getHeight()) local scale = 2 * game.ship.radius / math.max(game.ship.sprite:getWidth(), game.ship.sprite:getHeight())
love.graphics.draw(game.ship.sprite, love.graphics.draw(game.ship.sprite,
state.ship.x, 0,
state.ship.y, 0,
(state.ship.facing + phys.tau / 4) % phys.tau, (state.ship.facing + phys.tau / 4) % phys.tau,
scale, scale,
scale, scale,
game.ship.sprite:getWidth() / 2, game.ship.sprite:getWidth() / 2,
game.ship.sprite:getHeight() / 2 game.ship.sprite:getHeight() / 2
) )
-- TODO rocket exhaust
love.graphics.pop()
for _, bullet in ipairs(state.bullets) do for _, bullet in ipairs(state.bullets) do
love.graphics.setColor(0, 1, 0) love.graphics.setColor(0, 1, 0)