fuzzyworld

godot-shooter / commit

Fade in the power-ups as they appear, lower their population size, and spawn them at (1 + randf()), so they should spawn in a uniform donut outside the current screen.

6ae9f305f9c16f0309f3490042d7b9c1a620f4d0 · Pavel Safronov · 2023-11-07 09:39:13 -0800 · parents da9d123af3b8

Fade in the power-ups as they appear, lower their population size, and spawn them at (1 + randf()), so they should spawn in a uniform donut outside the current screen.
 HealPowerUp.gd  | 4 ++--
 SpeedPowerUp.gd | 4 ++--
 World.gd        | 8 ++++----
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/HealPowerUp.gd b/HealPowerUp.gd
index feff1c9..53278ff 100644
--- a/HealPowerUp.gd
+++ b/HealPowerUp.gd
@@ -2,8 +2,8 @@ extends Node2D
 
 export var heal_amount = 1
 
-#func _ready() -> void:
-#	$AnimationPlayer.play("fade_in")
+func _ready() -> void:
+	$AnimationPlayer.play("fade_in")
 
 func _on_Area2D_body_entered(body: Node) -> void:
 	if body.has_method("heal"):
diff --git a/SpeedPowerUp.gd b/SpeedPowerUp.gd
index d525408..98dea1f 100644
--- a/SpeedPowerUp.gd
+++ b/SpeedPowerUp.gd
@@ -2,8 +2,8 @@ extends Node2D
 
 export var speed_amount = 10
 
-#func _ready() -> void:
-#	$AnimationPlayer.play("fade_in")
+func _ready() -> void:
+	$AnimationPlayer.play("fade_in")
 
 func _on_Area2D_body_entered(body: Node) -> void:
 	if body.has_method("speed_up"):
diff --git a/World.gd b/World.gd
index 8ed7929..513055a 100644
--- a/World.gd
+++ b/World.gd
@@ -8,8 +8,8 @@ var destination: Vector2
 var is_destination_set = false
 var min_items_dict = {
 	"create_enemy": 10,
-	"create_health": 10,
-	"create_speed": 10,
+	"create_health": 2,
+	"create_speed": 2,
 }
 
 func enemy_killed():
@@ -25,13 +25,13 @@ func create_enemy():
 
 func create_health():
 	var health = Health.instance()
-	health.position = get_new_item_pos()
+	health.position = get_new_item_pos(1 + randf())
 	health.connect("tree_exiting", self, "create_health")
 	$Environment.call_deferred("add_child", health)
 
 func create_speed():
 	var speed = Speed.instance()
-	speed.position = get_new_item_pos()
+	speed.position = get_new_item_pos(1 + randf())
 	speed.connect("tree_exiting", self, "create_speed")
 	$Environment.call_deferred("add_child", speed)