splitting asteroids

This commit is contained in:
Donald Ball 2025-11-14 17:01:03 -05:00
parent c98ab26ac0
commit 78cd6176a8

View file

@ -72,6 +72,18 @@ function love.update(dt)
local asteroid = asteroids[asteroidIndex]
if areCirclesIntersecting(bullet.x, bullet.y, bulletRadius, asteroid.x, asteroid.y, asteroidRadius) then
table.remove(bullets, bulletIndex)
local angle1 = love.math.random() * (2 * math.pi)
local angle2 = (angle1 - math.pi) % (2 * math.pi)
table.insert(asteroids, {
x = asteroid.x,
y = asteroid.y,
angle = angle1,
})
table.insert(asteroids, {
x = asteroid.x,
y = asteroid.y,
angle = angle2,
})
table.remove(asteroids, asteroidIndex)
break
end