|
@ -42,8 +42,14 @@ func _process(delta): |
|
|
if has_node("Rocket"): |
|
|
if has_node("Rocket"): |
|
|
var asteroid = asteroidObj.instance() |
|
|
var asteroid = asteroidObj.instance() |
|
|
add_child(asteroid) |
|
|
add_child(asteroid) |
|
|
asteroid.position.x = rand_range($Rocket.position.x - get_viewport_rect().size.x/2, $Rocket.position.x + get_viewport_rect().size.x/2) |
|
|
spawnx = rand_range($Rocket.position.x - get_viewport_rect().size.x, $Rocket.position.x + get_viewport_rect().size.x) |
|
|
|
|
|
asteroid.position.x = spawnx |
|
|
|
|
|
if (spawnx < $Rocket.position.x - get_viewport_rect().size.x/2 or spawnx > $Rocket.position.x + get_viewport_rect().size.x/2): |
|
|
|
|
|
asteroid.position.y = rand_range($Rocket.position.y + get_viewport_rect().size.y/2, $Rocket.position.y - 2 * get_viewport_rect().size.y) |
|
|
|
|
|
else: |
|
|
asteroid.position.y = rand_range($Rocket.position.y - get_viewport_rect().size.y, $Rocket.position.y - 2 * get_viewport_rect().size.y) |
|
|
asteroid.position.y = rand_range($Rocket.position.y - get_viewport_rect().size.y, $Rocket.position.y - 2 * get_viewport_rect().size.y) |
|
|
|
|
|
#asteroid.position.x = rand_range($Rocket.position.x - get_viewport_rect().size.x/2, $Rocket.position.x + get_viewport_rect().size.x/2) |
|
|
|
|
|
#asteroid.position.y = rand_range($Rocket.position.y - get_viewport_rect().size.y, $Rocket.position.y - 2 * get_viewport_rect().size.y) |
|
|
asteroid.rotation = rand_range(0, 6.28) |
|
|
asteroid.rotation = rand_range(0, 6.28) |
|
|
if asteroidSpawnRepeat == 5: |
|
|
if asteroidSpawnRepeat == 5: |
|
|
asteroidSpawnRepeat = 0 |
|
|
asteroidSpawnRepeat = 0 |
|
|