added actual enemies

This commit is contained in:
2021-11-30 19:12:50 -06:00
parent 1264dc8e8f
commit 7e39fdf2bc
10 changed files with 416 additions and 159 deletions

27
Enemies/Flaming Skull.gd Normal file
View 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

View File

@@ -0,0 +1,83 @@
[gd_scene load_steps=11 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://Enemies/Flaming Skull.gd" type="Script" id=4]
[ext_resource path="res://Sprites/Enemies/flaming skull design.png" type="Texture" id=5]
[sub_resource type="AtlasTexture" id=3]
flags = 4
atlas = ExtResource( 5 )
region = Rect2( 0, 0, 672, 672 )
[sub_resource type="AtlasTexture" id=4]
flags = 4
atlas = ExtResource( 5 )
region = Rect2( 672, 0, 672, 672 )
[sub_resource type="AtlasTexture" id=5]
flags = 4
atlas = ExtResource( 5 )
region = Rect2( 1344, 0, 672, 672 )
[sub_resource type="SpriteFrames" id=6]
animations = [ {
"frames": [ SubResource( 3 ), SubResource( 4 ), SubResource( 5 ) ],
"loop": true,
"name": "default",
"speed": 5.0
} ]
[sub_resource type="CapsuleShape2D" id=1]
radius = 3.0
height = 2.0
[sub_resource type="CircleShape2D" id=2]
radius = 50.0
[node name="Flaming Skull" type="KinematicBody2D" groups=["enemies"]]
collision_layer = 2
script = ExtResource( 4 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
scale = Vector2( 0.0446429, 0.0446429 )
frames = SubResource( 6 )
playing = true
[node name="Hitbox" type="CollisionShape2D" parent="."]
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="."]
visible = false
scale = Vector2( 0.5, 0.5 )
texture = ExtResource( 2 )
color = Color( 0.984314, 0.94902, 0.211765, 0.392157 )
energy = 2.0
range_item_cull_mask = 11
[node name="Light2DEyes" type="Light2D" parent="."]
visible = false
scale = Vector2( 0.1, 0.1 )
texture = ExtResource( 2 )
offset = Vector2( 5, -40 )
range_item_cull_mask = 4
[node name="LightOccluder2D" type="LightOccluder2D" parent="."]
visible = false
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"]

View File

@@ -7,21 +7,21 @@ var velocity: Vector2 = Vector2.ZERO
func _physics_process(_delta: float) -> void:
velocity = Vector2.ZERO
velocity = Vector2.ZERO
if player:
velocity = position.direction_to(player.position).normalized() * SPEED
if player:
velocity = position.direction_to(player.position).normalized() * SPEED
velocity = move_and_slide(velocity)
return
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
if area.get_parent().name == 'Player':
player = area.get_parent()
return
func _on_player_detector_area_exited(_area: Area2D):
player = null
return
player = null
return

51
Enemies/Hellhound.gd Normal file
View File

@@ -0,0 +1,51 @@
extends KinematicBody2D
const SPEED: int = 60
var player: KinematicBody2D = null
var velocity: Vector2 = Vector2.ZERO
var last_x = 0.0
func _physics_process(_delta: float) -> void:
velocity = Vector2.ZERO
if player:
velocity = position.direction_to(player.position).normalized() * SPEED
var angle = position.angle_to_point(player.position)
if abs(angle) > PI/2:
$AnimatedSprite1.scale.x = -0.563
else:
$AnimatedSprite1.scale.x = 0.563
if velocity.x != 0:
last_x = velocity.x
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()
$AnimatedSprite1.animation = "Running"
return
func _on_player_detector_area_exited(_area: Area2D):
player = null
$AnimatedSprite1.animation = "Idle"
return
func _on_Player_Attack_area_entered(area: Area2D) -> void:
if area.get_parent().name == 'Player':
player = area.get_parent()
$AnimatedSprite1.animation = "Jump"
return
func _on_Player_Attack_area_exited(area: Area2D) -> void:
player = null
$AnimatedSprite1.animation = "Running"
return

181
Enemies/Hellhound.tscn Normal file
View File

@@ -0,0 +1,181 @@
[gd_scene load_steps=27 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/hell-hound-idle.png" type="Texture" id=3]
[ext_resource path="res://Enemies/Hellhound.gd" type="Script" id=4]
[ext_resource path="res://Sprites/Enemies/hell-hound-jump.png" type="Texture" id=5]
[ext_resource path="res://Sprites/Enemies/hell-hound-run.png" type="Texture" id=6]
[sub_resource type="AtlasTexture" id=3]
flags = 4
atlas = ExtResource( 5 )
region = Rect2( 0, 0, 65, 48 )
[sub_resource type="AtlasTexture" id=4]
flags = 4
atlas = ExtResource( 5 )
region = Rect2( 65, 0, 65, 48 )
[sub_resource type="AtlasTexture" id=5]
flags = 4
atlas = ExtResource( 5 )
region = Rect2( 130, 0, 65, 48 )
[sub_resource type="AtlasTexture" id=6]
flags = 4
atlas = ExtResource( 5 )
region = Rect2( 195, 0, 65, 48 )
[sub_resource type="AtlasTexture" id=7]
flags = 4
atlas = ExtResource( 5 )
region = Rect2( 260, 0, 65, 48 )
[sub_resource type="AtlasTexture" id=8]
flags = 4
atlas = ExtResource( 5 )
region = Rect2( 325, 0, 65, 48 )
[sub_resource type="AtlasTexture" id=9]
flags = 4
atlas = ExtResource( 3 )
region = Rect2( 0, 0, 64, 32 )
[sub_resource type="AtlasTexture" id=10]
flags = 4
atlas = ExtResource( 3 )
region = Rect2( 64, 0, 64, 32 )
[sub_resource type="AtlasTexture" id=11]
flags = 4
atlas = ExtResource( 3 )
region = Rect2( 128, 0, 64, 32 )
[sub_resource type="AtlasTexture" id=12]
flags = 4
atlas = ExtResource( 3 )
region = Rect2( 192, 0, 64, 32 )
[sub_resource type="AtlasTexture" id=13]
flags = 4
atlas = ExtResource( 3 )
region = Rect2( 256, 0, 64, 32 )
[sub_resource type="AtlasTexture" id=14]
flags = 4
atlas = ExtResource( 3 )
region = Rect2( 320, 0, 64, 32 )
[sub_resource type="AtlasTexture" id=15]
flags = 4
atlas = ExtResource( 6 )
region = Rect2( 0, 0, 67, 32 )
[sub_resource type="AtlasTexture" id=16]
flags = 4
atlas = ExtResource( 6 )
region = Rect2( 67, 0, 67, 32 )
[sub_resource type="AtlasTexture" id=17]
flags = 4
atlas = ExtResource( 6 )
region = Rect2( 134, 0, 67, 32 )
[sub_resource type="AtlasTexture" id=18]
flags = 4
atlas = ExtResource( 6 )
region = Rect2( 201, 0, 67, 32 )
[sub_resource type="AtlasTexture" id=19]
flags = 4
atlas = ExtResource( 6 )
region = Rect2( 268, 0, 67, 32 )
[sub_resource type="SpriteFrames" id=20]
animations = [ {
"frames": [ SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ) ],
"loop": true,
"name": "Jump",
"speed": 8.0
}, {
"frames": [ SubResource( 9 ), SubResource( 10 ), SubResource( 11 ), SubResource( 12 ), SubResource( 13 ), SubResource( 14 ) ],
"loop": true,
"name": "Idle",
"speed": 3.0
}, {
"frames": [ SubResource( 15 ), SubResource( 16 ), SubResource( 17 ), SubResource( 18 ), SubResource( 19 ) ],
"loop": true,
"name": "Running",
"speed": 5.0
} ]
[sub_resource type="CapsuleShape2D" id=1]
radius = 3.0
height = 2.0
[sub_resource type="CircleShape2D" id=2]
radius = 50.0
[node name="Hellhound" type="KinematicBody2D" groups=["enemies"]]
collision_layer = 2
script = ExtResource( 4 )
[node name="AnimatedSprite1" type="AnimatedSprite" parent="."]
position = Vector2( 1, -3 )
scale = Vector2( 0.5625, 0.5625 )
frames = SubResource( 20 )
animation = "Idle"
playing = true
[node name="Hitbox" type="CollisionShape2D" parent="."]
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="Player Attack" type="Area2D" parent="."]
visible = false
collision_layer = 0
collision_mask = 2
input_pickable = false
monitorable = false
[node name="Attack" type="CollisionShape2D" parent="Player Attack"]
visible = false
scale = Vector2( 0.5, 0.5 )
shape = SubResource( 2 )
[node name="Light2D" type="Light2D" parent="."]
visible = false
scale = Vector2( 0.5, 0.5 )
texture = ExtResource( 2 )
color = Color( 0.984314, 0.94902, 0.211765, 0.392157 )
energy = 2.0
range_item_cull_mask = 11
[node name="Light2DEyes" type="Light2D" parent="."]
visible = false
scale = Vector2( 0.1, 0.1 )
texture = ExtResource( 2 )
offset = Vector2( 5, -40 )
range_item_cull_mask = 4
[node name="LightOccluder2D" type="LightOccluder2D" parent="."]
visible = false
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"]
[connection signal="area_entered" from="Player Attack" to="." method="_on_Player_Attack_area_entered"]
[connection signal="area_exited" from="Player Attack" to="." method="_on_Player_Attack_area_exited"]

