diff --git a/project.godot b/project.godot index f6fad7d..058a865 100644 --- a/project.godot +++ b/project.godot @@ -43,34 +43,34 @@ window/size/resizable=false player_move_up={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"physical_scancode":0,"unicode":0,"echo":false,"script":null) +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"unicode":0,"echo":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null) , Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":87,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"unicode":0,"echo":false,"script":null) ] } player_move_down={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"physical_scancode":0,"unicode":0,"echo":false,"script":null) +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"unicode":0,"echo":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null) , Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":83,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"unicode":0,"echo":false,"script":null) ] } player_move_left={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"physical_scancode":0,"unicode":0,"echo":false,"script":null) +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"unicode":0,"echo":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null) , Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":65,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"unicode":0,"echo":false,"script":null) ] } player_move_right={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"physical_scancode":0,"unicode":0,"echo":false,"script":null) +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"unicode":0,"echo":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":15,"pressure":0.0,"pressed":false,"script":null) , Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":68,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"unicode":0,"echo":false,"script":null) ] } player_shoot={ @@ -82,8 +82,8 @@ player_shoot={ [layer_names] 2d_render/layer_1="Game" -2d_render/layer_2="UserInterface" 2d_physics/layer_1="Entities" +2d_render/layer_2="UserInterface" 2d_physics/layer_2="Damageable" 2d_physics/layer_3="Projectiles" 2d_physics/layer_4="UI" diff --git a/src/entities/Bullet.tscn b/src/entities/Bullet.tscn index c81ea27..44294c0 100644 --- a/src/entities/Bullet.tscn +++ b/src/entities/Bullet.tscn @@ -24,5 +24,4 @@ texture = ExtResource( 1 ) script = ExtResource( 2 ) [node name="Ownership" parent="." instance=ExtResource( 3 )] - [connection signal="hit" from="BulletMovement" to="." method="_on_BulletMovement_hit"] diff --git a/src/entities/Enemy.tscn b/src/entities/Enemy.tscn index 32f9329..f1e2d11 100644 --- a/src/entities/Enemy.tscn +++ b/src/entities/Enemy.tscn @@ -28,5 +28,4 @@ texture = ExtResource( 1 ) [node name="Alliance" parent="." instance=ExtResource( 5 )] alliance = -1 - [connection signal="dead" from="Damageable" to="." method="_on_Damageable_dead"] diff --git a/src/entities/FireConcept.png.import b/src/entities/FireConcept.png.import index ffd86b1..3f6293d 100644 --- a/src/entities/FireConcept.png.import +++ b/src/entities/FireConcept.png.import @@ -28,7 +28,6 @@ process/fix_alpha_border=true process/premult_alpha=false process/HDR_as_SRGB=false process/invert_color=false -process/normal_map_invert_y=false stream=false size_limit=0 detect_3d=true diff --git a/src/entities/behaviours/AttractedTo.gd b/src/entities/behaviours/AttractedTo.gd index 6d54894..4655d7d 100644 --- a/src/entities/behaviours/AttractedTo.gd +++ b/src/entities/behaviours/AttractedTo.gd @@ -2,7 +2,7 @@ extends Node export var movement_per_second: float = 32.0 -export var goal_path: String = "../../Fire" +export var goal_path: String = "../../PhaseOneContainer/Fire" onready var target: KinematicBody2D = get_parent() @@ -14,14 +14,14 @@ signal touching_goal var goal_reached_triggered: bool = false signal goal_reached - func _physics_process(_delta): - var direction: Vector2 = (goal.global_position - target.global_position).normalized() - var _motion: Vector2 = target.move_and_slide(direction * movement_per_second, Vector2.ZERO) - for slide_no in target.get_slide_count(): - var slide = target.get_slide_collision(slide_no) - if slide.collider == goal: - emit_signal("touching_goal") - if not goal_reached_triggered: - emit_signal("goal_reached") - goal_reached_triggered = true + if target.global_position != null: + var direction: Vector2 = (goal.global_position - target.global_position).normalized() + var _motion: Vector2 = target.move_and_slide(direction * movement_per_second, Vector2.ZERO) + for slide_no in target.get_slide_count(): + var slide = target.get_slide_collision(slide_no) + if slide.collider == goal: + emit_signal("touching_goal") + if not goal_reached_triggered: + emit_signal("goal_reached") + goal_reached_triggered = true diff --git a/src/entities/behaviours/EnemySpawn.gd b/src/entities/behaviours/EnemySpawn.gd new file mode 100644 index 0000000..4db4962 --- /dev/null +++ b/src/entities/behaviours/EnemySpawn.gd @@ -0,0 +1,34 @@ +extends Node + +# Items +export var enemy: PackedScene = preload("res://src/entities/Enemy.tscn") +export var bullet_container_node_path: String = "../.." +onready var bullet_container_node: Node = get_node(bullet_container_node_path) + +var _timer : Timer = null +var rng : RandomNumberGenerator = RandomNumberGenerator.new() + +func _ready(): + _timer = Timer.new() + add_child(_timer) + + _timer.connect("timeout", self, "_on_Timer_timeout") + _timer.set_wait_time(1.5) + _timer.set_one_shot(false) # Make sure it loops + _timer.start() + + rng.randomize() + + +func _on_Timer_timeout(): + var position = Vector2(0, 0) + var new_enemy = enemy.instance() + + var random = rng.randi_range(1, 4) + if random == 1: position = Vector2(0, rng.randf_range(0, 640)) + elif random == 1: position = Vector2(1280, rng.randf_range(0, 640)) + elif random == 1: position = Vector2(rng.randf_range(0, 1280), 0) + else: position = Vector2(rng.randf_range(0, 640), 640) + + new_enemy.set_position(position) + bullet_container_node.add_child(new_enemy) diff --git a/src/levels/Game.tscn b/src/levels/Game.tscn index 301d048..2ed5675 100644 --- a/src/levels/Game.tscn +++ b/src/levels/Game.tscn @@ -1,18 +1,15 @@ -[gd_scene load_steps=15 format=2] +[gd_scene load_steps=12 format=2] [ext_resource path="res://src/mechanics/Background.tscn" type="PackedScene" id=1] [ext_resource path="res://src/mechanics/Darkness.tscn" type="PackedScene" id=2] [ext_resource path="res://src/entities/Fire.tscn" type="PackedScene" id=3] [ext_resource path="res://src/entities/Player.tscn" type="PackedScene" id=4] -[ext_resource path="res://src/entities/Enemy.tscn" type="PackedScene" id=5] [ext_resource path="res://src/levels/Game.gd" type="Script" id=6] [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/music/BaseChoir.mp3" type="AudioStream" id=10] +[ext_resource path="res://src/entities/behaviours/EnemySpawn.gd" type="Script" id=10] [ext_resource path="res://src/levels/PhaseOneMusic.gd" type="Script" id=11] -[ext_resource path="res://src/music/BaseDrum.mp3" type="AudioStream" id=12] -[ext_resource path="res://src/music/BaseBell.mp3" type="AudioStream" id=13] [ext_resource path="res://src/ui/HealthBar.tscn" type="PackedScene" id=14] [node name="Game" type="Node2D"] @@ -26,17 +23,14 @@ script = ExtResource( 11 ) fire_path = NodePath("../PhaseOneContainer/Fire") [node name="Bell" type="AudioStreamPlayer" parent="PhaseOne/PhaseOneMusic"] -stream = ExtResource( 13 ) volume_db = -80.0 autoplay = true [node name="Choir" type="AudioStreamPlayer" parent="PhaseOne/PhaseOneMusic"] -stream = ExtResource( 10 ) volume_db = -80.0 autoplay = true [node name="Drum" type="AudioStreamPlayer" parent="PhaseOne/PhaseOneMusic"] -stream = ExtResource( 12 ) volume_db = -80.0 autoplay = true @@ -51,8 +45,8 @@ position = Vector2( 553, 296 ) [node name="Player" parent="PhaseOne/PhaseOneContainer" instance=ExtResource( 4 )] position = Vector2( 500, 438 ) -[node name="Enemy" parent="PhaseOne/PhaseOneContainer" instance=ExtResource( 5 )] -position = Vector2( 755, 508 ) +[node name="EnemySpawner" type="Node" parent="PhaseOne/PhaseOneContainer"] +script = ExtResource( 10 ) [node name="Fire" parent="PhaseOne/PhaseOneContainer" instance=ExtResource( 3 )] position = Vector2( 640, 320 ) diff --git a/src/mechanics/GrassDirtTileset.png.import b/src/mechanics/GrassDirtTileset.png.import index 36c7e5f..3d18c24 100644 --- a/src/mechanics/GrassDirtTileset.png.import +++ b/src/mechanics/GrassDirtTileset.png.import @@ -28,7 +28,6 @@ process/fix_alpha_border=true process/premult_alpha=false process/HDR_as_SRGB=false process/invert_color=false -process/normal_map_invert_y=false stream=false size_limit=0 detect_3d=true