Browse Source

Attempt to allow asteroids to spawn to the sides as well as on top of

the viewport
master
Abheek Dhawan 3 years ago
parent
commit
31f83a5222
  1. 10
      Scripts/Game.gd

10
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

Loading…
Cancel
Save