Spawn explosions when defeated

This commit is contained in:
Raxki 2024-09-20 18:11:06 -04:00
parent b8d3cb02af
commit 5667725122
8 changed files with 125 additions and 8 deletions

BIN
Effects/brown explosion.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://6swccd2f6w18"
path="res://.godot/imported/brown explosion.png-b2601ab39a5d70b00473d802e7e76b8c.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Effects/brown explosion.png"
dest_files=["res://.godot/imported/brown explosion.png-b2601ab39a5d70b00473d802e7e76b8c.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -0,0 +1,49 @@
[gd_scene load_steps=8 format=3 uid="uid://cfqqf0f6pw4nn"]
[ext_resource type="Texture2D" uid="uid://6swccd2f6w18" path="res://Effects/brown explosion.png" id="1_nujtd"]
[ext_resource type="Script" path="res://Scripts/oneoff_effect.gd" id="2_pfod1"]
[sub_resource type="AtlasTexture" id="AtlasTexture_gtoss"]
atlas = ExtResource("1_nujtd")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_wtc3l"]
atlas = ExtResource("1_nujtd")
region = Rect2(32, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_870bu"]
atlas = ExtResource("1_nujtd")
region = Rect2(0, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ghq8a"]
atlas = ExtResource("1_nujtd")
region = Rect2(32, 32, 32, 32)
[sub_resource type="SpriteFrames" id="SpriteFrames_pto00"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_gtoss")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_wtc3l")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_870bu")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ghq8a")
}],
"loop": false,
"name": &"default",
"speed": 6.0
}]
[node name="BrownExplosion" type="AnimatedSprite2D"]
y_sort_enabled = true
texture_filter = 1
sprite_frames = SubResource("SpriteFrames_pto00")
autoplay = "default"
script = ExtResource("2_pfod1")
[connection signal="animation_finished" from="." to="." method="_on_animation_finished"]

View file

@ -0,0 +1,13 @@
extends Node2D
@onready var explosion_generator = $ExplosionGenerator
@onready var player = $HiroPlayer
@onready var ai = $HiroAI
func _on_player_defeated():
if Globals.nsfw == true:
explosion_generator.spawn(player.position)
func _on_ai_defeated():
if Globals.nsfw == true:
explosion_generator.spawn(ai.position)

View file

@ -0,0 +1,8 @@
extends Node
var explosion = preload("res://Effects/brown_explosion.tscn")
func spawn(location: Vector2):
var instance = explosion.instantiate()
instance.position = location + Vector2(0.0, -11.0)
get_parent().add_child(instance)

View file

@ -25,7 +25,7 @@ var wants_to_melee = false
signal _got_hurt(damage: int, attack_direction: Vector2)
signal attack_did_hit(other: Area2D, power: int, attack_direction: Vector2)
#signal defeated
signal defeated
func _ready():
state_machine.set_expression_property("melee_stage", 0)
@ -98,10 +98,8 @@ func _on_hurt_state_entered():
# you need to reset hit_counter back to 0.
if health <= 0:
# You could put the naked state in the AnimationTree here
# anim_playback.travel("naked")
state_machine.send_event("been_defeated")
#defeated.emit()
defeated.emit()
if hit_counter >= 4:
state_machine.send_event("will_reposition")

4
Scripts/oneoff_effect.gd Normal file
View file

@ -0,0 +1,4 @@
extends AnimatedSprite2D
func _on_animation_finished():
queue_free()

View file

@ -1,16 +1,19 @@
[gd_scene load_steps=9 format=3 uid="uid://bxuxjqxxqy7ce"]
[gd_scene load_steps=11 format=3 uid="uid://bxuxjqxxqy7ce"]
[ext_resource type="PackedScene" uid="uid://di21xheryhp0k" path="res://Hiro/hiro_player.tscn" id="1_c1gpq"]
[ext_resource type="PackedScene" uid="uid://b8sfype1vx5ad" path="res://Nem/nem_npc.tscn" id="1_sqt7d"]
[ext_resource type="Script" path="res://Scripts/Levels/arena_level.gd" id="1_y634h"]
[ext_resource type="PackedScene" uid="uid://bcwkugn6v3oy7" path="res://addons/godot_state_charts/utilities/state_chart_debugger.tscn" id="2_o5str"]
[ext_resource type="Texture2D" uid="uid://b40la2vyf4rn6" path="res://world/Fighting Dojo BG.png" id="4_elb6q"]
[ext_resource type="PackedScene" uid="uid://dd2km6qhpdicx" path="res://Hiro/hiro_ai.tscn" id="5_r7nw4"]
[ext_resource type="PackedScene" uid="uid://bakb5a7xe4qby" path="res://Reed/reed_player.tscn" id="6_cn8e2"]
[ext_resource type="Texture2D" uid="uid://dc12iaho4b8yl" path="res://world/walls.png" id="7_pp5dn"]
[ext_resource type="PackedScene" uid="uid://c503u0i421w34" path="res://world/pillar.tscn" id="8_mxq55"]
[ext_resource type="Script" path="res://Scripts/explosion_generator.gd" id="9_df2wo"]
[node name="Node2D" type="Node2D"]
[node name="Level" type="Node2D"]
y_sort_enabled = true
script = ExtResource("1_y634h")
[node name="MapElements" type="Node2D" parent="."]
y_sort_enabled = true
@ -91,9 +94,14 @@ initial_node_to_watch = NodePath("../HiroAI")
[node name="HiroAI" parent="." node_paths=PackedStringArray("player_character") instance=ExtResource("5_r7nw4")]
position = Vector2(135, 215)
player_character = NodePath("../HiroPlayer")
health = 400
attack_power = 5
health = 250
attack_power = 10
[node name="ExplosionGenerator" type="Node" parent="."]
script = ExtResource("9_df2wo")
[connection signal="attack_did_hit" from="HiroPlayer" to="HiroAI" method="_on_player_attack_did_hit"]
[connection signal="defeated" from="HiroPlayer" to="." method="_on_player_defeated"]
[connection signal="defeated" from="HiroPlayer" to="HiroAI" method="_on_player_been_defeated"]
[connection signal="attack_did_hit" from="HiroAI" to="HiroPlayer" method="_on_enemy_attack_did_hit"]
[connection signal="defeated" from="HiroAI" to="." method="_on_ai_defeated"]