splitting asteroids
This commit is contained in:
parent
c98ab26ac0
commit
78cd6176a8
1 changed files with 12 additions and 0 deletions
12
main.lua
12
main.lua
|
|
@ -72,6 +72,18 @@ function love.update(dt)
|
||||||
local asteroid = asteroids[asteroidIndex]
|
local asteroid = asteroids[asteroidIndex]
|
||||||
if areCirclesIntersecting(bullet.x, bullet.y, bulletRadius, asteroid.x, asteroid.y, asteroidRadius) then
|
if areCirclesIntersecting(bullet.x, bullet.y, bulletRadius, asteroid.x, asteroid.y, asteroidRadius) then
|
||||||
table.remove(bullets, bulletIndex)
|
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)
|
table.remove(asteroids, asteroidIndex)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue