Fixed debugger errors in many files and optimized some scenes/code

This commit is contained in:
VoidTwo
2021-12-12 23:55:59 -06:00
parent fc6dfdef4d
commit ef5ce684eb
39 changed files with 657 additions and 740 deletions

View File

@@ -10,49 +10,49 @@ var counter: int = 0
func _physics_process(_delta: float) -> void:
velocity = Vector2.ZERO
velocity = Vector2.ZERO
if player and position.distance_to(player.position) > 1:
velocity = position.direction_to(player.position).normalized() * SPEED
if player and position.distance_to(player.position) > 1:
velocity = position.direction_to(player.position).normalized() * SPEED
if hit == true:
if counter < 15:
if counter % 5 == 0:
$AnimatedSprite.visible = false
else:
$AnimatedSprite.visible = true
counter += 1
velocity = Vector2.ZERO
else:
counter = 0
hit = false
if hit == true:
if counter < 15:
if counter % 5 == 0:
$AnimatedSprite.visible = false
else:
$AnimatedSprite.visible = true
counter += 1
velocity = Vector2.ZERO
else:
counter = 0
hit = false
velocity = move_and_slide(velocity)
return
velocity = move_and_slide(velocity)
return
func _on_player_detector_body_entered(body: Node) -> void:
if body.is_in_group('player'):
player = body
return
if body.is_in_group('player'):
player = body
return
func _on_player_detector_body_exited(body: Node) -> void:
if body.is_in_group('player'):
player = null
return
if body.is_in_group('player'):
player = null
return
func _on_hitbox_area_entered(area: Area2D) -> void:
if area.is_in_group('player_weapon_1'):
health -= 1
hit = true
elif area.is_in_group('player_weapon_2'):
health -= 2
hit = true
if area.is_in_group('player_weapon_1'):
health -= 1
hit = true
elif area.is_in_group('player_weapon_2'):
health -= 2
hit = true
if health <= 0:
call_deferred('queue_free')
return
if health <= 0:
call_deferred('queue_free')
return

61
Enemies/Ghost Enemy.gd Normal file
View File

@@ -0,0 +1,61 @@
extends KinematicBody2D
export var fireball: PackedScene
var player: KinematicBody2D = null
var move: Vector2 = Vector2.ZERO
const SPEED: int = 50
var counter: int = 0
var velocity: Vector2 = Vector2.ZERO
var health: int = 4
func _ready() -> void:
visible = false
return
func _physics_process(_delta: float) -> void:
velocity = Vector2.ZERO
if player and position.distance_to(player.position) > 1:
velocity = position.direction_to(player.position).normalized() * SPEED
velocity = move_and_slide(velocity)
return
func _on_Area2D_body_entered(body: Node) -> void:
if body.is_in_group('player'):
player = body
if counter == 0:
self.visible = true
$AnimatedSprite.play('appear')
counter = 1
return
func _on_AnimatedSprite_animation_finished() -> void:
$AnimatedSprite.play('idle')
return
func _on_Hitbox_area_entered(area: Area2D) -> void:
if area.is_in_group('player_weapon_1'):
health -= 1
elif area.is_in_group('player_weapon_2'):
health -= 2
if health <= 0:
$AnimatedSprite.play('vanish')
yield($AnimatedSprite, 'animation_finished')
call_deferred('queue_free')
return
func _on_Projectile_Timer_timeout() -> void:
if player:
var projectile: Node = fireball.instance()
projectile.init($AnimatedSprite.global_position, player.position)
get_tree().get_current_scene().get_node('Projectiles').add_child(projectile)
$AnimatedSprite.play('shriek')
return

View File

