add ship actor
This commit is contained in:
parent
583efe528c
commit
38af0bcaa1
2 changed files with 47 additions and 25 deletions
|
|
@ -65,15 +65,7 @@ local function initState()
|
|||
return {
|
||||
debug = true,
|
||||
actors = actors,
|
||||
ship = {
|
||||
x = game.width / 2,
|
||||
y = game.height / 2,
|
||||
angle = 0,
|
||||
speed = 0,
|
||||
spin = 0,
|
||||
facing = phys.tau * 3 / 4,
|
||||
radius = game.ship.radius,
|
||||
},
|
||||
ship = actors.ships.new({}),
|
||||
bullets = {},
|
||||
asteroids = asteroids,
|
||||
controls = {
|
||||
|
|
@ -193,22 +185,7 @@ function love.draw()
|
|||
for x = -1, 1 do
|
||||
love.graphics.origin()
|
||||
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)
|
||||
local scale = 2 * game.ship.radius / math.max(game.ship.sprite:getWidth(), game.ship.sprite:getHeight())
|
||||
love.graphics.draw(game.ship.sprite,
|
||||
0,
|
||||
0,
|
||||
(state.ship.facing + phys.tau / 4) % phys.tau,
|
||||
scale,
|
||||
scale,
|
||||
game.ship.sprite:getWidth() / 2,
|
||||
game.ship.sprite:getHeight() / 2
|
||||
)
|
||||
-- TODO rocket exhaust
|
||||
love.graphics.pop()
|
||||
state.ship:draw()
|
||||
|
||||
for _, bullet in ipairs(state.bullets) do
|
||||
bullet:draw()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue