From 7cb7946584a71b41aaba838dec453051cf4e3fd6 Mon Sep 17 00:00:00 2001 From: pennyrigate Date: Mon, 6 Nov 2023 00:23:29 -0500 Subject: [PATCH] rocks splash (fixes #210 fixes #211) --- maps/canopy.tscn | 2 +- maps/graveyard.tscn | 2 +- objects/environment/rock/rock.gd | 10 ++++++++++ objects/environment/rock/rock.tscn | 2 ++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/maps/canopy.tscn b/maps/canopy.tscn index ab33889..5f1383f 100644 --- a/maps/canopy.tscn +++ b/maps/canopy.tscn @@ -54,7 +54,7 @@ lore_entries = [ ExtResource( 23 ), ExtResource( 24 ), ExtResource( 25 ), ExtRes [node name="Sprite" type="Sprite" parent="Camera2D"] position = Vector2( 128, 96 ) -z_index = -2 +z_index = -260 texture = ExtResource( 3 ) __meta__ = { "_edit_lock_": true diff --git a/maps/graveyard.tscn b/maps/graveyard.tscn index f084225..7aedade 100644 --- a/maps/graveyard.tscn +++ b/maps/graveyard.tscn @@ -72,7 +72,7 @@ collision_mask = 0 format = 1 tile_data = PoolIntArray( 196694, -1073741823, 0, 196696, -1610612735, 0, 262228, -1610612735, 0, 589914, -1073741823, 0, 720938, -1073741823, 0, 720971, -1073741823, 0, 786474, -1073741823, 0, 786520, 1, 0, 852006, -1073741823, 0, 917542, -1073741823, 0, 1048643, 1, 0 ) -[node name="DeathNoBlood" type="TileMap" parent="." groups=["death", "no_blood"]] +[node name="DeathNoBlood" type="TileMap" parent="." groups=["death", "has_splash", "no_blood"]] tile_set = ExtResource( 6 ) cell_size = Vector2( 8, 8 ) collision_layer = 32 diff --git a/objects/environment/rock/rock.gd b/objects/environment/rock/rock.gd index 61d90cb..7bc5ee2 100644 --- a/objects/environment/rock/rock.gd +++ b/objects/environment/rock/rock.gd @@ -1,6 +1,7 @@ extends KinematicBody2D var velocity: Vector2 = Vector2.ZERO +const SplashParticles = preload("res://objects/environment/splash/splash_particles.tscn") func _physics_process(delta): if not is_on_floor(): @@ -21,3 +22,12 @@ func _on_Hitbox_area_entered(area): var enemy = area.get_owner() if enemy.global_position.y > global_position.y and velocity.y > 0: enemy.die() + + +func _on_Hitbox_body_entered(body): + if body.is_in_group("has_splash"): + var particles = SplashParticles.instance() + particles.global_position = global_position + particles.color = body.splash_color + particles.emitting = true + get_parent().add_child(particles) diff --git a/objects/environment/rock/rock.tscn b/objects/environment/rock/rock.tscn index a0aa5c4..aa761b0 100644 --- a/objects/environment/rock/rock.tscn +++ b/objects/environment/rock/rock.tscn @@ -33,9 +33,11 @@ shape = SubResource( 2 ) [node name="Hitbox" type="Area2D" parent="." groups=["squash"]] position = Vector2( -1, 0 ) collision_layer = 5 +collision_mask = 33 [node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"] position = Vector2( 5, 4 ) shape = SubResource( 3 ) [connection signal="area_entered" from="Hitbox" to="." method="_on_Hitbox_area_entered"] +[connection signal="body_entered" from="Hitbox" to="." method="_on_Hitbox_body_entered"]