ship sprite
This commit is contained in:
parent
1b1ed94b2f
commit
d498c7c78a
3 changed files with 14 additions and 10 deletions
1
asteroids/.gitignore
vendored
Normal file
1
asteroids/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
tmp
|
||||||
|
|
@ -11,6 +11,8 @@ local function initGame()
|
||||||
speed = 500,
|
speed = 500,
|
||||||
time = 4,
|
time = 4,
|
||||||
},
|
},
|
||||||
|
-- 99x75
|
||||||
|
sprite = love.graphics.newImage('resources/ship.png'),
|
||||||
},
|
},
|
||||||
asteroids = {
|
asteroids = {
|
||||||
stages = {
|
stages = {
|
||||||
|
|
@ -58,7 +60,7 @@ local function initState()
|
||||||
ship = {
|
ship = {
|
||||||
x = game.width / 2,
|
x = game.width / 2,
|
||||||
y = game.height / 2,
|
y = game.height / 2,
|
||||||
angle = 0,
|
angle = 3 * math.pi / 2,
|
||||||
speed = {
|
speed = {
|
||||||
x = 0,
|
x = 0,
|
||||||
y = 0,
|
y = 0,
|
||||||
|
|
@ -170,15 +172,16 @@ function love.draw()
|
||||||
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.setColor(0, 0, 1)
|
love.graphics.setColor(1, 1, 1)
|
||||||
love.graphics.circle('fill', state.ship.x, state.ship.y, game.ship.radius)
|
local scale = 2 * game.ship.radius / math.max(game.ship.sprite:getWidth(), game.ship.sprite:getHeight())
|
||||||
local shipCircleDistance = game.ship.radius * 2 / 3
|
love.graphics.draw(game.ship.sprite,
|
||||||
love.graphics.setColor(0, 1, 1)
|
state.ship.x,
|
||||||
love.graphics.circle(
|
state.ship.y,
|
||||||
'fill',
|
(state.ship.angle + math.pi / 2) % (math.pi * 2),
|
||||||
state.ship.x + math.cos(state.ship.angle) * shipCircleDistance,
|
scale,
|
||||||
state.ship.y + math.sin(state.ship.angle) * shipCircleDistance,
|
scale,
|
||||||
game.ship.radius / 6
|
game.ship.sprite:getWidth() / 2,
|
||||||
|
game.ship.sprite:getHeight() / 2
|
||||||
)
|
)
|
||||||
|
|
||||||
for _, bullet in ipairs(state.bullets) do
|
for _, bullet in ipairs(state.bullets) do
|
||||||
|
|
|
||||||
BIN
asteroids/resources/ship.png
Normal file
BIN
asteroids/resources/ship.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
Loading…
Add table
Add a link
Reference in a new issue