feat:fix animations, add sfx + bgm, healthbar, spawner node

This commit is contained in:
Alexis Williams 2024-08-18 03:04:28 +01:00
parent d9bc66acc0
commit 39f77e671f
29 changed files with 988 additions and 387 deletions

BIN
assets/EnemyHurt.wav Normal file

Binary file not shown.

View file

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://dxnxix8qrr6tq"
path="res://.godot/imported/EnemyHurt.wav-fb6c033455c8fd2c64ccfdf0c818a65a.sample"
[deps]
source_file="res://assets/EnemyHurt.wav"
dest_files=["res://.godot/imported/EnemyHurt.wav-fb6c033455c8fd2c64ccfdf0c818a65a.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

BIN
assets/Explode.wav Normal file

Binary file not shown.

24
assets/Explode.wav.import Normal file
View file

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://dfrc2luquqqlw"
path="res://.godot/imported/Explode.wav-1025ed9a84beb2ef982eff388b1bbeea.sample"
[deps]
source_file="res://assets/Explode.wav"
dest_files=["res://.godot/imported/Explode.wav-1025ed9a84beb2ef982eff388b1bbeea.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

BIN
assets/Go.aseprite Normal file

Binary file not shown.

14
assets/Go.aseprite.import Normal file
View file

@ -0,0 +1,14 @@
[remap]
importer="aseprite_wizard.plugin.noop"
type="PackedDataContainer"
uid="uid://davrou2v4qw2i"
path="res://.godot/imported/Go.aseprite-25f8aee4e191af232eb3cbeb790ac21b.res"
[deps]
source_file="res://assets/Go.aseprite"
dest_files=["res://.godot/imported/Go.aseprite-25f8aee4e191af232eb3cbeb790ac21b.res"]
[params]

Binary file not shown.

View file

@ -0,0 +1,14 @@
[remap]
importer="aseprite_wizard.plugin.noop"
type="PackedDataContainer"
uid="uid://dgqr8sd2xeyni"
path="res://.godot/imported/HealthBorder.aseprite-114a2c214cb1e322dfa2a303d28a908a.res"
[deps]
source_file="res://assets/HealthBorder.aseprite"
dest_files=["res://.godot/imported/HealthBorder.aseprite-114a2c214cb1e322dfa2a303d28a908a.res"]
[params]

BIN
assets/Level1BGAudio.wav Normal file

Binary file not shown.

View file

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://ce3soc3run6um"
path="res://.godot/imported/Level1BGAudio.wav-e7b60b70a4523876968adf4a6c8994a4.sample"
[deps]
source_file="res://assets/Level1BGAudio.wav"
dest_files=["res://.godot/imported/Level1BGAudio.wav-e7b60b70a4523876968adf4a6c8994a4.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

Binary file not shown.

BIN
assets/PlayerDeathSound.wav Normal file

Binary file not shown.

View file

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://du0f57xgcxuxf"
path="res://.godot/imported/PlayerDeathSound.wav-064911359937abe1fa0c8cddb7e84ea4.sample"
[deps]
source_file="res://assets/PlayerDeathSound.wav"
dest_files=["res://.godot/imported/PlayerDeathSound.wav-064911359937abe1fa0c8cddb7e84ea4.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

BIN
assets/PlayerHurt.wav Normal file

Binary file not shown.

View file

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://cir5d1qi0hcev"
path="res://.godot/imported/PlayerHurt.wav-7dea0e9202985b5dd27d18b772b40ee2.sample"
[deps]
source_file="res://assets/PlayerHurt.wav"
dest_files=["res://.godot/imported/PlayerHurt.wav-7dea0e9202985b5dd27d18b772b40ee2.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

BIN
assets/TopBottom.aseprite Normal file

Binary file not shown.

View file

@ -0,0 +1,14 @@
[remap]
importer="aseprite_wizard.plugin.noop"
type="PackedDataContainer"
uid="uid://crfosyduwl8ln"
path="res://.godot/imported/TopBottom.aseprite-4492d70b38a804feac46851918def1b1.res"
[deps]
source_file="res://assets/TopBottom.aseprite"
dest_files=["res://.godot/imported/TopBottom.aseprite-4492d70b38a804feac46851918def1b1.res"]
[params]

BIN
assets/export/health-.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cliy3s4yykb3k"
path="res://.godot/imported/health-.png-4c2f44980382af653fa17687a74ed113.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/export/health-.png"
dest_files=["res://.godot/imported/health-.png-4c2f44980382af653fa17687a74ed113.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dailayr5c75eu"
path="res://.godot/imported/top-bottom-.png-f040386dc0350eeaa8c2f46c3e11e100.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/export/top-bottom-.png"
dest_files=["res://.godot/imported/top-bottom-.png-f040386dc0350eeaa8c2f46c3e11e100.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

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,8 @@
[gd_scene load_steps=27 format=3 uid="uid://bxbpvgteyfh02"] [gd_scene load_steps=28 format=3 uid="uid://bxbpvgteyfh02"]
[ext_resource type="Script" path="res://scripts/viruling.gd" id="1_eevnl"] [ext_resource type="Script" path="res://scripts/viruling.gd" id="1_eevnl"]
[ext_resource type="Texture2D" uid="uid://djjun1p0rx1ap" path="res://assets/export/viruling-.png" id="1_i45rj"] [ext_resource type="Texture2D" uid="uid://djjun1p0rx1ap" path="res://assets/export/viruling-.png" id="1_i45rj"]
[ext_resource type="AudioStream" uid="uid://dfrc2luquqqlw" path="res://assets/Explode.wav" id="3_hno7f"]
[sub_resource type="CircleShape2D" id="CircleShape2D_gi7h4"] [sub_resource type="CircleShape2D" id="CircleShape2D_gi7h4"]
radius = 17.0294 radius = 17.0294
@ -213,3 +214,7 @@ one_shot = true
[node name="DeathTimer" type="Timer" parent="."] [node name="DeathTimer" type="Timer" parent="."]
wait_time = 0.55 wait_time = 0.55
one_shot = true one_shot = true
[node name="ExplosionSFX" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("3_hno7f")
volume_db = 10.0

121
levels/level1/sta1910.tmp Normal file
View file

@ -0,0 +1,121 @@
[gd_scene load_steps=10 format=3 uid="uid://cei5gjgfoginb"]
[ext_resource type="Script" path="res://scripts/stageController.gd" id="1_m1n7w"]
[ext_resource type="Texture2D" uid="uid://bynsxkfd4t4cn" path="res://assets/export/stage1.png" id="2_48003"]
[ext_resource type="AudioStream" uid="uid://ce3soc3run6um" path="res://assets/Level1BGAudio.wav" id="2_qcnna"]
[ext_resource type="PackedScene" uid="uid://cjiuycwqqxaxn" path="res://components/Player.tscn" id="2_sxo5w"]
[ext_resource type="PackedScene" uid="uid://bab4ac3s2n0o1" path="res://components/Borders.tscn" id="3_04xvl"]
[ext_resource type="PackedScene" uid="uid://bxbpvgteyfh02" path="res://components/Viruling.tscn" id="5_w7lww"]
[ext_resource type="PackedScene" path="res://components/Bars.tscn" id="6_u2jd3"]
[ext_resource type="Texture2D" uid="uid://dailayr5c75eu" path="res://assets/export/top-bottom-.png" id="7_gw1ay"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_h5wua"]
size = Vector2(492, 101)
[node name="World" type="Node2D"]
position = Vector2(344, 240)
script = ExtResource("1_m1n7w")
next_stage = "res://levels/level1/stage2.tscn"
[node name="BGM" type="AudioStreamPlayer2D" parent="."]
position = Vector2(-344, -240)
stream = ExtResource("2_qcnna")
[node name="Bars" parent="." instance=ExtResource("6_u2jd3")]
offset_left = -344.0
offset_top = -240.0
offset_right = -304.0
offset_bottom = -200.0
[node name="Background" type="Sprite2D" parent="."]
position = Vector2(-28, -64)
scale = Vector2(1.01667, 1)
texture = ExtResource("2_48003")
[node name="Player" parent="." instance=ExtResource("2_sxo5w")]
position = Vector2(-233, -21)
[node name="Borders" parent="." instance=ExtResource("3_04xvl")]
position = Vector2(-272, -240)
[node name="Floor" type="StaticBody2D" parent="."]
[node name="Sprite2D" type="Sprite2D" parent="Floor"]
z_index = 1
texture_filter = 1
position = Vector2(-28, -191)
scale = Vector2(1, 0.283333)
texture = ExtResource("7_gw1ay")
flip_v = true
metadata/_aseprite_wizard_config_ = {
"i_mode": 1,
"keep_anim_length": false,
"layer": "",
"o_ex_p": "",
"o_folder": "res://assets/export",
"o_name": "top-bottom-",
"only_visible": true,
"player": "",
"slice": "",
"source": "res://assets/TopBottom.aseprite"
}
metadata/_aseprite_wizard_interface_config_ = {
"output_section": true
}
metadata/_aseprite_wizard_source_file_hash_ = "1b764edd2623a4481e3cf82f9aa840f7"
[node name="CollisionShape2D" type="CollisionShape2D" parent="Floor"]
position = Vector2(-28, 69)
shape = SubResource("RectangleShape2D_h5wua")
[node name="Ceiling" type="StaticBody2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ceiling"]
position = Vector2(-29, -190)
shape = SubResource("RectangleShape2D_h5wua")
[node name="Sprite2D" type="Sprite2D" parent="Ceiling"]
z_index = 1
texture_filter = 1
position = Vector2(-28.5, 68.25)
scale = Vector2(0.99591, 0.284722)
texture = ExtResource("7_gw1ay")
metadata/_aseprite_wizard_config_ = {
"i_mode": 1,
"keep_anim_length": false,
"layer": "",
"o_ex_p": "",
"o_folder": "res://assets/export",
"o_name": "top-bottom-",
"only_visible": true,
"player": "",
"slice": "",
"source": "res://assets/TopBottom.aseprite"
}
metadata/_aseprite_wizard_interface_config_ = {
"output_section": true
}
metadata/_aseprite_wizard_source_file_hash_ = "1b764edd2623a4481e3cf82f9aa840f7"
[node name="Level1Spawner" type="Node2D" parent="."]
[node name="Viruling" parent="Level1Spawner" instance=ExtResource("5_w7lww")]
position = Vector2(528, -55)
[node name="Viruling7" parent="Level1Spawner" instance=ExtResource("5_w7lww")]
position = Vector2(827, 6)
[node name="Viruling6" parent="Level1Spawner" instance=ExtResource("5_w7lww")]
position = Vector2(923, -27)
[node name="Viruling5" parent="Level1Spawner" instance=ExtResource("5_w7lww")]
position = Vector2(727, -3)
[node name="Viruling4" parent="Level1Spawner" instance=ExtResource("5_w7lww")]
position = Vector2(431, -41)
[node name="Viruling3" parent="Level1Spawner" instance=ExtResource("5_w7lww")]
position = Vector2(334, -4)
[node name="Viruling2" parent="Level1Spawner" instance=ExtResource("5_w7lww")]
position = Vector2(627, -33)

View file

@ -1,14 +1,13 @@
[gd_scene load_steps=9 format=3 uid="uid://cei5gjgfoginb"] [gd_scene load_steps=10 format=3 uid="uid://cei5gjgfoginb"]
[ext_resource type="Script" path="res://scripts/stageController.gd" id="1_m1n7w"] [ext_resource type="Script" path="res://scripts/stageController.gd" id="1_m1n7w"]
[ext_resource type="Texture2D" uid="uid://bynsxkfd4t4cn" path="res://assets/export/stage1.png" id="2_48003"] [ext_resource type="Texture2D" uid="uid://bynsxkfd4t4cn" path="res://assets/export/stage1.png" id="2_48003"]
[ext_resource type="AudioStream" uid="uid://ce3soc3run6um" path="res://assets/Level1BGAudio.wav" id="2_qcnna"]
[ext_resource type="PackedScene" uid="uid://cjiuycwqqxaxn" path="res://components/Player.tscn" id="2_sxo5w"] [ext_resource type="PackedScene" uid="uid://cjiuycwqqxaxn" path="res://components/Player.tscn" id="2_sxo5w"]
[ext_resource type="PackedScene" uid="uid://bab4ac3s2n0o1" path="res://components/Borders.tscn" id="3_04xvl"] [ext_resource type="PackedScene" uid="uid://bab4ac3s2n0o1" path="res://components/Borders.tscn" id="3_04xvl"]
[ext_resource type="PackedScene" uid="uid://bxbpvgteyfh02" path="res://components/Viruling.tscn" id="5_w7lww"] [ext_resource type="PackedScene" uid="uid://bxbpvgteyfh02" path="res://components/Viruling.tscn" id="5_w7lww"]
[ext_resource type="PackedScene" uid="uid://clptnshbcs6cn" path="res://components/Bars.tscn" id="6_u2jd3"] [ext_resource type="PackedScene" path="res://components/Bars.tscn" id="6_u2jd3"]
[ext_resource type="Texture2D" uid="uid://dailayr5c75eu" path="res://assets/export/top-bottom-.png" id="7_gw1ay"]
[sub_resource type="QuadMesh" id="QuadMesh_seics"]
size = Vector2(480, 64)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_h5wua"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_h5wua"]
size = Vector2(492, 101) size = Vector2(492, 101)
@ -18,6 +17,10 @@ position = Vector2(344, 240)
script = ExtResource("1_m1n7w") script = ExtResource("1_m1n7w")
next_stage = "res://levels/level1/stage2.tscn" next_stage = "res://levels/level1/stage2.tscn"
[node name="BGM" type="AudioStreamPlayer2D" parent="."]
position = Vector2(-344, -240)
stream = ExtResource("2_qcnna")
[node name="Bars" parent="." instance=ExtResource("6_u2jd3")] [node name="Bars" parent="." instance=ExtResource("6_u2jd3")]
offset_left = -344.0 offset_left = -344.0
offset_top = -240.0 offset_top = -240.0
@ -29,36 +32,37 @@ position = Vector2(-28, -64)
scale = Vector2(1.01667, 1) scale = Vector2(1.01667, 1)
texture = ExtResource("2_48003") texture = ExtResource("2_48003")
[node name="Player" parent="." instance=ExtResource("2_sxo5w")]
position = Vector2(-233, -21)
[node name="Borders" parent="." instance=ExtResource("3_04xvl")] [node name="Borders" parent="." instance=ExtResource("3_04xvl")]
position = Vector2(-272, -240) position = Vector2(-272, -240)
[node name="Player" parent="." instance=ExtResource("2_sxo5w")]
position = Vector2(-240, -16)
[node name="Viruling" parent="." instance=ExtResource("5_w7lww")]
position = Vector2(440, -96)
[node name="Viruling2" parent="." instance=ExtResource("5_w7lww")]
position = Vector2(240, -48)
[node name="Viruling2" parent="Viruling2" instance=ExtResource("5_w7lww")]
position = Vector2(72, 40)
[node name="Viruling3" parent="." instance=ExtResource("5_w7lww")]
position = Vector2(424, -32)
[node name="Viruling4" parent="." instance=ExtResource("5_w7lww")]
position = Vector2(320, -104)
[node name="Viruling2" parent="Viruling4" instance=ExtResource("5_w7lww")]
position = Vector2(240, -48)
[node name="Floor" type="StaticBody2D" parent="."] [node name="Floor" type="StaticBody2D" parent="."]
[node name="MeshInstance2D" type="MeshInstance2D" parent="Floor"] [node name="Sprite2D" type="Sprite2D" parent="Floor"]
position = Vector2(-28, 68) z_index = 1
scale = Vector2(1.01667, 1.625) texture_filter = 1
mesh = SubResource("QuadMesh_seics") position = Vector2(-28, -191)
scale = Vector2(1, 0.283333)
texture = ExtResource("7_gw1ay")
flip_v = true
metadata/_aseprite_wizard_config_ = {
"i_mode": 1,
"keep_anim_length": false,
"layer": "",
"o_ex_p": "",
"o_folder": "res://assets/export",
"o_name": "top-bottom-",
"only_visible": true,
"player": "",
"slice": "",
"source": "res://assets/TopBottom.aseprite"
}
metadata/_aseprite_wizard_interface_config_ = {
"output_section": true
}
metadata/_aseprite_wizard_source_file_hash_ = "1b764edd2623a4481e3cf82f9aa840f7"
[node name="CollisionShape2D" type="CollisionShape2D" parent="Floor"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Floor"]
position = Vector2(-28, 69) position = Vector2(-28, 69)
@ -66,11 +70,52 @@ shape = SubResource("RectangleShape2D_h5wua")
[node name="Ceiling" type="StaticBody2D" parent="."] [node name="Ceiling" type="StaticBody2D" parent="."]
[node name="MeshInstance2D" type="MeshInstance2D" parent="Ceiling"]
position = Vector2(-28, -192)
scale = Vector2(1.01667, 1.625)
mesh = SubResource("QuadMesh_seics")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ceiling"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Ceiling"]
position = Vector2(-30, -189.5) position = Vector2(-29, -190)
shape = SubResource("RectangleShape2D_h5wua") shape = SubResource("RectangleShape2D_h5wua")
[node name="Sprite2D" type="Sprite2D" parent="Ceiling"]
z_index = 1
texture_filter = 1
position = Vector2(-28.5, 68.25)
scale = Vector2(0.99591, 0.284722)
texture = ExtResource("7_gw1ay")
metadata/_aseprite_wizard_config_ = {
"i_mode": 1,
"keep_anim_length": false,
"layer": "",
"o_ex_p": "",
"o_folder": "res://assets/export",
"o_name": "top-bottom-",
"only_visible": true,
"player": "",
"slice": "",
"source": "res://assets/TopBottom.aseprite"
}
metadata/_aseprite_wizard_interface_config_ = {
"output_section": true
}
metadata/_aseprite_wizard_source_file_hash_ = "1b764edd2623a4481e3cf82f9aa840f7"
[node name="Level1Spawner" type="Node2D" parent="."]
[node name="Viruling" parent="Level1Spawner" instance=ExtResource("5_w7lww")]
position = Vector2(528, -55)
[node name="Viruling7" parent="Level1Spawner" instance=ExtResource("5_w7lww")]
position = Vector2(827, 6)
[node name="Viruling6" parent="Level1Spawner" instance=ExtResource("5_w7lww")]
position = Vector2(923, -27)
[node name="Viruling5" parent="Level1Spawner" instance=ExtResource("5_w7lww")]
position = Vector2(727, -3)
[node name="Viruling4" parent="Level1Spawner" instance=ExtResource("5_w7lww")]
position = Vector2(431, -41)
[node name="Viruling3" parent="Level1Spawner" instance=ExtResource("5_w7lww")]
position = Vector2(334, -4)
[node name="Viruling2" parent="Level1Spawner" instance=ExtResource("5_w7lww")]
position = Vector2(627, -33)

11
scripts/health_bar.gd Normal file
View file

@ -0,0 +1,11 @@
extends MeshInstance2D
@onready var border_sprite = $Border
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass

View file

@ -8,15 +8,20 @@ extends Entity
@onready var collider = $CollisionShape2D @onready var collider = $CollisionShape2D
@onready var punch_hitbox = $PunchHitbox @onready var punch_hitbox = $PunchHitbox
@onready var death_timer = $DeathTimer @onready var death_timer = $DeathTimer
@onready var player_hurt_sfx = $PlayerHurtSfx
@onready var player_death_sfx = $PlayerDeathSfx
@onready var hurt_timer = $HurtTimer
@onready var health_bar = $HealthBar
var jumping = false var jumping = false
var facing_right = true var facing_right = true
var right_punch = false var right_punch = false
var hurting = false var hurting = false
var is_dying = false var is_dying = false
var is_death_sfx = false
const ATTACK_DAMAGE = 25 const ATTACK_DAMAGE = 25
const INITIAL_HEALTH = 100 const INITIAL_HEALTH = 50
const SPEED_MULTIPLIER = 300 const SPEED_MULTIPLIER = 300
const ATTACK_KNOCKBACK = 5000 const ATTACK_KNOCKBACK = 5000
@ -44,6 +49,11 @@ func _physics_process(delta):
if velocity.y > 1000: if velocity.y > 1000:
velocity.y = 1000 velocity.y = 1000
if is_dying and !player_death_sfx.playing:
player_death_sfx.play()
elif hurting and !player_hurt_sfx.playing and death_timer.is_stopped():
player_hurt_sfx.play()
# perform horizontal movement # perform horizontal movement
var horizontal_direction = Input.get_axis("move_left", "move_right") var horizontal_direction = Input.get_axis("move_left", "move_right")
velocity.x = speed * horizontal_direction velocity.x = speed * horizontal_direction
@ -60,17 +70,8 @@ func _physics_process(delta):
if horizontal_direction != 0: if horizontal_direction != 0:
facing_right = horizontal_direction > 0 facing_right = horizontal_direction > 0
# figure out which animation should be played
# respecting the jump animation above all
if !jumping and !hurting and attack_timer.is_stopped():
if is_on_floor() && horizontal_direction != 0:
animated_sprite.play("walk")
else:
animated_sprite.play("idle")
super._physics_process(delta) super._physics_process(delta)
punch_hitbox.visible = true if !attack_timer.is_stopped() else false punch_hitbox.visible = true if !attack_timer.is_stopped() else false
func punch_connect(node: Node): func punch_connect(node: Node):
@ -82,12 +83,7 @@ func punch_connect(node: Node):
func hurt_anim(): func hurt_anim():
hurting = true hurting = true
animated_sprite.play("hurt") hurt_timer.start()
animated_sprite.animation_finished.connect(disable_hurt)
func disable_hurt():
hurting = false
animated_sprite.animation_finished.disconnect(disable_hurt)
func _process(delta: float) -> void: func _process(delta: float) -> void:
if health <= 0: if health <= 0:
@ -96,6 +92,7 @@ func _process(delta: float) -> void:
health = 99999 health = 99999
if is_dying: if is_dying:
animated_sprite.play("death") animated_sprite.play("death")
punch_hitbox.visible = false punch_hitbox.visible = false
speed = 0 speed = 0
@ -107,7 +104,32 @@ func _process(delta: float) -> void:
attack_timer.start() attack_timer.start()
if is_on_floor(): if is_on_floor():
animated_sprite.play("right" if right_punch else "left") animated_sprite.play("Right" if right_punch else "Left")
right_punch = !right_punch right_punch = !right_punch
else: else:
animated_sprite.play("slam") animated_sprite.play("slam")
elif attack_timer.is_stopped() and !hurting and !is_dying and !jumping:
var horizontal_direction = Input.get_axis("move_left", "move_right")
if is_on_floor() && horizontal_direction != 0:
animated_sprite.play("walk")
else:
animated_sprite.play("idle")
if !hurt_timer.is_stopped():
animated_sprite.play("hurt")
else:
hurting = false
var health_percentage = health * 100 / INITIAL_HEALTH
if is_dying:
health_bar.play("0")
elif health_percentage > 80:
health_bar.play("100")
elif health_percentage > 60:
health_bar.play("80")
elif health_percentage > 40:
health_bar.play("40")
elif health_percentage > 20:
health_bar.play("20")

View file

@ -5,6 +5,7 @@ var completed = false;
@onready var right_border = $Borders/Right/CollisionShape2D; @onready var right_border = $Borders/Right/CollisionShape2D;
@onready var right_trigger = $Borders/Right/Trigger; @onready var right_trigger = $Borders/Right/Trigger;
@onready var bgm = $BGM
func _process(delta: float) -> void: func _process(delta: float) -> void:
if Input.is_action_just_pressed("trigger_completed"): if Input.is_action_just_pressed("trigger_completed"):
@ -14,5 +15,8 @@ func _process(delta: float) -> void:
right_border.shape = null right_border.shape = null
right_trigger.body_entered.connect(_on_trigger) right_trigger.body_entered.connect(_on_trigger)
if !bgm.playing:
bgm.play()
func _on_trigger(body: Node) -> void: func _on_trigger(body: Node) -> void:
get_tree().change_scene_to_file(next_stage) get_tree().change_scene_to_file(next_stage)

View file

@ -6,6 +6,7 @@ extends Entity;
@onready var collision_shape = collider.shape @onready var collision_shape = collider.shape
@onready var attack_timer = $AttackTimer @onready var attack_timer = $AttackTimer
@onready var death_timer = $DeathTimer @onready var death_timer = $DeathTimer
@onready var explosion_sfx = $ExplosionSFX
var is_dying = false var is_dying = false
const SPEED_MULTIPLIER = 100 const SPEED_MULTIPLIER = 100
@ -38,7 +39,9 @@ func _process(delta: float) -> void:
health = 99999 health = 99999
if is_dying: if is_dying:
animated_sprite.play("death") animated_sprite.play("death")
explosion_sfx.play()
contact_hitbox.visible = false contact_hitbox.visible = false
speed = 0 speed = 0