From c5321d1fabda9ab8a057946a8bb38fd47405011e Mon Sep 17 00:00:00 2001 From: Derek Date: Tue, 25 Feb 2025 20:46:24 -0600 Subject: [PATCH] tweaks to hud and finally have the machete... kind of working? --- assets/machete.tscn | 5 +---- hud.tscn | 8 ++++---- scripts/EnemyTarget.gd | 1 - scripts/hud.gd | 8 +++++--- scripts/melee_collision.gd | 7 +------ scripts/melee_weapon.gd | 2 +- 6 files changed, 12 insertions(+), 19 deletions(-) diff --git a/assets/machete.tscn b/assets/machete.tscn index 51f404f..fa8ae24 100644 --- a/assets/machete.tscn +++ b/assets/machete.tscn @@ -281,11 +281,10 @@ cast_shadow = 0 mesh = SubResource("ArrayMesh_io6u4") skeleton = NodePath("") -[node name="Area3D" type="Area3D" parent="MacheteHandle"] +[node name="Area3D" type="RigidBody3D" parent="MacheteHandle"] transform = Transform3D(-4.37114e-08, -1, 4.37114e-08, 0.314307, -5.5235e-08, -0.949321, 0.949321, -2.77573e-08, 0.314307, 0, 0.415, -0.0427188) collision_layer = 128 collision_mask = 232 -priority = 1 script = ExtResource("12_u0mbp") [node name="CollisionShape3D" type="CollisionShape3D" parent="MacheteHandle/Area3D"] @@ -305,5 +304,3 @@ libraries = { [node name="Audio" type="Node3D" parent="."] [node name="Swing" type="AudioStreamPlayer3D" parent="Audio"] - -[connection signal="body_entered" from="MacheteHandle/Area3D" to="." method="_on_area_3d_body_entered"] diff --git a/hud.tscn b/hud.tscn index 7e6ce8f..fdfc757 100644 --- a/hud.tscn +++ b/hud.tscn @@ -165,26 +165,26 @@ theme_override_constants/outline_size = 15 text = "Gun Name" horizontal_alignment = 2 -[node name="HBoxContainer" type="HBoxContainer" parent="GunInfo/VBoxContainer"] +[node name="AmmoCounter" type="HBoxContainer" parent="GunInfo/VBoxContainer"] layout_mode = 2 size_flags_vertical = 3 theme = ExtResource("1_22trs") theme_override_constants/separation = 50 alignment = 2 -[node name="AmmoCurrent" type="Label" parent="GunInfo/VBoxContainer/HBoxContainer"] +[node name="AmmoCurrent" type="Label" parent="GunInfo/VBoxContainer/AmmoCounter"] layout_mode = 2 theme = ExtResource("1_22trs") theme_override_constants/outline_size = 15 text = "XXX" horizontal_alignment = 2 -[node name="Label" type="Label" parent="GunInfo/VBoxContainer/HBoxContainer"] +[node name="Label" type="Label" parent="GunInfo/VBoxContainer/AmmoCounter"] layout_mode = 2 theme_override_constants/outline_size = 15 text = "-" -[node name="AmmoReserve" type="Label" parent="GunInfo/VBoxContainer/HBoxContainer"] +[node name="AmmoReserve" type="Label" parent="GunInfo/VBoxContainer/AmmoCounter"] layout_mode = 2 theme = ExtResource("1_22trs") theme_override_colors/font_shadow_color = Color(0, 0, 0, 1) diff --git a/scripts/EnemyTarget.gd b/scripts/EnemyTarget.gd index 9628d21..2bf393c 100644 --- a/scripts/EnemyTarget.gd +++ b/scripts/EnemyTarget.gd @@ -27,4 +27,3 @@ func hit(bullet_damage): func _on_body_entered(body: Node3D) -> void: hit(body.bullet_damage) SignalBus.emit_signal("enemy_hit") - body.despawn() diff --git a/scripts/hud.gd b/scripts/hud.gd index 3b2bbc1..614611a 100644 --- a/scripts/hud.gd +++ b/scripts/hud.gd @@ -19,9 +19,10 @@ var crosshair_target @onready var stamina_bar: TextureProgressBar = $StaminaBar @onready var stamina_bar_2: ProgressBar = $StaminaBar2 @onready var health_bar: ProgressBar = $HealthBar +@onready var ammo_counter: HBoxContainer = $GunInfo/VBoxContainer/AmmoCounter @onready var gun_name: Label = $"GunInfo/VBoxContainer/Gun Name" -@onready var ammo_current: Label = $GunInfo/VBoxContainer/HBoxContainer/AmmoCurrent -@onready var ammo_reserve: Label = $GunInfo/VBoxContainer/HBoxContainer/AmmoReserve +@onready var ammo_current: Label = $GunInfo/VBoxContainer/AmmoCounter/AmmoCurrent +@onready var ammo_reserve: Label = $GunInfo/VBoxContainer/AmmoCounter/AmmoReserve @onready var gun_info: MarginContainer = $GunInfo @onready var money: Label = $Money @onready var crosshair: TextureRect = $Crosshair @@ -114,10 +115,11 @@ func _process(delta: float) -> void: if player.gun != null: if GameGlobals.gun_ammo.has(player.gun.gun_name) and GameGlobals.gun_ammo[player.gun.gun_name] != null: + ammo_counter.visible = true ammo_current.text = str(GameGlobals.gun_ammo[player.gun.gun_name]).pad_zeros(2) lerp_color(ammo_current,RED_COLOR,FULL_WHITE,GameGlobals.gun_ammo[player.gun.gun_name],player.gun.max_ammo,.5) else: - ammo_current.text = "-" + ammo_counter.visible = false if GameGlobals.ammo_reserve.has(str(player.gun.ammo_type)): ammo_reserve.text = str(GameGlobals.ammo_reserve[str(player.gun.ammo_type)]).pad_zeros(3) lerp_color(ammo_reserve,RED_COLOR,FULL_WHITE,GameGlobals.ammo_reserve[str(player.gun.ammo_type)],player.gun.max_ammo*2,.5) diff --git a/scripts/melee_collision.gd b/scripts/melee_collision.gd index 6b28225..cab3959 100644 --- a/scripts/melee_collision.gd +++ b/scripts/melee_collision.gd @@ -1,4 +1,4 @@ -extends Area3D +extends Node var bullet_damage @@ -8,8 +8,3 @@ var bullet_damage # Called when the node enters the scene tree for the first time. func _ready() -> void: bullet_damage = machete.bullet_damage - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: - pass diff --git a/scripts/melee_weapon.gd b/scripts/melee_weapon.gd index ae3fd09..7ad00d3 100644 --- a/scripts/melee_weapon.gd +++ b/scripts/melee_weapon.gd @@ -39,7 +39,7 @@ func _ready(): func _process(_delta): if blade_ray.is_colliding(): var body = blade_ray.get_collider() - if body.has_method("hit"): + if body != null and body.has_method("hit"): body.hit(bullet_damage) func shoot(delta):