1
Fork 0
mirror of https://github.com/RYGhub/the-cold-night.git synced 2024-11-22 04:34:19 +00:00

⚙️ Created enemy spawner

This commit is contained in:
Cookie-CHR 2022-04-03 10:23:32 +02:00
parent da81aa103e
commit 948405ddd5
8 changed files with 58 additions and 34 deletions

View file

@ -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"

View file

@ -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"]

View file

@ -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"]

View file

@ -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

View file

@ -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,8 +14,8 @@ signal touching_goal
var goal_reached_triggered: bool = false
signal goal_reached
func _physics_process(_delta):
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():

View file

@ -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)

View file

@ -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 )

View file

@ -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