@@ -4,7 +4,7 @@
[ext_resource path="res://Sprites/Assets/ghost-idle.png" type="Texture" id=2]
[ext_resource path="res://Sprites/Assets/ghost-shriek.png" type="Texture" id=3]
[ext_resource path="res://Sprites/Assets/ghost-vanish.png" type="Texture" id=4]
[ext_resource path="res://Enemies/Ghost_Enemy.gd" type="Script" id=5]
[ext_resource path="res://Enemies/Ghost Enemy.gd" type="Script" id=5]
[ext_resource path="res://Enemies/Projectiles/Fireball.tscn" type="PackedScene" id=6]
[ext_resource path="res://Sprites/Levels/Environment/Fire_Column_Medium_14.png" type="Texture" id=7]
@@ -36,29 +36,21 @@ region = Rect2( 320, 0, 64, 80 )
atlas = ExtResource( 2 )
region = Rect2( 384, 0, 64, 80 )
[sub_resource type="AtlasTexture" id=8]
atlas = ExtResource( 1 )
region = Rect2( 0, 0, 64, 48 )
[sub_resource type="AtlasTexture" id=23]
atlas = ExtResource( 3 )
region = Rect2( 128, 0, 64, 80 )
[sub_resource type="AtlasTexture" id=9]
atlas = ExtResource( 1 )
region = Rect2( 64, 0, 64, 48 )
[sub_resource type="AtlasTexture" id=24]
atlas = ExtResource( 3 )
region = Rect2( 192, 0, 64, 80 )
[sub_resource type="AtlasTexture" id=10]
atlas = ExtResource( 1 )
region = Rect2( 128, 0, 64, 48 )
[sub_resource type="AtlasTexture" id=22]
atlas = ExtResource( 3 )
region = Rect2( 64, 0, 64, 80 )
[sub_resource type="AtlasTexture" id=11]
atlas = ExtResource( 1 )
region = Rect2( 192, 0, 64, 48 )
[sub_resource type="AtlasTexture" id=12]
atlas = ExtResource( 1 )
region = Rect2( 256, 0, 64, 48 )
[sub_resource type="AtlasTexture" id=13]
atlas = ExtResource( 1 )
region = Rect2( 320, 0, 64, 48 )
[sub_resource type="AtlasTexture" id=21]
atlas = ExtResource( 3 )
region = Rect2( 0, 0, 64, 80 )
[sub_resource type="AtlasTexture" id=14]
atlas = ExtResource( 4 )
@@ -88,21 +80,29 @@ region = Rect2( 320, 0, 64, 64 )
atlas = ExtResource( 4 )
region = Rect2( 384, 0, 64, 64 )
[sub_resource type="AtlasTexture" id=23]
atlas = ExtResource( 3 )
region = Rect2( 128, 0, 64, 80 )
[sub_resource type="AtlasTexture" id=8]
atlas = ExtResource( 1 )
region = Rect2( 0, 0, 64, 48 )
[sub_resource type="AtlasTexture" id=24]
atlas = ExtResource( 3 )
region = Rect2( 192, 0, 64, 80 )
[sub_resource type="AtlasTexture" id=9]
atlas = ExtResource( 1 )
region = Rect2( 64, 0, 64, 48 )
[sub_resource type="AtlasTexture" id=22]
atlas = ExtResource( 3 )
region = Rect2( 64, 0, 64, 80 )
[sub_resource type="AtlasTexture" id=10]
atlas = ExtResource( 1 )
region = Rect2( 128, 0, 64, 48 )
[sub_resource type="AtlasTexture" id=21]
atlas = ExtResource( 3 )
region = Rect2( 0, 0, 64, 80 )
[sub_resource type="AtlasTexture" id=11]
atlas = ExtResource( 1 )
region = Rect2( 192, 0, 64, 48 )
[sub_resource type="AtlasTexture" id=12]
atlas = ExtResource( 1 )
region = Rect2( 256, 0, 64, 48 )
[sub_resource type="AtlasTexture" id=13]
atlas = ExtResource( 1 )
region = Rect2( 320, 0, 64, 48 )
[sub_resource type="SpriteFrames" id=25]
animations = [ {
@@ -111,9 +111,9 @@ animations = [ {
"name": "idle",
"speed": 5.0
}, {
"frames": [ SubResource( 8 ), SubResource( 9 ), SubResource( 10 ), SubResource( 11 ), SubResource( 12 ), SubResource( 13 ) ],
"frames": [ SubResource( 23 ), SubResource( 24 ), SubResource( 22 ), SubResource( 21 ) ],
"loop": true,
"name": "appear",
"name": "shriek",
"speed": 5.0
}, {
"frames": [ SubResource( 14 ), SubResource( 15 ), SubResource( 16 ), SubResource( 17 ), SubResource( 18 ), SubResource( 19 ), SubResource( 20 ) ],
@@ -121,9 +121,9 @@ animations = [ {
"name": "vanish",
"speed": 5.0
}, {
"frames": [ SubResource( 23 ), SubResource( 24 ), SubResource( 22 ), SubResource( 21 ) ],
"frames": [ SubResource( 8 ), SubResource( 9 ), SubResource( 10 ), SubResource( 11 ), SubResource( 12 ), SubResource( 13 ) ],
"loop": true,
"name": "shriek",
"name": "appear",
"speed": 5.0
} ]
@@ -144,10 +144,10 @@ orbit_velocity_random = 0.0
color = Color( 0.729412, 0, 0, 1 )
hue_variation = 1.0
[node name="KinematicBody2D" type="KinematicBody2D"]
[node name="Ghost Enemy" type="KinematicBody2D"]
z_index = 2
script = ExtResource( 5 )
Fireball = ExtResource( 6 )
fireball = ExtResource( 6 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
frames = SubResource( 25 )
@@ -165,9 +165,7 @@ shape = SubResource( 26 )
position = Vector2( 0.530334, 11.3032 )
shape = SubResource( 27 )
[node name="Hitbox" type="Area2D" parent="." groups=[
"enemy_hitbox_1",
]]
[node name="Hitbox" type="Area2D" parent="." groups=["enemy_hitbox_1"]]
light_mask = 0
collision_layer = 4
collision_mask = 2

View File

@@ -1,61 +0,0 @@
extends KinematicBody2D
# Declare member variables here. Examples:
# var a: int = 2
# var b: String = "text"
export var Fireball: PackedScene
onready var player = null
var move = Vector2.ZERO
var SPEED = 50
var counter = 0
var velocity: Vector2 = Vector2.ZERO
var health: int = 4
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
self.visible = false
func _physics_process(delta):
velocity = Vector2.ZERO
if player and position.distance_to(player.position) > 1:
velocity = position.direction_to(player.position).normalized() * SPEED
velocity = move_and_slide(velocity)
func _on_Area2D_body_entered(body):
if body.is_in_group('player'):
player = body
if counter == 0:
self.visible = true
$AnimatedSprite.play("appear")
counter = 1
func _on_AnimatedSprite_animation_finished():
$AnimatedSprite.play("idle")
func _on_Hitbox_area_entered(area):
if area.is_in_group('player_weapon_1'):
health -= 1
elif area.is_in_group('player_weapon_2'):
health -= 2
if health <= 0:
$AnimatedSprite.play("vanish")
yield($AnimatedSprite, "animation_finished")
call_deferred('queue_free')
return
func _on_Projectile_Timer_timeout():
if player:
var projectile: Node = Fireball.instance()
projectile.init($AnimatedSprite.global_position, player.position)
get_tree().get_current_scene().get_node('Projectiles').add_child(projectile)
$AnimatedSprite.play("shriek")

View File

@@ -10,65 +10,65 @@ var counter: int = 0
func _physics_process(_delta: float) -> void:
velocity = Vector2.ZERO
velocity = Vector2.ZERO
if player and position.distance_to(player.position) > 1:
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 player and position.distance_to(player.position) > 1:
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 hit == true:
if counter < 15:
if counter % 5 == 0:
$AnimatedSprite1.visible = false
else:
$AnimatedSprite1.visible = true
counter += 1
velocity = Vector2.ZERO
else:
counter = 0
hit = false
if hit == true:
if counter < 15:
if counter % 5 == 0:
$AnimatedSprite1.visible = false
else:
$AnimatedSprite1.visible = true
counter += 1
velocity = Vector2.ZERO
else:
counter = 0
hit = false
velocity = move_and_slide(velocity)
return
velocity = move_and_slide(velocity)
return
func _on_player_detector_body_entered(body: Node) -> void:
if body.is_in_group('player'):
player = body
$AnimatedSprite1.animation = 'Running'
return
if body.is_in_group('player'):
player = body
$AnimatedSprite1.animation = 'Running'
return
func _on_player_detector_body_exited(body: Node) -> void:
if body.is_in_group('player'):
player = null
$AnimatedSprite1.animation = 'Idle'
return
if body.is_in_group('player'):
player = null
$AnimatedSprite1.animation = 'Idle'
return
func _on_hitbox_area_entered(area: Area2D) -> void:
if area.is_in_group('player_weapon_1'):
health -= 1
hit = true
elif area.is_in_group('player_weapon_2'):
health -= 2
hit = true
if area.is_in_group('player_weapon_1'):
health -= 1
hit = true
elif area.is_in_group('player_weapon_2'):
health -= 2
hit = true
if health <= 0:
call_deferred('queue_free')
return
if health <= 0:
call_deferred('queue_free')
return
func _on_Player_Detector__Attack_body_entered(body: Node) -> void:
if body.is_in_group('player'):
player = body
$AnimatedSprite1.animation = 'Jump'
if body.is_in_group('player'):
player = body
$AnimatedSprite1.animation = 'Jump'
func _on_Player_Detector__Attack_body_exited(body: Node) -> void:
if body.is_in_group('player'):
player = body
$AnimatedSprite1.animation = 'Running'
if body.is_in_group('player'):
player = body
$AnimatedSprite1.animation = 'Running'

View File

@@ -1,47 +1,49 @@
extends KinematicBody2D
onready var SNOWBALL_BLUE_SCENE = preload("res://Enemies/Snowball Blue.tscn")
onready var SNOWBALL_BLUE_SCENE: Resource = preload('res://Enemies/Snowball Blue.tscn')
var player = null
var move = Vector2.ZERO
var speed = .5
var player: KinematicBody2D = null
var velocity: Vector2 = Vector2.ZERO
const SPEED: int = 50
var health: int = 2
func _physics_process(delta: float) -> void:
move = Vector2.ZERO
func _physics_process(_delta: float) -> void:
velocity = Vector2.ZERO
if player != null:
move = position.direction_to(player.position) * speed
else:
move = Vector2.ZERO
move = move.normalized()
move = move_and_collide(move)
if player and position.distance_to(player.position) > 1:
velocity = position.direction_to(player.position).normalized() * SPEED
velocity = move_and_slide(velocity)
return
func _on_Area2D_body_entered(body: Node) -> void:
if body != self && !(body.name.begins_with("tree")) && !(body.name.begins_with("snowmen_enemy")) && !(body.name.begins_with("wall")):
player = body
return
func _on_Area2D_body_exited(body: Node) -> void:
if !(body.name.begins_with("tree")) && !(body.name.begins_with("snowmen_enemy")) && !(body.name.begins_with("wall")):
player = null
return
func fire():
func fire() -> void:
var snowball = SNOWBALL_BLUE_SCENE.instance()
snowball.position = get_global_position()
snowball.player = player
get_parent().add_child(snowball)
$Timer.set_wait_time(1)
return
func _on_Timer_timeout() -> void:
if player != null:
fire()
return
func _on_player_detector_area_entered(area: Area2D) -> void:
if area.get_parent().name == 'Player':
@@ -49,10 +51,11 @@ func _on_player_detector_area_entered(area: Area2D) -> void:
return
func _on_player_detector_area_exited(_area: Area2D):
func _on_player_detector_area_exited(_area: Area2D) -> void:
player = null
return
func _on_hitbox_area_entered(area: Area2D) -> void:
if area.is_in_group('player_weapon_1'):
health -= 1

View File

@@ -1,47 +1,48 @@
extends KinematicBody2D
onready var SNOWBALL_SCENE = preload("res://Enemies/Snowball.tscn")
onready var SNOWBALL_SCENE: Resource = preload('res://Enemies/Snowball.tscn')
var player = null
var move = Vector2.ZERO
var speed = .5
var player: KinematicBody2D = null
var velocity: Vector2 = Vector2.ZERO
const SPEED: int = 50
var health: int = 2
func _physics_process(delta: float) -> void:
move = Vector2.ZERO
func _physics_process(_delta: float) -> void:
velocity = Vector2.ZERO
if player != null:
move = position.direction_to(player.position) * speed
else:
move = Vector2.ZERO
move = move.normalized()
move = move_and_collide(move)
if player and position.distance_to(player.position) > 1:
velocity = position.direction_to(player.position).normalized() * SPEED
velocity = move_and_slide(velocity)
return
func _on_Area2D_body_entered(body: Node) -> void:
if body != self && !(body.name.begins_with("tree")) && !(body.name.begins_with("snowmen_enemy")) && !(body.name.begins_with("wall")):
player = body
return
func _on_Area2D_body_exited(body: Node) -> void:
if !(body.name.begins_with("tree")) && !(body.name.begins_with("snowmen_enemy")) && !(body.name.begins_with("wall")):
player = null
return
func fire():
func fire() -> void:
var snowball = SNOWBALL_SCENE.instance()
snowball.position = get_global_position()
snowball.player = player
get_parent().add_child(snowball)
$Timer.set_wait_time(1)
return
func _on_Timer_timeout() -> void:
if player != null:
fire()
return
func _on_player_detector_area_entered(area: Area2D) -> void:
@@ -50,12 +51,12 @@ func _on_player_detector_area_entered(area: Area2D) -> void:
return
func _on_player_detector_area_exited(_area: Area2D):
func _on_player_detector_area_exited(_area: Area2D) -> void:
player = null
return
func _on_hitbox_area_entered(area: Area2D) -> void:
print("HIT")
if area.is_in_group('player_weapon_1'):
health -= 1
elif area.is_in_group('player_weapon_2'):