spinning asteroids
This commit is contained in:
parent
eae3659768
commit
63b296e19c
2 changed files with 5 additions and 4 deletions
|
|
@ -58,7 +58,7 @@ local function initState()
|
|||
local stage = game.asteroids.stages[asteroid.stage]
|
||||
asteroid.speed = stage.speed
|
||||
asteroid.facing = math.random() * phys.tau
|
||||
asteroid.spin = 2 + math.random() * 5
|
||||
asteroid.spin = 0.1 + math.random() * 0.1
|
||||
asteroid.radius = stage.radius
|
||||
asteroid.sprite = stage.sprite
|
||||
end
|
||||
|
|
@ -141,7 +141,7 @@ function love.update(dt)
|
|||
radius = radius,
|
||||
speed = speed,
|
||||
facing = math.random() * phys.tau,
|
||||
spin = 2 + math.random() * 5,
|
||||
spin = 0.1 + math.random() * 0.1,
|
||||
sprite = sprite,
|
||||
})
|
||||
table.insert(state.asteroids, {
|
||||
|
|
@ -152,7 +152,7 @@ function love.update(dt)
|
|||
radius = radius,
|
||||
speed = speed,
|
||||
facing = math.random() * phys.tau,
|
||||
spin = 2 + math.random() * 5,
|
||||
spin = 0.1 + math.random() * 0.1,
|
||||
sprite = sprite,
|
||||
})
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,12 +10,13 @@ function phys.intersects(actor1, actor2)
|
|||
end
|
||||
|
||||
-- updates the actor's location by applying the passage of time
|
||||
-- TODO spin
|
||||
function phys.update(actor, dt)
|
||||
assert(actor.speed >= 0)
|
||||
local dv = actor.speed * dt
|
||||
actor.x = actor.x + math.cos(actor.angle) * dv
|
||||
actor.y = actor.y + math.sin(actor.angle) * dv
|
||||
local dr = actor.spin * dt
|
||||
actor.facing = (actor.facing + dr) % phys.tau
|
||||
end
|
||||
|
||||
function phys.apply(actor, force)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue