reduce asteroid init

This commit is contained in:
Donald Ball 2025-11-20 21:07:12 -05:00
parent b2b70ee910
commit c1c774338e
2 changed files with 7 additions and 19 deletions

View file

@ -8,7 +8,8 @@ function actors.buildActors(game)
local asteroids_mt = { __index = asteroids }
function asteroids.new(asteroid)
local stage = game.asteroids.stages[asteroid.stage or #game.asteroids.stages]
local stageIndex = asteroid.stage or #game.asteroids.stages
local stage = game.asteroids.stages[stageIndex]
local instance = {
angle = math.random() * phys.tau,
speed = stage.speed,
@ -20,6 +21,7 @@ function actors.buildActors(game)
for k, v in pairs(asteroid) do
instance[k] = v
end
instance.stage = stageIndex
setmetatable(instance, asteroids_mt)
return instance
end