diff --git a/asteroids/.gitignore b/asteroids/.gitignore new file mode 100644 index 0000000..a9a5aec --- /dev/null +++ b/asteroids/.gitignore @@ -0,0 +1 @@ +tmp diff --git a/asteroids/main.lua b/asteroids/main.lua index de4136d..b5d28ef 100644 --- a/asteroids/main.lua +++ b/asteroids/main.lua @@ -11,6 +11,8 @@ local function initGame() speed = 500, time = 4, }, + -- 99x75 + sprite = love.graphics.newImage('resources/ship.png'), }, asteroids = { stages = { @@ -58,7 +60,7 @@ local function initState() ship = { x = game.width / 2, y = game.height / 2, - angle = 0, + angle = 3 * math.pi / 2, speed = { x = 0, y = 0, @@ -170,15 +172,16 @@ function love.draw() for x = -1, 1 do love.graphics.origin() love.graphics.translate(x * game.width, y * game.height) - love.graphics.setColor(0, 0, 1) - love.graphics.circle('fill', state.ship.x, state.ship.y, game.ship.radius) - local shipCircleDistance = game.ship.radius * 2 / 3 - love.graphics.setColor(0, 1, 1) - love.graphics.circle( - 'fill', - state.ship.x + math.cos(state.ship.angle) * shipCircleDistance, - state.ship.y + math.sin(state.ship.angle) * shipCircleDistance, - game.ship.radius / 6 + love.graphics.setColor(1, 1, 1) + local scale = 2 * game.ship.radius / math.max(game.ship.sprite:getWidth(), game.ship.sprite:getHeight()) + love.graphics.draw(game.ship.sprite, + state.ship.x, + state.ship.y, + (state.ship.angle + math.pi / 2) % (math.pi * 2), + scale, + scale, + game.ship.sprite:getWidth() / 2, + game.ship.sprite:getHeight() / 2 ) for _, bullet in ipairs(state.bullets) do diff --git a/asteroids/resources/ship.png b/asteroids/resources/ship.png new file mode 100644 index 0000000..cecbbed Binary files /dev/null and b/asteroids/resources/ship.png differ