Added pause capability to all levels, added music to Level 5, added a simple chasing AI to the glowing ghosts, and optimized the Main Menu scene
This commit is contained in:
27
Enemies/Glowing Ghost.gd
Normal file
27
Enemies/Glowing Ghost.gd
Normal file
@@ -0,0 +1,27 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
const SPEED: int = 50
|
||||
|
||||
var player: KinematicBody2D = null
|
||||
var velocity: Vector2 = Vector2.ZERO
|
||||
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
velocity = Vector2.ZERO
|
||||
|
||||
if player:
|
||||
velocity = position.direction_to(player.position).normalized() * SPEED
|
||||
|
||||
velocity = move_and_slide(velocity)
|
||||
return
|
||||
|
||||
|
||||
func _on_player_detector_area_entered(area: Area2D) -> void:
|
||||
if area.get_parent().name == 'Player':
|
||||
player = area.get_parent()
|
||||
return
|
||||
|
||||
|
||||
func _on_player_detector_area_exited(_area: Area2D):
|
||||
player = null
|
||||
return
|
@@ -1,16 +1,20 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://Resources/Level_5_Enemy_Glowing_Ghost_Occluder.tres" type="OccluderPolygon2D" id=1]
|
||||
[ext_resource path="res://Sprites/Assets/Light.png" type="Texture" id=2]
|
||||
[ext_resource path="res://Sprites/Enemies/Glowing_Ghost.png" type="Texture" id=3]
|
||||
[ext_resource path="res://Enemies/Glowing Ghost.gd" type="Script" id=4]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
radius = 3.0
|
||||
height = 2.0
|
||||
|
||||
[sub_resource type="CircleShape2D" id=2]
|
||||
radius = 50.0
|
||||
|
||||
[node name="Glowing Ghost" type="KinematicBody2D" groups=["enemies"]]
|
||||
collision_layer = 2
|
||||
collision_mask = 0
|
||||
script = ExtResource( 4 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
light_mask = 4
|
||||
@@ -22,6 +26,16 @@ visible = false
|
||||
position = Vector2( 0, -3 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="Player Detector" type="Area2D" parent="."]
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
input_pickable = false
|
||||
monitorable = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player Detector"]
|
||||
visible = false
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="Light2D" type="Light2D" parent="."]
|
||||
scale = Vector2( 0.5, 0.5 )
|
||||
texture = ExtResource( 2 )
|
||||
@@ -38,3 +52,6 @@ range_item_cull_mask = 4
|
||||
[node name="LightOccluder2D" type="LightOccluder2D" parent="."]
|
||||
show_behind_parent = true
|
||||
occluder = ExtResource( 1 )
|
||||
|
||||
[connection signal="area_entered" from="Player Detector" to="." method="_on_player_detector_area_entered"]
|
||||
[connection signal="area_exited" from="Player Detector" to="." method="_on_player_detector_area_exited"]
|
||||
|
Reference in New Issue
Block a user