lovexp/asteroids/actors.lua

35 lines
891 B
Lua
Raw Normal View History

2025-11-20 20:58:15 -05:00
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)
2025-11-20 21:07:12 -05:00
local stageIndex = asteroid.stage or #game.asteroids.stages
local stage = game.asteroids.stages[stageIndex]
2025-11-20 20:58:15 -05:00
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
2025-11-20 21:07:12 -05:00
instance.stage = stageIndex
2025-11-20 20:58:15 -05:00
setmetatable(instance, asteroids_mt)
return instance
end
return {
asteroids = asteroids,
}
end
return actors