View File

@@ -4,36 +4,36 @@ signal complete(option)
func _on_new_game_button_pressed() -> void:
emit_signal('complete', 'new game')
return
emit_signal('complete', 'new game')
return
func _on_quit_button_pressed() -> void:
get_tree().quit()
return
get_tree().quit()
return
func _on_continue_button_mouse_entered() -> void:
if not $'Menu/Menu Elements/Menu Options/Continue/Continue Button'.disabled:
$'Menu Button Hover'.play(0.0)
return
if not $'Menu/Menu Elements/Menu Options/Continue/Continue Button'.disabled:
$'Menu Button Hover'.play(0.0)
return
func _on_new_game_button_mouse_entered() -> void:
$'Menu Button Hover'.play(0.0)
return
$'Menu Button Hover'.play(0.0)
return
func _on_settings_button_mouse_entered() -> void:
$'Menu Button Hover'.play(0.0)
return
$'Menu Button Hover'.play(0.0)
return
func _on_credits_button_mouse_entered() -> void:
$'Menu Button Hover'.play(0.0)
return
$'Menu Button Hover'.play(0.0)
return
func _on_quit_button_mouse_entered() -> void:
$'Menu Button Hover'.play(0.0)
return
$'Menu Button Hover'.play(0.0)
return

View File

@@ -44,7 +44,7 @@ __meta__ = {
[node name="Menu Elements" type="VBoxContainer" parent="Menu"]
margin_left = 42.0
margin_top = 11.0
margin_top = 10.0
margin_right = 257.0
margin_bottom = 149.0
alignment = 2
@@ -61,7 +61,7 @@ valign = 1
[node name="Menu Options" type="VBoxContainer" parent="Menu/Menu Elements"]
margin_top = 44.0
margin_right = 215.0
margin_bottom = 138.0
margin_bottom = 139.0
[node name="Continue" type="CenterContainer" parent="Menu/Menu Elements/Menu Options"]
margin_right = 215.0
@@ -79,19 +79,19 @@ texture_disabled = ExtResource( 6 )
[node name="New Game" type="CenterContainer" parent="Menu/Menu Elements/Menu Options"]
margin_top = 19.0
margin_right = 215.0
margin_bottom = 33.0
margin_bottom = 34.0
[node name="New Game Button" type="TextureButton" parent="Menu/Menu Elements/Menu Options/New Game"]
margin_left = 66.0
margin_right = 149.0
margin_bottom = 14.0
margin_bottom = 15.0
texture_normal = ExtResource( 5 )
texture_hover = ExtResource( 7 )
[node name="Settings" type="CenterContainer" parent="Menu/Menu Elements/Menu Options"]
margin_top = 37.0
margin_top = 38.0
margin_right = 215.0
margin_bottom = 56.0
margin_bottom = 57.0
[node name="Settings Button" type="TextureButton" parent="Menu/Menu Elements/Menu Options/Settings"]
margin_left = 77.0
@@ -101,9 +101,9 @@ texture_normal = ExtResource( 1 )
texture_hover = ExtResource( 10 )
[node name="Credits" type="CenterContainer" parent="Menu/Menu Elements/Menu Options"]
margin_top = 60.0
margin_top = 61.0
margin_right = 215.0
margin_bottom = 75.0
margin_bottom = 76.0
[node name="Credits Button" type="TextureButton" parent="Menu/Menu Elements/Menu Options/Credits"]
margin_left = 82.0
@@ -113,9 +113,9 @@ texture_normal = ExtResource( 3 )
texture_hover = ExtResource( 9 )
[node name="Quit" type="CenterContainer" parent="Menu/Menu Elements/Menu Options"]
margin_top = 79.0
margin_top = 80.0
margin_right = 215.0
margin_bottom = 94.0
margin_bottom = 95.0
[node name="Quit Button" type="TextureButton" parent="Menu/Menu Elements/Menu Options/Quit"]
margin_left = 90.0

File diff suppressed because one or more lines are too long

View File

@@ -2,5 +2,5 @@ extends Node2D
func _ready() -> void:
$YSort/Player.load_hud($HUD)
return
$YSort/Player.load_hud($HUD)
return

View File

@@ -56,7 +56,7 @@ func _on_Hitbox_body_entered(body: Node) -> void:
if health_index != 0:
health_index -= 1
hud.update_health(HEALTH_SLICES[health_index])
#hud.update_health(HEALTH_SLICES[health_index])
return