lovexp/asteroids/actors.lua

32 lines
817 B
Lua

local phys = require("phys")
local inspect = require("inspect")
local actors = {}
function actors.buildActors(game)
local asteroids = {}
local asteroids_mt = { __index = asteroids }
function asteroids.new(asteroid)
local stage = game.asteroids.stages[asteroid.stage or #game.asteroids.stages]
local instance = {
angle = math.random() * phys.tau,
speed = stage.speed,
facing = math.random() * phys.tau,
spin = (math.random() - 0.5),
radius = stage.radius,
sprite = stage.sprite,
}
for k, v in pairs(asteroid) do
instance[k] = v
end
setmetatable(instance, asteroids_mt)
return instance
end
return {
asteroids = asteroids,
}
end
return actors