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,
|
||||
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
|
||||
|
|
|
|||
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