diff --git a/project.godot b/project.godot index f6fad7d..7a6d7ad 100644 --- a/project.godot +++ b/project.godot @@ -12,15 +12,21 @@ _global_script_classes=[ { "base": "Node", "class": "Alliance", "language": "GDScript", -"path": "res://src/entities/behaviours/Alliance.gd" +"path": "res://src/behaviours/Alliance.gd" +}, { +"base": "Node", +"class": "AttractedToMovement", +"language": "GDScript", +"path": "res://src/behaviours/movement/AttractedToMovement.gd" }, { "base": "Node", "class": "Ownership", "language": "GDScript", -"path": "res://src/entities/behaviours/Ownership.gd" +"path": "res://src/behaviours/Ownership.gd" } ] _global_script_class_icons={ "Alliance": "", +"AttractedToMovement": "", "Ownership": "" } diff --git a/src/entities/behaviours/Alliance.gd b/src/behaviours/Alliance.gd similarity index 100% rename from src/entities/behaviours/Alliance.gd rename to src/behaviours/Alliance.gd diff --git a/src/entities/behaviours/Alliance.tscn b/src/behaviours/Alliance.tscn similarity index 70% rename from src/entities/behaviours/Alliance.tscn rename to src/behaviours/Alliance.tscn index af25e09..55cfd3e 100644 --- a/src/entities/behaviours/Alliance.tscn +++ b/src/behaviours/Alliance.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=2] -[ext_resource path="res://src/entities/behaviours/Alliance.gd" type="Script" id=1] +[ext_resource path="res://src/behaviours/Alliance.gd" type="Script" id=1] [node name="Alliance" type="Node"] script = ExtResource( 1 ) diff --git a/src/entities/behaviours/BranchSpawn.gd b/src/behaviours/BranchSpawn.gd similarity index 63% rename from src/entities/behaviours/BranchSpawn.gd rename to src/behaviours/BranchSpawn.gd index 0bf0486..f867ff6 100644 --- a/src/entities/behaviours/BranchSpawn.gd +++ b/src/behaviours/BranchSpawn.gd @@ -1,13 +1,16 @@ extends Node +# TODO + +export var branch: PackedScene +export var branch_container_node_path: NodePath + -export var branch: PackedScene = preload("res://src/entities/Pickup.tscn") -export var branch_container_node_path: String = "../.." onready var branch_container_node: Node = get_node(branch_container_node_path) onready var source: Node2D = get_parent() -func BranchSpawn(): +func _ready(): var new_branch = branch.instance() new_branch.set_position(source.global_position) branch_container_node.add_child(new_branch) diff --git a/src/behaviours/BranchSpawn.tscn b/src/behaviours/BranchSpawn.tscn new file mode 100644 index 0000000..bb53b87 --- /dev/null +++ b/src/behaviours/BranchSpawn.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://src/behaviours/BranchSpawn.gd" type="Script" id=1] + +[node name="BranchSpawn" type="Node"] +script = ExtResource( 1 ) diff --git a/src/entities/behaviours/BulletMovement.gd b/src/behaviours/BulletMovement.gd similarity index 88% rename from src/entities/behaviours/BulletMovement.gd rename to src/behaviours/BulletMovement.gd index 0282931..1c1b317 100644 --- a/src/entities/behaviours/BulletMovement.gd +++ b/src/behaviours/BulletMovement.gd @@ -1,12 +1,15 @@ extends Node -onready var target: KinematicBody2D = get_parent() -export var movement_per_second: float = 400.0 - signal hit(collision) +export var movement_per_second: float + + +onready var target: KinematicBody2D = get_parent() + + func _physics_process(delta): var direction = Vector2(cos(target.rotation), sin(target.rotation)) var collision: KinematicCollision2D = target.move_and_collide(direction * movement_per_second * delta) diff --git a/src/entities/behaviours/BulletSpawn.gd b/src/behaviours/BulletSpawn.gd similarity index 87% rename from src/entities/behaviours/BulletSpawn.gd rename to src/behaviours/BulletSpawn.gd index fb5afdb..ac4ff53 100644 --- a/src/entities/behaviours/BulletSpawn.gd +++ b/src/behaviours/BulletSpawn.gd @@ -1,10 +1,14 @@ extends Node -export var bullet: PackedScene = preload("res://src/entities/Bullet.tscn") -export var bullet_container_node_path: String = "../.." +export var bullet: PackedScene +export var bullet_container_node_path: String + + onready var bullet_container_node: Node = get_node(bullet_container_node_path) onready var source: Node2D = get_parent() + + var _timer : Timer = null func _ready(): diff --git a/src/entities/behaviours/BulletSpawn.tscn b/src/behaviours/BulletSpawn.tscn similarity index 53% rename from src/entities/behaviours/BulletSpawn.tscn rename to src/behaviours/BulletSpawn.tscn index db25fb2..e79eee1 100644 --- a/src/entities/behaviours/BulletSpawn.tscn +++ b/src/behaviours/BulletSpawn.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=2] -[ext_resource path="res://src/entities/behaviours/BulletSpawn.gd" type="Script" id=1] +[ext_resource path="res://src/behaviours/BulletSpawn.gd" type="Script" id=1] [node name="BulletSpawn" type="Node"] script = ExtResource( 1 ) diff --git a/src/entities/behaviours/Damageable.gd b/src/behaviours/Damageable.gd similarity index 100% rename from src/entities/behaviours/Damageable.gd rename to src/behaviours/Damageable.gd diff --git a/src/entities/behaviours/Damageable.tscn b/src/behaviours/Damageable.tscn similarity index 53% rename from src/entities/behaviours/Damageable.tscn rename to src/behaviours/Damageable.tscn index c7bd5c2..b4dcdbd 100644 --- a/src/entities/behaviours/Damageable.tscn +++ b/src/behaviours/Damageable.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=2] -[ext_resource path="res://src/entities/behaviours/Damageable.gd" type="Script" id=1] +[ext_resource path="res://src/behaviours/Damageable.gd" type="Script" id=1] [node name="Damageable" type="Node"] script = ExtResource( 1 ) diff --git a/src/entities/behaviours/EnemySpawn.gd b/src/behaviours/EnemySpawn.gd similarity index 100% rename from src/entities/behaviours/EnemySpawn.gd rename to src/behaviours/EnemySpawn.gd diff --git a/src/entities/behaviours/ErraticMovement.gd b/src/behaviours/ErraticMovement.gd similarity index 100% rename from src/entities/behaviours/ErraticMovement.gd rename to src/behaviours/ErraticMovement.gd diff --git a/src/entities/behaviours/ErraticMovement.tscn b/src/behaviours/ErraticMovement.tscn similarity index 53% rename from src/entities/behaviours/ErraticMovement.tscn rename to src/behaviours/ErraticMovement.tscn index e685476..fb37d54 100644 --- a/src/entities/behaviours/ErraticMovement.tscn +++ b/src/behaviours/ErraticMovement.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=2] -[ext_resource path="res://src/entities/behaviours/ErraticMovement.gd" type="Script" id=1] +[ext_resource path="res://src/behaviours/ErraticMovement.gd" type="Script" id=1] [node name="ErraticMovement" type="Node"] script = ExtResource( 1 ) diff --git a/src/entities/behaviours/Ownership.gd b/src/behaviours/Ownership.gd similarity index 100% rename from src/entities/behaviours/Ownership.gd rename to src/behaviours/Ownership.gd diff --git a/src/entities/behaviours/Ownership.tscn b/src/behaviours/Ownership.tscn similarity index 53% rename from src/entities/behaviours/Ownership.tscn rename to src/behaviours/Ownership.tscn index a2468df..387bcb3 100644 --- a/src/entities/behaviours/Ownership.tscn +++ b/src/behaviours/Ownership.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=2] -[ext_resource path="res://src/entities/behaviours/Ownership.gd" type="Script" id=1] +[ext_resource path="res://src/behaviours/Ownership.gd" type="Script" id=1] [node name="Ownership" type="Node"] script = ExtResource( 1 ) diff --git a/src/entities/behaviours/PlayerMovement.gd b/src/behaviours/PlayerMovement.gd similarity index 100% rename from src/entities/behaviours/PlayerMovement.gd rename to src/behaviours/PlayerMovement.gd diff --git a/src/entities/behaviours/PlayerMovement.tscn b/src/behaviours/PlayerMovement.tscn similarity index 53% rename from src/entities/behaviours/PlayerMovement.tscn rename to src/behaviours/PlayerMovement.tscn index 7161f53..d5f8184 100644 --- a/src/entities/behaviours/PlayerMovement.tscn +++ b/src/behaviours/PlayerMovement.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=2] -[ext_resource path="res://src/entities/behaviours/PlayerMovement.gd" type="Script" id=1] +[ext_resource path="res://src/behaviours/PlayerMovement.gd" type="Script" id=1] [node name="PlayerMovement" type="Node"] script = ExtResource( 1 ) diff --git a/src/entities/behaviours/SpriteRandomRotation.gd b/src/behaviours/SpriteRandomRotation.gd similarity index 100% rename from src/entities/behaviours/SpriteRandomRotation.gd rename to src/behaviours/SpriteRandomRotation.gd diff --git a/src/entities/behaviours/AttractedToMovement.gd b/src/behaviours/movement/AttractedToMovement.gd similarity index 100% rename from src/entities/behaviours/AttractedToMovement.gd rename to src/behaviours/movement/AttractedToMovement.gd diff --git a/src/entities/behaviours/AttractedToMovement.tscn b/src/behaviours/movement/AttractedToMovement.tscn similarity index 100% rename from src/entities/behaviours/AttractedToMovement.tscn rename to src/behaviours/movement/AttractedToMovement.tscn diff --git a/src/entities/AbstractEntity.tscn b/src/entities/AbstractEntity.tscn new file mode 100644 index 0000000..b24332b --- /dev/null +++ b/src/entities/AbstractEntity.tscn @@ -0,0 +1,11 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://src/behaviours/Damageable.tscn" type="PackedScene" id=1] +[ext_resource path="res://src/behaviours/Alliance.tscn" type="PackedScene" id=2] + +[node name="AbstractEntity" type="KinematicBody2D"] +collision_layer = 3 + +[node name="Alliance" parent="." instance=ExtResource( 2 )] + +[node name="Damageable" parent="." instance=ExtResource( 1 )] diff --git a/src/entities/Bullet.tscn b/src/entities/Bullet.tscn index a454fba..9f9754f 100644 --- a/src/entities/Bullet.tscn +++ b/src/entities/Bullet.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=7 format=2] [ext_resource path="res://src/mechanics/Arrow.png" type="Texture" id=1] -[ext_resource path="res://src/entities/behaviours/BulletMovement.gd" type="Script" id=2] -[ext_resource path="res://src/entities/behaviours/Ownership.tscn" type="PackedScene" id=3] +[ext_resource path="res://src/behaviours/BulletMovement.gd" type="Script" id=2] +[ext_resource path="res://src/behaviours/Ownership.tscn" type="PackedScene" id=3] [ext_resource path="res://src/entities/Bullet.gd" type="Script" id=4] [ext_resource path="res://src/sounds/Arrow.mp3" type="AudioStream" id=5] diff --git a/src/entities/Enemy.tscn b/src/entities/Enemy.tscn index 0ad427a..b99e93c 100644 --- a/src/entities/Enemy.tscn +++ b/src/entities/Enemy.tscn @@ -1,12 +1,12 @@ [gd_scene load_steps=9 format=2] [ext_resource path="res://src/mechanics/Black.png" type="Texture" id=1] -[ext_resource path="res://src/entities/behaviours/ErraticMovement.tscn" type="PackedScene" id=2] -[ext_resource path="res://src/entities/behaviours/AttractedTo.tscn" type="PackedScene" id=3] -[ext_resource path="res://src/entities/behaviours/Damageable.tscn" type="PackedScene" id=4] -[ext_resource path="res://src/entities/behaviours/Alliance.tscn" type="PackedScene" id=5] +[ext_resource path="res://src/behaviours/ErraticMovement.tscn" type="PackedScene" id=2] +[ext_resource path="res://src/behaviours/movement/AttractedToMovement.tscn" type="PackedScene" id=3] +[ext_resource path="res://src/behaviours/Damageable.tscn" type="PackedScene" id=4] +[ext_resource path="res://src/behaviours/Alliance.tscn" type="PackedScene" id=5] [ext_resource path="res://src/entities/Enemy.gd" type="Script" id=6] -[ext_resource path="res://src/entities/behaviours/BranchSpawn.gd" type="Script" id=7] +[ext_resource path="res://src/behaviours/BranchSpawn.gd" type="Script" id=7] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 16, 16 ) diff --git a/src/entities/Pickup.tscn b/src/entities/Pickup.tscn index 48208c8..60c2dd6 100644 --- a/src/entities/Pickup.tscn +++ b/src/entities/Pickup.tscn @@ -2,7 +2,7 @@ [ext_resource path="res://src/mechanics/Branch1.png" type="Texture" id=1] [ext_resource path="res://src/entities/Pickup.gd" type="Script" id=2] -[ext_resource path="res://src/entities/behaviours/SpriteRandomRotation.gd" type="Script" id=3] +[ext_resource path="res://src/behaviours/SpriteRandomRotation.gd" type="Script" id=3] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 16, 16 ) diff --git a/src/entities/Player.tscn b/src/entities/Player.tscn index 1e21e58..2b35a63 100644 --- a/src/entities/Player.tscn +++ b/src/entities/Player.tscn @@ -1,31 +1,18 @@ -[gd_scene load_steps=7 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://src/mechanics/White.png" type="Texture" id=1] -[ext_resource path="res://src/entities/behaviours/PlayerMovement.tscn" type="PackedScene" id=2] -[ext_resource path="res://src/entities/behaviours/BulletSpawn.tscn" type="PackedScene" id=3] -[ext_resource path="res://src/entities/behaviours/Damageable.tscn" type="PackedScene" id=4] -[ext_resource path="res://src/entities/behaviours/Alliance.tscn" type="PackedScene" id=5] +[ext_resource path="res://src/behaviours/PlayerMovement.tscn" type="PackedScene" id=2] +[ext_resource path="res://src/entities/AbstractEntity.tscn" type="PackedScene" id=3] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 16, 16 ) -[node name="Player" type="KinematicBody2D"] -collision_layer = 3 -collision/safe_margin = 0.02 +[node name="Player" instance=ExtResource( 3 )] -[node name="Shape" type="CollisionShape2D" parent="."] +[node name="Shape" type="CollisionShape2D" parent="." index="0"] shape = SubResource( 1 ) -[node name="Sprite" type="Sprite" parent="Shape"] +[node name="Sprite" type="Sprite" parent="Shape" index="0"] texture = ExtResource( 1 ) -[node name="PlayerMovement" parent="." instance=ExtResource( 2 )] - -[node name="BulletSpawn" parent="." instance=ExtResource( 3 )] - -[node name="Damageable" parent="." instance=ExtResource( 4 )] -health = 5 -max_health = 5 - -[node name="Alliance" parent="." instance=ExtResource( 5 )] -alliance = 1 +[node name="PlayerMovement" parent="." index="1" instance=ExtResource( 2 )] diff --git a/src/levels/Game.tscn b/src/levels/Game.tscn index 2ed5675..9dfb021 100644 --- a/src/levels/Game.tscn +++ b/src/levels/Game.tscn @@ -8,7 +8,7 @@ [ext_resource path="res://src/ui/TimeSurvived.tscn" type="PackedScene" id=7] [ext_resource path="res://src/entities/Pickup.tscn" type="PackedScene" id=8] [ext_resource path="res://src/entities/pickupeffects/ChangeFireIntensity.tscn" type="PackedScene" id=9] -[ext_resource path="res://src/entities/behaviours/EnemySpawn.gd" type="Script" id=10] +[ext_resource path="res://src/behaviours/EnemySpawn.gd" type="Script" id=10] [ext_resource path="res://src/levels/PhaseOneMusic.gd" type="Script" id=11] [ext_resource path="res://src/ui/HealthBar.tscn" type="PackedScene" id=14]