fuzzyworld

godot-shooter / commit

Added particles to the bomb explosion.

f85124dde4d1b60ccccd4916f8503a49f0c3fc87 · Pavel Safronov · 2023-11-17 15:33:14 -0800 · parents 93d86765201b

Added particles to the bomb explosion.
 scenes/World.gd   |  5 +++--
 weapons/Bomb.gd   |  5 ++---
 weapons/Bomb.tscn | 22 +++++++++++++++++++---
 3 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/scenes/World.gd b/scenes/World.gd
index 87c3086..5de4a83 100644
--- a/scenes/World.gd
+++ b/scenes/World.gd
@@ -29,7 +29,9 @@ func health_consumed(_data):
 	player.score += 1
 func gold_consumed(_data):
 	completed_objectives += 1
-	player.score += 5 * (completed_objectives+1)
+	var points = 5 * (completed_objectives+1)
+	player.score += points
+	player.show_message("+%f points" % points)
 func weapon_consumed(data):
 	var weapon: Weapon = data
 	var is_same_weapon = player.weapon.name == weapon.name
@@ -38,7 +40,6 @@ func weapon_consumed(data):
 	else:
 		player.weapon = weapon
 func bomb_consumed(data):
-	Utils.log("consumed a bomb")
 	var pos: Vector2 = data
 	var bomb = Bomb.instance()
 	$Environment.add_child(bomb)
diff --git a/weapons/Bomb.gd b/weapons/Bomb.gd
index 1ab59b7..ddac863 100644
--- a/weapons/Bomb.gd
+++ b/weapons/Bomb.gd
@@ -8,10 +8,9 @@ func _ready() -> void:
 	pass # Replace with function body.
 
 func _on_Area2D_body_entered(body: Node) -> void:
-#	var player = get_tree().get_nodes_in_group("player")[0]
-#	if body != player:
-#		var enemy: Enemy = body
 	if body is Enemy:
 		var already_hurt_enemy = hurt_enemies.has(body)
+		if already_hurt_enemy:
+			return
 		hurt_enemies.push_back(body)
 		body.hurt(damage_amount)
diff --git a/weapons/Bomb.tscn b/weapons/Bomb.tscn
index d442183..ef67e75 100644
--- a/weapons/Bomb.tscn
+++ b/weapons/Bomb.tscn
@@ -1,10 +1,11 @@
-[gd_scene load_steps=6 format=2]
+[gd_scene load_steps=8 format=2]
 
 [ext_resource path="res://weapons/Bomb.gd" type="Script" id=1]
 [ext_resource path="res://assets/kenney_crosshair-pack/PNG/White Retina/crosshair117.png" type="Texture" id=2]
+[ext_resource path="res://assets/kenney_simple-space/PNG/Retina/star_tiny.png" type="Texture" id=3]
 
 [sub_resource type="CircleShape2D" id=1]
-radius = 49.0102
+radius = 50.0
 
 [sub_resource type="Animation" id=2]
 length = 0.001
@@ -75,6 +76,9 @@ tracks/2/keys = {
 } ]
 }
 
+[sub_resource type="Curve" id=4]
+_data = [ Vector2( 0, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.119424, 0.184685 ), 0.0, 0.0, 0, 0, Vector2( 1, 0.0135136 ), 0.0598591, 0.0, 0, 0 ]
+
 [node name="Bomb" type="Node2D"]
 script = ExtResource( 1 )
 
@@ -90,6 +94,18 @@ texture = ExtResource( 2 )
 anims/RESET = SubResource( 2 )
 anims/explode = SubResource( 3 )
 
-[node name="Particles2D" type="Particles2D" parent="."]
+[node name="Particles2D" type="CPUParticles2D" parent="."]
+amount = 500
+texture = ExtResource( 3 )
+emission_shape = 1
+emission_sphere_radius = 50.0
+direction = Vector2( 0, 0 )
+spread = 180.0
+gravity = Vector2( 0, 0 )
+initial_velocity = 100.0
+initial_velocity_random = 1.0
+damping = 100.0
+scale_amount = 0.3
+scale_amount_curve = SubResource( 4 )
 
 [connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]