diff --git a/Scripts/Game.gd b/Scripts/Game.gd index 59405cb..46c9825 100644 --- a/Scripts/Game.gd +++ b/Scripts/Game.gd @@ -42,8 +42,14 @@ func _process(delta): if has_node("Rocket"): var asteroid = asteroidObj.instance() 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) - asteroid.position.y = rand_range($Rocket.position.y - get_viewport_rect().size.y, $Rocket.position.y - 2 * get_viewport_rect().size.y) + 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.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) if asteroidSpawnRepeat == 5: asteroidSpawnRepeat = 0