Minor testing logic update.
This commit is contained in:
parent
49a8913c14
commit
a0df0be862
1 changed files with 30 additions and 2 deletions
|
|
@ -26,8 +26,36 @@ func _on_spawn_timer_timeout() -> void:
|
||||||
if test_mode:
|
if test_mode:
|
||||||
_spawn_test_pickups()
|
_spawn_test_pickups()
|
||||||
else:
|
else:
|
||||||
# TODO: normal mode — spawn a single random pickup.
|
_spawn_normal_pickup()
|
||||||
pass
|
|
||||||
|
|
||||||
|
func _spawn_normal_pickup() -> void:
|
||||||
|
# Spawn a single random pickup at a position near the player.
|
||||||
|
if all_weapon_shots.is_empty():
|
||||||
|
return
|
||||||
|
|
||||||
|
var pickup := _spawn_pickup(
|
||||||
|
all_weapon_shots[randi() % all_weapon_shots.size()]
|
||||||
|
)
|
||||||
|
if pickup == null or not is_instance_valid(pickup):
|
||||||
|
return
|
||||||
|
|
||||||
|
# Position: centered horizontally, above the player with vertical padding.
|
||||||
|
var player_node := get_node_or_null("../Player")
|
||||||
|
if player_node != null:
|
||||||
|
pickup.position = Vector2(
|
||||||
|
randf_range(40.0, screensize.x - 40.0),
|
||||||
|
player_node.position.y - randf_range(80.0, 200.0)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
pickup.position = Vector2(
|
||||||
|
randf_range(40.0, screensize.x - 40.0),
|
||||||
|
randf_range(30.0, screensize.y * 0.4)
|
||||||
|
)
|
||||||
|
|
||||||
|
add_child(pickup)
|
||||||
|
_pickups_spawned += 1
|
||||||
|
_pickups_remaining = max(_pickups_remaining, _pickups_spawned)
|
||||||
|
|
||||||
|
|
||||||
func _spawn_test_pickups() -> void:
|
func _spawn_test_pickups() -> void:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue