diff --git a/classes/hit/hit.gd b/classes/hit/hit.gd deleted file mode 100644 index a78572d..0000000 --- a/classes/hit/hit.gd +++ /dev/null @@ -1,3 +0,0 @@ -class_name Hit extends Area2D - -@export var power_hit: bool = false diff --git a/classes/hit/hit.gd.uid b/classes/hit/hit.gd.uid deleted file mode 100644 index 69e065d..0000000 --- a/classes/hit/hit.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://b440ri3521uio diff --git a/classes/hit/hit.tscn b/classes/hit/hit.tscn deleted file mode 100644 index cc23606..0000000 --- a/classes/hit/hit.tscn +++ /dev/null @@ -1,12 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://d04legmj3c42r"] - -[ext_resource type="Script" uid="uid://b440ri3521uio" path="res://classes/hit/hit.gd" id="1_udkr8"] - -[node name="Hit2D" type="Area2D" groups=["hit"]] -collision_layer = 64 -collision_mask = 0 -script = ExtResource("1_udkr8") - -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -rotation = 1.5707964 -debug_color = Color(0.6205005, 0.42311785, 0.8432588, 0.41960785) diff --git a/scenes/ball/ball.gd b/scenes/ball/ball.gd index 51740f8..23c5b46 100644 --- a/scenes/ball/ball.gd +++ b/scenes/ball/ball.gd @@ -43,16 +43,16 @@ func _decelerate_to_stop(duration: float = 0.3) -> void: ) -func _on_hit(hitbox: Hit) -> void: +func _on_hit(hitbox: Area2D) -> void: print("area detected") if not is_hit: if hitbox.is_in_group("hit"): - assert(hitbox.power_hit != null, "hit doesnt have correct metadata, is it a hit?") + assert(hitbox.has_meta("power_hit"), "hit doesnt have correct metadata, is it a hit?") print("ball not hit yet") var player: Player = hitbox.get_parent() var timer: Timer = player.hit_timer - var angle: float = (PI/2 if hitbox.power_hit else randf_range(3*PI/4, PI/4)) * (-1 if player.id == 1 else 1) - var speed: float = randf_range(350, 450) if hitbox.power_hit else 0.0 # o.o + var angle: float = (PI/2 if hitbox.get_meta("power_hit") else randf_range(3*PI/4, PI/4)) * (-1 if player.id == 1 else 1) + var speed: float = randf_range(350, 450) if hitbox.get_meta("power_hit") else 0.0 # o.o launch(angle, speed) print("ball hit") if not timer.is_connected("timeout", _on_hit_end): diff --git a/scenes/hit/power_hit.tscn b/scenes/hit/power_hit.tscn index 36b32b6..6c67f62 100644 --- a/scenes/hit/power_hit.tscn +++ b/scenes/hit/power_hit.tscn @@ -1,6 +1,5 @@ -[gd_scene load_steps=4 format=3 uid="uid://d0c57c37o75b0"] +[gd_scene load_steps=3 format=3 uid="uid://d0c57c37o75b0"] -[ext_resource type="Script" uid="uid://b440ri3521uio" path="res://classes/hit/hit.gd" id="1_kwsj5"] [ext_resource type="Texture2D" uid="uid://c6a62gvw7218s" path="res://scenes/hit/assets/hit.png" id="2_kwsj5"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_kwsj5"] @@ -10,9 +9,6 @@ height = 70.0 [node name="PowerHit2D" type="Area2D" groups=["hit"]] collision_layer = 64 collision_mask = 0 -script = ExtResource("1_kwsj5") -power_hit = true -metadata/_custom_type_script = "uid://b440ri3521uio" metadata/power_hit = true [node name="CollisionShape2D" type="CollisionShape2D" parent="."] diff --git a/scenes/hit/small_hit.tscn b/scenes/hit/small_hit.tscn index f0c65db..59d98f2 100644 --- a/scenes/hit/small_hit.tscn +++ b/scenes/hit/small_hit.tscn @@ -1,6 +1,5 @@ -[gd_scene load_steps=4 format=3 uid="uid://px67runjx6ex"] +[gd_scene load_steps=3 format=3 uid="uid://px67runjx6ex"] -[ext_resource type="Script" uid="uid://b440ri3521uio" path="res://classes/hit/hit.gd" id="1_dk3vy"] [ext_resource type="Texture2D" uid="uid://c6a62gvw7218s" path="res://scenes/hit/assets/hit.png" id="1_rmj1p"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_fxeki"] @@ -10,7 +9,6 @@ height = 34.0 [node name="SmallHit2D" type="Area2D" groups=["hit"]] collision_layer = 64 collision_mask = 0 -script = ExtResource("1_dk3vy") metadata/_custom_type_script = "uid://b440ri3521uio" metadata/power_hit = false