From 9de2a0e75ab459f7204c5b6dfc135491eec23ec4 Mon Sep 17 00:00:00 2001 From: tonydero Date: Tue, 15 Oct 2024 08:37:50 -0600 Subject: [PATCH] refactor class names --- scenes/ability_ph.tscn | 6 ++++-- scenes/enemy.tscn | 6 +++--- scripts/Ability.gd | 5 ----- scripts/AbilityA1.gd | 5 ----- scripts/{AbilityPH.gd => AbilityPlayer.gd} | 8 +++++--- scripts/Character.gd | 14 -------------- scripts/{Gear.gd => ItemGear.gd} | 0 scripts/{Enemy.gd => NPCEnemy.gd} | 2 +- scripts/{Area.gd => WorldArea.gd} | 2 +- scripts/{Zone.gd => WorldZone.gd} | 2 +- 10 files changed, 15 insertions(+), 35 deletions(-) delete mode 100644 scripts/Ability.gd delete mode 100644 scripts/AbilityA1.gd rename scripts/{AbilityPH.gd => AbilityPlayer.gd} (90%) delete mode 100644 scripts/Character.gd rename scripts/{Gear.gd => ItemGear.gd} (100%) rename scripts/{Enemy.gd => NPCEnemy.gd} (97%) rename scripts/{Area.gd => WorldArea.gd} (79%) rename scripts/{Zone.gd => WorldZone.gd} (80%) diff --git a/scenes/ability_ph.tscn b/scenes/ability_ph.tscn index 10c7bed..549069d 100644 --- a/scenes/ability_ph.tscn +++ b/scenes/ability_ph.tscn @@ -1,12 +1,14 @@ [gd_scene load_steps=3 format=3 uid="uid://dvwo26vsk46tl"] -[ext_resource type="Script" path="res://scripts/AbilityPH.gd" id="1_6jbus"] [ext_resource type="Texture2D" uid="uid://b10c1776j6j60" path="res://assets/icon.svg" id="1_eoss7"] +[ext_resource type="Script" path="res://scripts/AbilityPlayer.gd" id="2_l8ort"] [node name="AbilityPH" type="TextureRect"] +offset_right = 128.0 +offset_bottom = 128.0 scale = Vector2(0.5, 0.5) texture = ExtResource("1_eoss7") -script = ExtResource("1_6jbus") +script = ExtResource("2_l8ort") [node name="IdleCooldown" type="Timer" parent="."] autostart = true diff --git a/scenes/enemy.tscn b/scenes/enemy.tscn index 869f81b..2598876 100644 --- a/scenes/enemy.tscn +++ b/scenes/enemy.tscn @@ -1,13 +1,13 @@ [gd_scene load_steps=4 format=3 uid="uid://55qfhbliodhn"] -[ext_resource type="Script" path="res://scripts/Enemy.gd" id="1_4u60d"] +[ext_resource type="Script" path="res://scripts/NPCEnemy.gd" id="1_ec4cy"] [ext_resource type="Texture2D" uid="uid://b10c1776j6j60" path="res://assets/icon.svg" id="2_twdr5"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_tv6kf"] size = Vector2(196, 175) -[node name="NPC" type="Node2D"] -script = ExtResource("1_4u60d") +[node name="NPCEnemy" type="Node2D"] +script = ExtResource("1_ec4cy") [node name="CharacterBody2D" type="CharacterBody2D" parent="."] diff --git a/scripts/Ability.gd b/scripts/Ability.gd deleted file mode 100644 index 994015a..0000000 --- a/scripts/Ability.gd +++ /dev/null @@ -1,5 +0,0 @@ -class_name Ability -extends Sprite2D - - -# basis for the 6 abilities diff --git a/scripts/AbilityA1.gd b/scripts/AbilityA1.gd deleted file mode 100644 index 50a1310..0000000 --- a/scripts/AbilityA1.gd +++ /dev/null @@ -1,5 +0,0 @@ -class_name AbilityA1 -extends Ability - - -# defines the unique characteristics of the A1 abilities diff --git a/scripts/AbilityPH.gd b/scripts/AbilityPlayer.gd similarity index 90% rename from scripts/AbilityPH.gd rename to scripts/AbilityPlayer.gd index 449e70b..a0aa1e8 100644 --- a/scripts/AbilityPH.gd +++ b/scripts/AbilityPlayer.gd @@ -1,5 +1,5 @@ # placerholder test ability -class_name Ability +class_name AbilityPlayer extends TextureRect @@ -12,6 +12,9 @@ var playerPos func _ready() -> void: middleX = get_viewport_rect().size.x/2 + + +func _process(_delta: float) -> void: playerPos = Vector2(middleX, get_viewport_rect().size.y*(0.75)) @@ -33,10 +36,9 @@ func _get_target(enemies) -> Node: # var numEnemies := _get_num_enemies() var enemyDists var closestEnemy - # get array of difficulties using map # get list of distances by mapping distance to each node in enemies enemyDists = enemies.map(_get_distance_to_player) - # get closest enemy by finding index with min dist + # get closest enemy by finding first index with min dist closestEnemy = enemies[enemyDists.find(enemyDists.min())] return closestEnemy diff --git a/scripts/Character.gd b/scripts/Character.gd deleted file mode 100644 index c9ba38d..0000000 --- a/scripts/Character.gd +++ /dev/null @@ -1,14 +0,0 @@ -class_name Character -extends Node2D - -# TODO: do the thing - -@export var charName := "Character" -@export var maxHealth := 10 -@export var dmgTaken := 0 - -func _init() -> void: - pass - #%NameLabel.text = self.charName - #%CharacterMaxHealth.text = str(self.maxHealth) - #%CharacterCurrHealth.text = str(self.maxHealth - self.dmgTaken) diff --git a/scripts/Gear.gd b/scripts/ItemGear.gd similarity index 100% rename from scripts/Gear.gd rename to scripts/ItemGear.gd diff --git a/scripts/Enemy.gd b/scripts/NPCEnemy.gd similarity index 97% rename from scripts/Enemy.gd rename to scripts/NPCEnemy.gd index d326384..d2f9d77 100644 --- a/scripts/Enemy.gd +++ b/scripts/NPCEnemy.gd @@ -1,4 +1,4 @@ -class_name Enemy +class_name NPCEnemy extends NPC diff --git a/scripts/Area.gd b/scripts/WorldArea.gd similarity index 79% rename from scripts/Area.gd rename to scripts/WorldArea.gd index 96f9cc8..1331073 100644 --- a/scripts/Area.gd +++ b/scripts/WorldArea.gd @@ -1,4 +1,4 @@ -class_name Area +class_name WorldArea extends Sprite2D diff --git a/scripts/Zone.gd b/scripts/WorldZone.gd similarity index 80% rename from scripts/Zone.gd rename to scripts/WorldZone.gd index 9d9dc28..7a1322d 100644 --- a/scripts/Zone.gd +++ b/scripts/WorldZone.gd @@ -1,4 +1,4 @@ -class_name Zone +class_name WorldZone extends Sprite2D