Code cleanup and minor fixes to Level 3
This commit is contained in:
@@ -8,33 +8,33 @@ var health: int = 2
|
|||||||
|
|
||||||
|
|
||||||
func _physics_process(_delta: float) -> void:
|
func _physics_process(_delta: float) -> void:
|
||||||
velocity = Vector2.ZERO
|
velocity = Vector2.ZERO
|
||||||
|
|
||||||
if player and position.distance_to(player.position) > 1:
|
if player and position.distance_to(player.position) > 1:
|
||||||
velocity = position.direction_to(player.position).normalized() * SPEED
|
velocity = position.direction_to(player.position).normalized() * SPEED
|
||||||
|
|
||||||
velocity = move_and_slide(velocity)
|
velocity = move_and_slide(velocity)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func _on_player_detector_body_entered(body: Node) -> void:
|
func _on_player_detector_body_entered(body: Node) -> void:
|
||||||
if body.is_in_group('player'):
|
if body.is_in_group('player'):
|
||||||
player = body
|
player = body
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func _on_player_detector_body_exited(body: Node) -> void:
|
func _on_player_detector_body_exited(body: Node) -> void:
|
||||||
if body.is_in_group('player'):
|
if body.is_in_group('player'):
|
||||||
player = null
|
player = null
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func _on_hitbox_area_entered(area: Area2D) -> void:
|
func _on_hitbox_area_entered(area: Area2D) -> void:
|
||||||
if area.is_in_group('player_weapon_1'):
|
if area.is_in_group('player_weapon_1'):
|
||||||
health -= 1
|
health -= 1
|
||||||
elif area.is_in_group('player_weapon_2'):
|
elif area.is_in_group('player_weapon_2'):
|
||||||
health -= 2
|
health -= 2
|
||||||
|
|
||||||
if health <= 0:
|
if health <= 0:
|
||||||
call_deferred('queue_free')
|
call_deferred('queue_free')
|
||||||
return
|
return
|
||||||
|
@@ -10,44 +10,44 @@ var health: int = 1
|
|||||||
|
|
||||||
|
|
||||||
func _physics_process(_delta: float) -> void:
|
func _physics_process(_delta: float) -> void:
|
||||||
velocity = Vector2.ZERO
|
velocity = Vector2.ZERO
|
||||||
|
|
||||||
if player:
|
if player:
|
||||||
if position.distance_to(player.position) < 40:
|
if position.distance_to(player.position) < 40:
|
||||||
velocity = position.direction_to(player.position).normalized() * -SPEED
|
velocity = position.direction_to(player.position).normalized() * -SPEED
|
||||||
elif position.distance_to(player.position) > 41:
|
elif position.distance_to(player.position) > 41:
|
||||||
velocity = position.direction_to(player.position).normalized() * SPEED
|
velocity = position.direction_to(player.position).normalized() * SPEED
|
||||||
|
|
||||||
velocity = move_and_slide(velocity)
|
velocity = move_and_slide(velocity)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func _on_player_detector_body_entered(body: Node) -> void:
|
func _on_player_detector_body_entered(body: Node) -> void:
|
||||||
if body.is_in_group('player'):
|
if body.is_in_group('player'):
|
||||||
player = body
|
player = body
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func _on_player_detector_body_exited(body: Node) -> void:
|
func _on_player_detector_body_exited(body: Node) -> void:
|
||||||
if body.is_in_group('player'):
|
if body.is_in_group('player'):
|
||||||
player = null
|
player = null
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func _on_projectile_timer_timeout() -> void:
|
func _on_projectile_timer_timeout() -> void:
|
||||||
if player:
|
if player:
|
||||||
var projectile: Node = creepy_hand.instance()
|
var projectile: Node = creepy_hand.instance()
|
||||||
projectile.init($Sprite.global_position, player.position)
|
projectile.init($Sprite.global_position, player.position)
|
||||||
get_tree().get_current_scene().get_node('Projectiles').add_child(projectile)
|
get_tree().get_current_scene().get_node('Projectiles').add_child(projectile)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func _on_hitbox_area_entered(area: Area2D) -> void:
|
func _on_hitbox_area_entered(area: Area2D) -> void:
|
||||||
if area.is_in_group('player_weapon_1'):
|
if area.is_in_group('player_weapon_1'):
|
||||||
health -= 1
|
health -= 1
|
||||||
elif area.is_in_group('player_weapon_2'):
|
elif area.is_in_group('player_weapon_2'):
|
||||||
health -= 2
|
health -= 2
|
||||||
|
|
||||||
if health <= 0:
|
if health <= 0:
|
||||||
call_deferred('queue_free')
|
call_deferred('queue_free')
|
||||||
return
|
return
|
||||||
|
@@ -10,49 +10,49 @@ var counter: int = 0
|
|||||||
|
|
||||||
|
|
||||||
func _physics_process(_delta: float) -> void:
|
func _physics_process(_delta: float) -> void:
|
||||||
velocity = Vector2.ZERO
|
velocity = Vector2.ZERO
|
||||||
|
|
||||||
if player and position.distance_to(player.position) > 1:
|
if player and position.distance_to(player.position) > 1:
|
||||||
velocity = position.direction_to(player.position).normalized() * SPEED
|
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
|
|
||||||
|
|
||||||
|
|
||||||
velocity = move_and_slide(velocity)
|
|
||||||
return
|
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
|
||||||
|
|
||||||
|
|
||||||
func _on_player_detector_body_entered(body: Node) -> void:
|
func _on_player_detector_body_entered(body: Node) -> void:
|
||||||
if body.is_in_group('player'):
|
if body.is_in_group('player'):
|
||||||
player = body
|
player = body
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func _on_player_detector_body_exited(body: Node) -> void:
|
func _on_player_detector_body_exited(body: Node) -> void:
|
||||||
if body.is_in_group('player'):
|
if body.is_in_group('player'):
|
||||||
player = null
|
player = null
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func _on_hitbox_area_entered(area: Area2D) -> void:
|
func _on_hitbox_area_entered(area: Area2D) -> void:
|
||||||
if area.is_in_group('player_weapon_1'):
|
if area.is_in_group('player_weapon_1'):
|
||||||
health -= 1
|
health -= 1
|
||||||
hit = true
|
hit = true
|
||||||
elif area.is_in_group('player_weapon_2'):
|
elif area.is_in_group('player_weapon_2'):
|
||||||
health -= 2
|
health -= 2
|
||||||
hit = true
|
hit = true
|
||||||
|
|
||||||
if health <= 0:
|
if health <= 0:
|
||||||
call_deferred('queue_free')
|
call_deferred('queue_free')
|
||||||
return
|
return
|
||||||
|
@@ -10,65 +10,65 @@ var counter: int = 0
|
|||||||
|
|
||||||
|
|
||||||
func _physics_process(_delta: float) -> void:
|
func _physics_process(_delta: float) -> void:
|
||||||
velocity = Vector2.ZERO
|
velocity = Vector2.ZERO
|
||||||
|
|
||||||
if player and position.distance_to(player.position) > 1:
|
if player and position.distance_to(player.position) > 1:
|
||||||
velocity = position.direction_to(player.position).normalized() * SPEED
|
velocity = position.direction_to(player.position).normalized() * SPEED
|
||||||
var angle = position.angle_to_point(player.position)
|
var angle = position.angle_to_point(player.position)
|
||||||
if abs(angle) > PI/2:
|
if abs(angle) > PI/2:
|
||||||
$AnimatedSprite1.scale.x = -0.563
|
$AnimatedSprite1.scale.x = -0.563
|
||||||
else:
|
else:
|
||||||
$AnimatedSprite1.scale.x = 0.563
|
$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
|
|
||||||
|
|
||||||
velocity = move_and_slide(velocity)
|
if hit == true:
|
||||||
return
|
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
|
||||||
|
|
||||||
|
|
||||||
func _on_player_detector_body_entered(body: Node) -> void:
|
func _on_player_detector_body_entered(body: Node) -> void:
|
||||||
if body.is_in_group('player'):
|
if body.is_in_group('player'):
|
||||||
player = body
|
player = body
|
||||||
$AnimatedSprite1.animation = 'Running'
|
$AnimatedSprite1.animation = 'Running'
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func _on_player_detector_body_exited(body: Node) -> void:
|
func _on_player_detector_body_exited(body: Node) -> void:
|
||||||
if body.is_in_group('player'):
|
if body.is_in_group('player'):
|
||||||
player = null
|
player = null
|
||||||
$AnimatedSprite1.animation = 'Idle'
|
$AnimatedSprite1.animation = 'Idle'
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func _on_hitbox_area_entered(area: Area2D) -> void:
|
func _on_hitbox_area_entered(area: Area2D) -> void:
|
||||||
if area.is_in_group('player_weapon_1'):
|
if area.is_in_group('player_weapon_1'):
|
||||||
health -= 1
|
health -= 1
|
||||||
hit = true
|
hit = true
|
||||||
elif area.is_in_group('player_weapon_2'):
|
elif area.is_in_group('player_weapon_2'):
|
||||||
health -= 2
|
health -= 2
|
||||||
hit = true
|
hit = true
|
||||||
|
|
||||||
if health <= 0:
|
if health <= 0:
|
||||||
call_deferred('queue_free')
|
call_deferred('queue_free')
|
||||||
return
|
return
|
||||||
|
|
||||||
func _on_Player_Detector__Attack_body_entered(body: Node) -> void:
|
func _on_Player_Detector__Attack_body_entered(body: Node) -> void:
|
||||||
if body.is_in_group('player'):
|
if body.is_in_group('player'):
|
||||||
player = body
|
player = body
|
||||||
$AnimatedSprite1.animation = 'Jump'
|
$AnimatedSprite1.animation = 'Jump'
|
||||||
|
|
||||||
|
|
||||||
func _on_Player_Detector__Attack_body_exited(body: Node) -> void:
|
func _on_Player_Detector__Attack_body_exited(body: Node) -> void:
|
||||||
if body.is_in_group('player'):
|
if body.is_in_group('player'):
|
||||||
player = body
|
player = body
|
||||||
$AnimatedSprite1.animation = 'Running'
|
$AnimatedSprite1.animation = 'Running'
|
||||||
|
@@ -9,58 +9,58 @@ var health: int = 2
|
|||||||
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
move = Vector2.ZERO
|
move = Vector2.ZERO
|
||||||
|
|
||||||
if player != null:
|
if player != null:
|
||||||
move = position.direction_to(player.position) * speed
|
move = position.direction_to(player.position) * speed
|
||||||
else:
|
else:
|
||||||
move = Vector2.ZERO
|
move = Vector2.ZERO
|
||||||
|
|
||||||
move = move.normalized()
|
move = move.normalized()
|
||||||
move = move_and_collide(move)
|
move = move_and_collide(move)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _on_Area2D_body_entered(body: Node) -> void:
|
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")):
|
if body != self && !(body.name.begins_with("tree")) && !(body.name.begins_with("snowmen_enemy")) && !(body.name.begins_with("wall")):
|
||||||
player = body
|
player = body
|
||||||
|
|
||||||
|
|
||||||
func _on_Area2D_body_exited(body: Node) -> void:
|
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")):
|
if !(body.name.begins_with("tree")) && !(body.name.begins_with("snowmen_enemy")) && !(body.name.begins_with("wall")):
|
||||||
player = null
|
player = null
|
||||||
|
|
||||||
|
|
||||||
func fire():
|
func fire():
|
||||||
var snowball = SNOWBALL_SCENE.instance()
|
var snowball = SNOWBALL_SCENE.instance()
|
||||||
snowball.position = get_global_position()
|
snowball.position = get_global_position()
|
||||||
snowball.player = player
|
snowball.player = player
|
||||||
get_parent().add_child(snowball)
|
get_parent().add_child(snowball)
|
||||||
$Timer.set_wait_time(1)
|
$Timer.set_wait_time(1)
|
||||||
|
|
||||||
|
|
||||||
func _on_Timer_timeout() -> void:
|
func _on_Timer_timeout() -> void:
|
||||||
if player != null:
|
if player != null:
|
||||||
fire()
|
fire()
|
||||||
|
|
||||||
|
|
||||||
func _on_player_detector_area_entered(area: Area2D) -> void:
|
func _on_player_detector_area_entered(area: Area2D) -> void:
|
||||||
if area.get_parent().name == 'Player':
|
if area.get_parent().name == 'Player':
|
||||||
player = area.get_parent()
|
player = area.get_parent()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func _on_player_detector_area_exited(_area: Area2D):
|
func _on_player_detector_area_exited(_area: Area2D):
|
||||||
player = null
|
player = null
|
||||||
return
|
return
|
||||||
|
|
||||||
func _on_hitbox_area_entered(area: Area2D) -> void:
|
func _on_hitbox_area_entered(area: Area2D) -> void:
|
||||||
print("HIT")
|
print("HIT")
|
||||||
if area.is_in_group('player_weapon_1'):
|
if area.is_in_group('player_weapon_1'):
|
||||||
health -= 1
|
health -= 1
|
||||||
elif area.is_in_group('player_weapon_2'):
|
elif area.is_in_group('player_weapon_2'):
|
||||||
health -= 2
|
health -= 2
|
||||||
|
|
||||||
if health <= 0:
|
if health <= 0:
|
||||||
call_deferred('queue_free')
|
call_deferred('queue_free')
|
||||||
return
|
return
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
extends Label
|
extends Label
|
||||||
|
|
||||||
signal timer_end
|
signal timer_end
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
|
||||||
|
func _process(_delta: float) -> void:
|
||||||
var time_seconds: int = int($Timer.get_time_left())
|
var time_seconds: int = int($Timer.get_time_left())
|
||||||
set_text('%02d:%02d' % [time_seconds, int(($Timer.get_time_left() - time_seconds) * 100)])
|
set_text('%02d:%02d' % [time_seconds, int(($Timer.get_time_left() - time_seconds) * 100)])
|
||||||
|
|
||||||
if $Timer.get_time_left() == 0:
|
if $Timer.get_time_left() == 0:
|
||||||
get_tree().change_scene('res://Levels/Hub World.tscn')
|
get_tree().change_scene('res://Levels/Hub World.tscn')
|
||||||
return
|
return
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
[gd_scene load_steps=4 format=2]
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://GUI/Countdown Timer.gd" type="Script" id=1]
|
[ext_resource path="res://GUI/Countdown Timer.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://Fonts/AtariClassic.ttf" type="DynamicFontData" id=2]
|
[ext_resource path="res://Fonts/AtariClassicSmooth.ttf" type="DynamicFontData" id=2]
|
||||||
|
|
||||||
[sub_resource type="DynamicFont" id=1]
|
[sub_resource type="DynamicFont" id=1]
|
||||||
size = 40
|
size = 40
|
||||||
@@ -14,8 +14,8 @@ margin_right = 335.0
|
|||||||
margin_bottom = 41.0
|
margin_bottom = 41.0
|
||||||
rect_min_size = Vector2( 200, 0 )
|
rect_min_size = Vector2( 200, 0 )
|
||||||
rect_scale = Vector2( 0.25, 0.25 )
|
rect_scale = Vector2( 0.25, 0.25 )
|
||||||
custom_fonts/font = SubResource( 1 )
|
|
||||||
custom_colors/font_color = Color( 0, 0, 0, 1 )
|
custom_colors/font_color = Color( 0, 0, 0, 1 )
|
||||||
|
custom_fonts/font = SubResource( 1 )
|
||||||
align = 1
|
align = 1
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[gd_scene load_steps=4 format=2]
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Levels/Interactives/Coin.gd" type="Script" id=1]
|
[ext_resource path="res://Levels/Interactables/Coin.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://Sprites/Assets/coin.png" type="Texture" id=2]
|
[ext_resource path="res://Sprites/Assets/coin.png" type="Texture" id=2]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id=1]
|
[sub_resource type="CircleShape2D" id=1]
|
@@ -8,7 +8,7 @@ extends Node2D
|
|||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
@@ -17,8 +17,8 @@ func _ready() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_AnimationPlayer_animation_finished(anim_name: String) -> void:
|
func _on_AnimationPlayer_animation_finished(anim_name: String) -> void:
|
||||||
$GemSprite.visible = false
|
$GemSprite.visible = false
|
||||||
|
|
||||||
|
|
||||||
func _on_AnimationPlayer_animation_started(anim_name: String) -> void:
|
func _on_AnimationPlayer_animation_started(anim_name: String) -> void:
|
||||||
$GemSprite.visible = true
|
$GemSprite.visible = true
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[gd_scene load_steps=4 format=2]
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Sprites/Assets/resources_basic.png" type="Texture" id=1]
|
[ext_resource path="res://Sprites/Assets/Resources_Basic.png" type="Texture" id=1]
|
||||||
[ext_resource path="res://Levels/Interactables/Gem.gd" type="Script" id=2]
|
[ext_resource path="res://Levels/Interactables/Gem.gd" type="Script" id=2]
|
||||||
|
|
||||||
[sub_resource type="Animation" id=3]
|
[sub_resource type="Animation" id=3]
|
||||||
|
@@ -13,7 +13,7 @@ signal gem_collected
|
|||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
@@ -22,12 +22,12 @@ func _ready() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_Player_Detector_area_entered(area: Area2D) -> void:
|
func _on_Player_Detector_area_entered(area: Area2D) -> void:
|
||||||
if area.get_parent().name == 'Player':
|
if area.get_parent().name == 'Player':
|
||||||
if is_opened == false:
|
if is_opened == false:
|
||||||
$chestClosed.visible = false
|
$chestClosed.visible = false
|
||||||
$chestOpened.visible = true
|
$chestOpened.visible = true
|
||||||
$Gem.visible = true
|
$Gem.visible = true
|
||||||
$Gem/AnimationPlayer.play('rise')
|
$Gem/AnimationPlayer.play('rise')
|
||||||
is_opened = true
|
is_opened = true
|
||||||
has_gem = false
|
has_gem = false
|
||||||
emit_signal('gem_collected')
|
emit_signal('gem_collected')
|
||||||
|
@@ -1,52 +1,56 @@
|
|||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
onready var coin = preload("res://Levels/Interactives/Coin.tscn")
|
onready var coin = preload('res://Levels/Interactables/Coin.tscn')
|
||||||
onready var coin_container = get_node("coin_container")
|
|
||||||
onready var score_label = get_node('Level 3 HUD/Label')
|
|
||||||
#have event for timer to run out
|
|
||||||
|
|
||||||
|
|
||||||
var screensize
|
var screensize
|
||||||
var score = 0
|
var score = 0
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
$YSort/Player.load_hud($HUD)
|
$YSort/Player.load_hud($HUD)
|
||||||
screensize = get_viewport_rect().size
|
screensize = get_viewport_rect().size
|
||||||
spawn_coins(8)
|
spawn_coins(8)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func spawn_coins(num):
|
func spawn_coins(num: int) -> void:
|
||||||
for i in range(num):
|
for _i in range(num):
|
||||||
var g = coin.instance()
|
var g: Node = coin.instance()
|
||||||
$'coin_container'.add_child(g)
|
$'coin_container'.add_child(g)
|
||||||
g.connect("coin_grabbed", self, "_on_coin_grabbed")
|
g.connect('coin_grabbed', self, '_on_coin_grabbed')
|
||||||
#g.set_pos(Vector2(rand_range(0, screensize.x-40), rand_range(0, screensize.y-40)))
|
#g.set_pos(Vector2(rand_range(0, screensize.x - 40), rand_range(0, screensize.y - 40)))
|
||||||
g.position = Vector2(rand_range(0, screensize.x-40), rand_range(0, screensize.y-40))
|
g.position = Vector2(rand_range(0, screensize.x - 40), rand_range(0, screensize.y - 40))
|
||||||
|
return
|
||||||
|
|
||||||
func _on_coin_grabbed():
|
|
||||||
score+=1
|
|
||||||
print(score)
|
|
||||||
score_label.set_text(str(score) + "/5")
|
|
||||||
|
|
||||||
func _timer_out():
|
func _on_coin_grabbed() -> void:
|
||||||
get_tree().change_scene('res://Levels/Hub World.tscn')
|
score += 1
|
||||||
|
print(score)
|
||||||
|
$'Level 3 HUD/Label'.set_text(str(score) + '/5')
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
func _timer_out() -> void:
|
||||||
|
get_tree().change_scene('res://Levels/Hub World.tscn')
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
func _on_TreasureChest_ice_key_collected() -> void:
|
func _on_TreasureChest_ice_key_collected() -> void:
|
||||||
$YSort/Door/doorClosed.visible = false
|
$YSort/Door/doorClosed.visible = false
|
||||||
$YSort/Door/doorOpened.visible = true
|
$YSort/Door/doorOpened.visible = true
|
||||||
$YSort/DoorCollision.layers = 5
|
$YSort/DoorCollision.layers = 5
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
func _on_DoorDetector_body_entered(body: Node) -> void:
|
func _on_DoorDetector_body_entered(body: Node) -> void:
|
||||||
if body.get_parent().name == 'Player':
|
if body.is_in_group('player'):
|
||||||
print('WIN WIN WIN')
|
print('WIN WIN WIN')
|
||||||
get_tree().change_scene('res://Levels/Hub World.tscn')
|
get_tree().change_scene('res://Levels/Hub World.tscn')
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
func _on_DoorDetector_area_entered(area: Area2D) -> void:
|
func _on_DoorDetector_area_entered(area: Area2D) -> void:
|
||||||
if area.get_parent().name == 'Player':
|
if area.get_parent().name == 'Player':
|
||||||
print('WIN WIN WIN')
|
print('WIN WIN WIN')
|
||||||
get_tree().change_scene('res://Levels/Hub World.tscn') # Replace with function body.
|
get_tree().change_scene('res://Levels/Hub World.tscn')
|
||||||
|
return
|
||||||
|
@@ -177,6 +177,11 @@ position = Vector2( -49.6063, 34.526 )
|
|||||||
position = Vector2( 0, -4.25 )
|
position = Vector2( 0, -4.25 )
|
||||||
shape = SubResource( 5 )
|
shape = SubResource( 5 )
|
||||||
|
|
||||||
|
[node name="Effects" type="Node" parent="."]
|
||||||
|
|
||||||
|
[node name="SlowTime" type="Node" parent="Effects"]
|
||||||
|
script = ExtResource( 16 )
|
||||||
|
|
||||||
[node name="coin_container" type="Control" parent="."]
|
[node name="coin_container" type="Control" parent="."]
|
||||||
margin_right = 40.0
|
margin_right = 40.0
|
||||||
margin_bottom = 40.0
|
margin_bottom = 40.0
|
||||||
@@ -184,18 +189,6 @@ __meta__ = {
|
|||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="Countdown Timer" parent="." instance=ExtResource( 12 )]
|
|
||||||
|
|
||||||
[node name="HUD" parent="." instance=ExtResource( 9 )]
|
|
||||||
|
|
||||||
[node name="Pause Screen" parent="." instance=ExtResource( 10 )]
|
|
||||||
|
|
||||||
[node name="BGM" type="AudioStreamPlayer" parent="."]
|
|
||||||
pause_mode = 2
|
|
||||||
stream = ExtResource( 11 )
|
|
||||||
volume_db = -12.0
|
|
||||||
autoplay = true
|
|
||||||
|
|
||||||
[node name="Level 3 HUD" type="Control" parent="."]
|
[node name="Level 3 HUD" type="Control" parent="."]
|
||||||
margin_left = 0.28064
|
margin_left = 0.28064
|
||||||
margin_top = -12.9083
|
margin_top = -12.9083
|
||||||
@@ -216,10 +209,17 @@ __meta__ = {
|
|||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="Effects" type="Node" parent="."]
|
[node name="HUD" parent="." instance=ExtResource( 9 )]
|
||||||
|
|
||||||
[node name="SlowTime" type="Node" parent="Effects"]
|
[node name="Countdown Timer" parent="HUD" instance=ExtResource( 12 )]
|
||||||
script = ExtResource( 16 )
|
|
||||||
|
[node name="Pause Screen" parent="." instance=ExtResource( 10 )]
|
||||||
|
|
||||||
|
[node name="BGM" type="AudioStreamPlayer" parent="."]
|
||||||
|
pause_mode = 2
|
||||||
|
stream = ExtResource( 11 )
|
||||||
|
volume_db = -12.0
|
||||||
|
autoplay = true
|
||||||
|
|
||||||
[connection signal="area_entered" from="YSort/DoorDetector" to="." method="_on_DoorDetector_area_entered"]
|
[connection signal="area_entered" from="YSort/DoorDetector" to="." method="_on_DoorDetector_area_entered"]
|
||||||
[connection signal="ice_key_collected" from="YSort/TreasureChest" to="." method="_on_TreasureChest_ice_key_collected"]
|
[connection signal="ice_key_collected" from="YSort/TreasureChest" to="." method="_on_TreasureChest_ice_key_collected"]
|
||||||
|
@@ -3,22 +3,22 @@ extends Node2D
|
|||||||
var gems: int = 4
|
var gems: int = 4
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
#$YSort/Player.position = get_viewport_rect().size / 2
|
#$YSort/Player.position = get_viewport_rect().size / 2
|
||||||
$YSort/Player.load_hud($HUD)
|
$YSort/Player.load_hud($HUD)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func _on_TreasureChest_gem_collected() -> void:
|
func _on_TreasureChest_gem_collected() -> void:
|
||||||
gems -= 1
|
gems -= 1
|
||||||
|
|
||||||
if gems == 0:
|
if gems == 0:
|
||||||
$YSort/Items/Door/doorClosed.visible = false
|
$YSort/Items/Door/doorClosed.visible = false
|
||||||
$YSort/Items/Door/doorOpened.visible = true
|
$YSort/Items/Door/doorOpened.visible = true
|
||||||
$DoorCollision.layers = 5
|
$DoorCollision.layers = 5
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _on_NextArea_area_entered(area: Area2D) -> void:
|
func _on_NextArea_area_entered(area: Area2D) -> void:
|
||||||
if area.get_parent().name == 'Player':
|
if area.get_parent().name == 'Player':
|
||||||
$YSort/Player.position.x = 195
|
$YSort/Player.position.x = 195
|
||||||
$YSort/Player.position.y = -335
|
$YSort/Player.position.y = -335
|
||||||
|
@@ -1,18 +1,18 @@
|
|||||||
[gd_scene load_steps=31 format=2]
|
[gd_scene load_steps=31 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Sprites/Levels/Environment/fire_column_medium_12.png" type="Texture" id=1]
|
[ext_resource path="res://Sprites/Levels/Environment/Fire_Column_Medium_12.png" type="Texture" id=1]
|
||||||
[ext_resource path="res://Enemies/Hellhound.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://Enemies/Hellhound.tscn" type="PackedScene" id=2]
|
||||||
[ext_resource path="res://Sprites/Levels/Environment/Fire_Column_Medium_03.png" type="Texture" id=3]
|
[ext_resource path="res://Sprites/Levels/Environment/Fire_Column_Medium_03.png" type="Texture" id=3]
|
||||||
[ext_resource path="res://Sprites/Levels/Environment/Fire_Column_Medium_09.png" type="Texture" id=4]
|
[ext_resource path="res://Sprites/Levels/Environment/Fire_Column_Medium_09.png" type="Texture" id=4]
|
||||||
[ext_resource path="res://Levels/Objects/Door.tscn" type="PackedScene" id=5]
|
[ext_resource path="res://Levels/Objects/Door.tscn" type="PackedScene" id=5]
|
||||||
[ext_resource path="res://Sprites/Levels/Environment/fire_column_medium_10.png" type="Texture" id=6]
|
[ext_resource path="res://Sprites/Levels/Environment/Fire_Column_Medium_10.png" type="Texture" id=6]
|
||||||
[ext_resource path="res://Sprites/Levels/Environment/Fire_Column_Medium_04.png" type="Texture" id=7]
|
[ext_resource path="res://Sprites/Levels/Environment/Fire_Column_Medium_04.png" type="Texture" id=7]
|
||||||
[ext_resource path="res://Sprites/Levels/Environment/Fire_Column_Medium_06.png" type="Texture" id=8]
|
[ext_resource path="res://Sprites/Levels/Environment/Fire_Column_Medium_06.png" type="Texture" id=8]
|
||||||
[ext_resource path="res://Levels/Level 4.gd" type="Script" id=9]
|
[ext_resource path="res://Levels/Level 4.gd" type="Script" id=9]
|
||||||
[ext_resource path="res://Sprites/Levels/Environment/Fire_Column_Medium_01.png" type="Texture" id=10]
|
[ext_resource path="res://Sprites/Levels/Environment/Fire_Column_Medium_01.png" type="Texture" id=10]
|
||||||
[ext_resource path="res://Sprites/Levels/Environment/fire_column_medium_13.png" type="Texture" id=11]
|
[ext_resource path="res://Sprites/Levels/Environment/Fire_Column_Medium_13.png" type="Texture" id=11]
|
||||||
[ext_resource path="res://Sprites/Levels/Environment/fire_column_medium_14.png" type="Texture" id=12]
|
[ext_resource path="res://Sprites/Levels/Environment/Fire_Column_Medium_14.png" type="Texture" id=12]
|
||||||
[ext_resource path="res://Sprites/Levels/Environment/fire_column_medium_11.png" type="Texture" id=13]
|
[ext_resource path="res://Sprites/Levels/Environment/Fire_Column_Medium_11.png" type="Texture" id=13]
|
||||||
[ext_resource path="res://Sprites/Levels/Environment/Fire_Column_Medium_08.png" type="Texture" id=14]
|
[ext_resource path="res://Sprites/Levels/Environment/Fire_Column_Medium_08.png" type="Texture" id=14]
|
||||||
[ext_resource path="res://Resources/Level_4_Tileset.tres" type="TileSet" id=15]
|
[ext_resource path="res://Resources/Level_4_Tileset.tres" type="TileSet" id=15]
|
||||||
[ext_resource path="res://Levels/Interactables/Treasure Chest.tscn" type="PackedScene" id=16]
|
[ext_resource path="res://Levels/Interactables/Treasure Chest.tscn" type="PackedScene" id=16]
|
||||||
@@ -86,21 +86,21 @@ tile_data = PoolIntArray( -2686978, 0, 5, -2686977, 0, 196610, -2752512, 0, 1966
|
|||||||
[node name="Fire3" type="AnimatedSprite" parent="."]
|
[node name="Fire3" type="AnimatedSprite" parent="."]
|
||||||
position = Vector2( -607.628, -210.601 )
|
position = Vector2( -607.628, -210.601 )
|
||||||
frames = SubResource( 1 )
|
frames = SubResource( 1 )
|
||||||
frame = 2
|
frame = 12
|
||||||
playing = true
|
playing = true
|
||||||
offset = Vector2( 679.819, 333.222 )
|
offset = Vector2( 679.819, 333.222 )
|
||||||
|
|
||||||
[node name="Fire2" type="AnimatedSprite" parent="."]
|
[node name="Fire2" type="AnimatedSprite" parent="."]
|
||||||
position = Vector2( -543.25, -212.563 )
|
position = Vector2( -543.25, -212.563 )
|
||||||
frames = SubResource( 1 )
|
frames = SubResource( 1 )
|
||||||
frame = 5
|
frame = 1
|
||||||
playing = true
|
playing = true
|
||||||
offset = Vector2( 679.819, 333.222 )
|
offset = Vector2( 679.819, 333.222 )
|
||||||
|
|
||||||
[node name="Fire1" type="AnimatedSprite" parent="."]
|
[node name="Fire1" type="AnimatedSprite" parent="."]
|
||||||
position = Vector2( -479.806, -214.167 )
|
position = Vector2( -479.806, -214.167 )
|
||||||
frames = SubResource( 1 )
|
frames = SubResource( 1 )
|
||||||
frame = 12
|
frame = 8
|
||||||
playing = true
|
playing = true
|
||||||
offset = Vector2( 679.819, 333.222 )
|
offset = Vector2( 679.819, 333.222 )
|
||||||
|
|
||||||
|
@@ -1,17 +1,16 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
const END_VALUE = 1
|
|
||||||
|
|
||||||
signal unfreeze
|
signal unfreeze
|
||||||
|
|
||||||
var is_active = false
|
const END_VALUE: int = 1
|
||||||
var time_start
|
|
||||||
var duration_ms
|
var is_active: bool = false
|
||||||
var start_value
|
var time_start: int
|
||||||
|
var duration_ms: int
|
||||||
|
var start_value: float
|
||||||
|
|
||||||
|
|
||||||
|
func start(duration: int = 1, strength: float = 0.9):
|
||||||
func start(duration = 1, strength = 0.9):
|
|
||||||
time_start = OS.get_ticks_msec()
|
time_start = OS.get_ticks_msec()
|
||||||
duration_ms = duration * 1000
|
duration_ms = duration * 1000
|
||||||
start_value = 1 - strength
|
start_value = 1 - strength
|
||||||
@@ -19,7 +18,7 @@ func start(duration = 1, strength = 0.9):
|
|||||||
is_active = true
|
is_active = true
|
||||||
|
|
||||||
|
|
||||||
func _process(delta):
|
func _process(_delta: float) -> void:
|
||||||
if is_active:
|
if is_active:
|
||||||
var current_time = OS.get_ticks_msec() - time_start
|
var current_time = OS.get_ticks_msec() - time_start
|
||||||
var value = circl_ease_in(current_time, start_value, END_VALUE, duration_ms)
|
var value = circl_ease_in(current_time, start_value, END_VALUE, duration_ms)
|
||||||
@@ -28,7 +27,9 @@ func _process(delta):
|
|||||||
value = END_VALUE
|
value = END_VALUE
|
||||||
emit_signal('unfreeze')
|
emit_signal('unfreeze')
|
||||||
Engine.time_scale = value
|
Engine.time_scale = value
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
func circl_ease_in(t, b, c, d):
|
func circl_ease_in(t, b, c, d):
|
||||||
t /=d
|
t /= d
|
||||||
return -c * (sqrt(1 - t * t) - 1) + b
|
return -c * (sqrt(1 - t * t) - 1) + b
|
||||||
|
@@ -7,7 +7,7 @@ export var relative_y_tiles: int
|
|||||||
|
|
||||||
func _on_spawn_trap_body_entered(body: Node) -> void:
|
func _on_spawn_trap_body_entered(body: Node) -> void:
|
||||||
if body.is_in_group('player'):
|
if body.is_in_group('player'):
|
||||||
set_deferred('monitoring', false)
|
$Tile.set_deferred('disabled', true)
|
||||||
|
|
||||||
var enemy: KinematicBody2D = load(enemy_path).instance()
|
var enemy: KinematicBody2D = load(enemy_path).instance()
|
||||||
enemy.position.x = position.x + (relative_x_tiles * 16 + 8)
|
enemy.position.x = position.x + (relative_x_tiles * 16 + 8)
|
||||||
|
90
Main.gd
90
Main.gd
@@ -7,73 +7,73 @@ export var world_path: String
|
|||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
randomize()
|
randomize()
|
||||||
var splash_screen: Node = play_splash_screen()
|
var splash_screen: Node = play_splash_screen()
|
||||||
yield(splash_screen, 'complete')
|
yield(splash_screen, 'complete')
|
||||||
splash_screen = null
|
splash_screen = null
|
||||||
|
|
||||||
var main_menu: Node = play_main_menu()
|
var main_menu: Node = play_main_menu()
|
||||||
yield(main_menu, 'complete')
|
yield(main_menu, 'complete')
|
||||||
free_connected_node(main_menu, 'main_menu_option')
|
free_connected_node(main_menu, 'main_menu_option')
|
||||||
main_menu = null
|
main_menu = null
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func play_splash_screen() -> Node:
|
func play_splash_screen() -> Node:
|
||||||
var splash_screen: Node = load(splash_screen_path).instance()
|
var splash_screen: Node = load(splash_screen_path).instance()
|
||||||
if splash_screen.connect('complete', self, 'free_connected_node',
|
if splash_screen.connect('complete', self, 'free_connected_node',
|
||||||
[splash_screen, 'free_connected_node']) != OK:
|
[splash_screen, 'free_connected_node']) != OK:
|
||||||
print('ERROR: Splash Screen "complete" signal already connected.')
|
print('ERROR: Splash Screen "complete" signal already connected.')
|
||||||
|
|
||||||
add_child(splash_screen)
|
add_child(splash_screen)
|
||||||
return splash_screen
|
return splash_screen
|
||||||
|
|
||||||
|
|
||||||
func play_main_menu() -> Node:
|
func play_main_menu() -> Node:
|
||||||
var main_menu: Node = load(main_menu_path).instance()
|
var main_menu: Node = load(main_menu_path).instance()
|
||||||
if main_menu.connect('complete', self, 'main_menu_option') != OK:
|
if main_menu.connect('complete', self, 'main_menu_option') != OK:
|
||||||
print('ERROR: Main Menu "complete" signal already connected.')
|
print('ERROR: Main Menu "complete" signal already connected.')
|
||||||
|
|
||||||
add_child(main_menu)
|
add_child(main_menu)
|
||||||
return main_menu
|
return main_menu
|
||||||
|
|
||||||
|
|
||||||
func main_menu_option(option: String) -> void:
|
func main_menu_option(option: String) -> void:
|
||||||
if option == 'new game':
|
if option == 'new game':
|
||||||
var level_select_menu: Node = play_level_select_menu()
|
var level_select_menu: Node = play_level_select_menu()
|
||||||
yield(level_select_menu, 'complete')
|
yield(level_select_menu, 'complete')
|
||||||
free_connected_node(level_select_menu, 'level_select_menu_option')
|
free_connected_node(level_select_menu, 'level_select_menu_option')
|
||||||
level_select_menu = null
|
level_select_menu = null
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func play_level_select_menu() -> Node:
|
func play_level_select_menu() -> Node:
|
||||||
var level_select_menu: Node = load(level_select_menu_path).instance()
|
var level_select_menu: Node = load(level_select_menu_path).instance()
|
||||||
if level_select_menu.connect('complete', self, 'level_select_menu_option') != OK:
|
if level_select_menu.connect('complete', self, 'level_select_menu_option') != OK:
|
||||||
print('ERROR: Level Select Menu "complete" signal already connected.')
|
print('ERROR: Level Select Menu "complete" signal already connected.')
|
||||||
|
|
||||||
add_child(level_select_menu)
|
add_child(level_select_menu)
|
||||||
return level_select_menu
|
return level_select_menu
|
||||||
|
|
||||||
|
|
||||||
func level_select_menu_option(option: String) -> void:
|
func level_select_menu_option(option: String) -> void:
|
||||||
var level: String = 'res://Levels/'
|
var level: String = 'res://Levels/'
|
||||||
if option == 'H':
|
if option == 'H':
|
||||||
level += 'Hub World.tscn'
|
level += 'Hub World.tscn'
|
||||||
else:
|
else:
|
||||||
level += 'Level ' + option + '.tscn'
|
level += 'Level ' + option + '.tscn'
|
||||||
|
|
||||||
new_game(level)
|
new_game(level)
|
||||||
return
|
return
|
||||||
|
|
||||||
func free_connected_node(node: Node, connected_function: String) -> void:
|
func free_connected_node(node: Node, connected_function: String) -> void:
|
||||||
node.disconnect('complete', self, connected_function)
|
node.disconnect('complete', self, connected_function)
|
||||||
node.queue_free()
|
node.queue_free()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func new_game(level: String) -> void:
|
func new_game(level: String) -> void:
|
||||||
if get_tree().change_scene(level) != OK:
|
if get_tree().change_scene(level) != OK:
|
||||||
print('ERROR: Main failed to change scene to Level.')
|
print('ERROR: Main failed to change scene to Level.')
|
||||||
queue_free()
|
queue_free()
|
||||||
return
|
return
|
||||||
|
196
Player/Player.gd
196
Player/Player.gd
@@ -1,10 +1,10 @@
|
|||||||
extends KinematicBody2D
|
extends KinematicBody2D
|
||||||
|
|
||||||
|
signal frozen
|
||||||
|
|
||||||
export var ACCELERATION: int = 1000
|
export var ACCELERATION: int = 1000
|
||||||
export var MAX_SPEED: int = 120
|
export var MAX_SPEED: int = 120
|
||||||
export var FRICTION: int = 1000
|
export var FRICTION: int = 1000
|
||||||
signal frozen
|
|
||||||
|
|
||||||
|
|
||||||
const HEALTH_SLICES: Array = [0, 18, 35, 50, 65, 82, 100]
|
const HEALTH_SLICES: Array = [0, 18, 35, 50, 65, 82, 100]
|
||||||
var health_index: int = 6
|
var health_index: int = 6
|
||||||
@@ -14,157 +14,135 @@ var velocity: Vector2 = Vector2.ZERO
|
|||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
set_weapon_position(Vector2(1, 0))
|
set_weapon_position(Vector2(1, 0))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
var input_vector: Vector2 = Vector2.ZERO
|
var input_vector: Vector2 = Vector2.ZERO
|
||||||
|
|
||||||
input_vector.x = Input.get_action_strength('player_right') \
|
input_vector.x = Input.get_action_strength('player_right') \
|
||||||
- Input.get_action_strength('player_left')
|
- Input.get_action_strength('player_left')
|
||||||
input_vector.y = Input.get_action_strength('player_down') \
|
input_vector.y = Input.get_action_strength('player_down') \
|
||||||
- Input.get_action_strength('player_up')
|
- Input.get_action_strength('player_up')
|
||||||
input_vector = input_vector.normalized()
|
input_vector = input_vector.normalized()
|
||||||
|
|
||||||
if input_vector != Vector2.ZERO:
|
if input_vector != Vector2.ZERO:
|
||||||
$AnimationTree.set('parameters/Idle/blend_position', input_vector)
|
$AnimationTree.set('parameters/Idle/blend_position', input_vector)
|
||||||
velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
|
velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
|
||||||
set_weapon_position(input_vector)
|
set_weapon_position(input_vector)
|
||||||
else:
|
else:
|
||||||
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
|
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
|
||||||
|
|
||||||
velocity = move_and_slide(velocity)
|
velocity = move_and_slide(velocity)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func load_hud(node: CanvasLayer) -> void:
|
func load_hud(node: CanvasLayer) -> void:
|
||||||
hud = node
|
hud = node
|
||||||
if hud.connect('add_currency', self, 'add_currency') != OK:
|
if hud.connect('add_currency', self, 'add_currency') != OK:
|
||||||
print('ERROR: HUD "add_currency" signal already connected.')
|
print('ERROR: HUD "add_currency" signal already connected.')
|
||||||
|
|
||||||
hud.update_health(HEALTH_SLICES[health_index])
|
hud.update_health(HEALTH_SLICES[health_index])
|
||||||
hud.update_currency($Inventory.get_currency())
|
hud.update_currency($Inventory.get_currency())
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func set_weapon_position(pos: Vector2) -> void:
|
func set_weapon_position(pos: Vector2) -> void:
|
||||||
# facing left
|
# Facing left
|
||||||
if pos[0] < 0:
|
if pos[0] < 0:
|
||||||
$Sword.rotation_degrees = -90
|
$Sword.rotation_degrees = -90
|
||||||
$Javelin.rotation_degrees = -90
|
$Javelin.rotation_degrees = -90
|
||||||
|
|
||||||
# facing right
|
# Facing right
|
||||||
elif pos[0] > 0:
|
elif pos[0] > 0:
|
||||||
$Sword.rotation_degrees = 90
|
$Sword.rotation_degrees = 90
|
||||||
$Javelin.rotation_degrees = 90
|
$Javelin.rotation_degrees = 90
|
||||||
|
|
||||||
# facing up
|
# Facing up
|
||||||
elif pos[1] < 0:
|
elif pos[1] < 0:
|
||||||
$Sword.rotation_degrees = 0
|
$Sword.rotation_degrees = 0
|
||||||
$Javelin.rotation_degrees = 0
|
$Javelin.rotation_degrees = 0
|
||||||
|
|
||||||
# facing down
|
# Facing down
|
||||||
elif pos[1] > 0:
|
elif pos[1] > 0:
|
||||||
$Sword.rotation_degrees = 180
|
$Sword.rotation_degrees = 180
|
||||||
$Javelin.rotation_degrees = 180
|
$Javelin.rotation_degrees = 180
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func add_currency(amount: int) -> void:
|
func add_currency(amount: int) -> void:
|
||||||
$Inventory.add_currency(amount)
|
$Inventory.add_currency(amount)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func has_item(item: String) -> bool:
|
func has_item(item: String) -> bool:
|
||||||
return $Inventory.contains(item)
|
return $Inventory.contains(item)
|
||||||
|
|
||||||
|
|
||||||
func add_item(item: String) -> void:
|
func add_item(item: String) -> void:
|
||||||
$Inventory.add(item)
|
$Inventory.add(item)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func remove_item(item: String) -> void:
|
func remove_item(item: String) -> void:
|
||||||
$Inventory.remove(item)
|
$Inventory.remove(item)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func _on_Inventory_update_currency(amount: int) -> void:
|
func _on_Inventory_update_currency(amount: int) -> void:
|
||||||
hud.update_currency(amount)
|
hud.update_currency(amount)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
func _on_hitbox_area_entered(area: Area2D) -> void:
|
func _on_hitbox_area_entered(area: Area2D) -> void:
|
||||||
var hit: int = 0
|
var hit: int = 0
|
||||||
|
|
||||||
if area.is_in_group('enemy_hitbox_1') or area.is_in_group('enemy_projectile_1'):
|
if area.is_in_group('enemy_hitbox_1') or area.is_in_group('enemy_projectile_1'):
|
||||||
hit = 1
|
hit = 1
|
||||||
elif area.is_in_group('enemy_hitbox_2') or area.is_in_group('enemy_projectile_2'):
|
elif area.is_in_group('enemy_hitbox_2') or area.is_in_group('enemy_projectile_2'):
|
||||||
hit = 2
|
hit = 2
|
||||||
elif area.is_in_group('enemy_hitbox_3') or area.is_in_group('enemy_projectile_3'):
|
elif area.is_in_group('enemy_hitbox_3') or area.is_in_group('enemy_projectile_3'):
|
||||||
hit = 3
|
hit = 3
|
||||||
elif area.is_in_group('freeze'):
|
elif area.is_in_group('freeze'):
|
||||||
emit_signal('frozen')
|
emit_signal('frozen')
|
||||||
modulate = Color(0,.5,1)
|
$Sprite.self_modulate = Color(0, 0.5, 1)
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
if health_index != 0:
|
if health_index != 0:
|
||||||
health_index -= hit
|
health_index -= hit
|
||||||
if health_index < 0:
|
if health_index < 0:
|
||||||
health_index = 0
|
health_index = 0
|
||||||
|
|
||||||
hud.update_health(HEALTH_SLICES[health_index])
|
|
||||||
else:
|
|
||||||
get_tree().change_scene('res://Levels/Hub World.tscn')
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
|
hud.update_health(HEALTH_SLICES[health_index])
|
||||||
|
else:
|
||||||
|
get_tree().change_scene('res://Levels/Hub World.tscn')
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if event.is_action_pressed('player_attack'):
|
if event.is_action_pressed('player_attack'):
|
||||||
if hud.weapon == 'sword':
|
if hud.weapon == 'sword':
|
||||||
$'Sword/Sword Animation'.play('swing')
|
$'Sword/Sword Animation'.play('swing')
|
||||||
elif hud.weapon == 'javelin':
|
elif hud.weapon == 'javelin':
|
||||||
$'Javelin/Javelin Animation'.play('swing')
|
$'Javelin/Javelin Animation'.play('swing')
|
||||||
|
|
||||||
if event.is_action_pressed('screenshot'):
|
elif event.is_action_pressed('screenshot'):
|
||||||
var img: Image = get_viewport().get_texture().get_data()
|
var img: Image = get_viewport().get_texture().get_data()
|
||||||
yield(get_tree(), 'idle_frame')
|
yield(get_tree(), 'idle_frame')
|
||||||
yield(get_tree(), 'idle_frame')
|
yield(get_tree(), 'idle_frame')
|
||||||
|
|
||||||
img.flip_y()
|
img.flip_y()
|
||||||
|
|
||||||
var time: Dictionary = OS.get_datetime_from_unix_time(OS.get_unix_time())
|
var time: Dictionary = OS.get_datetime_from_unix_time(OS.get_unix_time())
|
||||||
var time_msecs: int = OS.get_system_time_msecs()
|
var time_msecs: int = OS.get_system_time_msecs()
|
||||||
|
|
||||||
|
if img.save_png('user://Screenshot_%d%d%d_%d.png' % [time.year, time.month, time.day, time_msecs]) != OK:
|
||||||
if img.save_png('user://Screenshot_%d%d%d_%d.png' % [time.year, time.month, time.day, time_msecs]) != OK:
|
print('ERROR: Failed saving screenshot.')
|
||||||
print('ERROR: Failed saving screenshot.')
|
return
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
func _on_Hitbox_area_entered(area: Area2D) -> void:
|
|
||||||
print(area.name)
|
|
||||||
|
|
||||||
if area.name == 'detection':
|
|
||||||
return
|
|
||||||
|
|
||||||
if 'freeze' in area.get_parent().get_groups():
|
|
||||||
emit_signal('frozen')
|
|
||||||
return
|
|
||||||
|
|
||||||
if 'enemies' in area.get_parent().get_groups() or area.name != 'detection' or 'damage' in area.get_groups():
|
|
||||||
if health_index != 0:
|
|
||||||
health_index -= 1
|
|
||||||
hud.update_health(HEALTH_SLICES[health_index])
|
|
||||||
else:
|
|
||||||
get_tree().change_scene('res://Levels/Hub World.tscn')
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
func _on_SlowTime_unfreeze() -> void:
|
func _on_SlowTime_unfreeze() -> void:
|
||||||
modulate = Color(1,1,1)
|
$Sprite.self_modulate = Color(1, 1, 1)
|
||||||
|
return
|
||||||
|
@@ -10,9 +10,9 @@
|
|||||||
|
|
||||||
[sub_resource type="SpriteFrames" id=1]
|
[sub_resource type="SpriteFrames" id=1]
|
||||||
animations = [ {
|
animations = [ {
|
||||||
"frames": [ ExtResource( 2 ) ],
|
"frames": [ ExtResource( 4 ) ],
|
||||||
"loop": false,
|
"loop": false,
|
||||||
"name": "look_left",
|
"name": "look_up",
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ ExtResource( 2 ) ],
|
"frames": [ ExtResource( 2 ) ],
|
||||||
@@ -20,15 +20,15 @@ animations = [ {
|
|||||||
"name": "look_right",
|
"name": "look_right",
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ ExtResource( 4 ) ],
|
|
||||||
"loop": false,
|
|
||||||
"name": "look_up",
|
|
||||||
"speed": 5.0
|
|
||||||
}, {
|
|
||||||
"frames": [ ExtResource( 3 ) ],
|
"frames": [ ExtResource( 3 ) ],
|
||||||
"loop": false,
|
"loop": false,
|
||||||
"name": "look_down",
|
"name": "look_down",
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [ ExtResource( 2 ) ],
|
||||||
|
"loop": false,
|
||||||
|
"name": "look_left",
|
||||||
|
"speed": 5.0
|
||||||
} ]
|
} ]
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape2D" id=2]
|
[sub_resource type="CapsuleShape2D" id=2]
|
||||||
@@ -182,9 +182,7 @@ graph_offset = Vector2( -3591.37, -302.6 )
|
|||||||
|
|
||||||
[sub_resource type="AnimationNodeStateMachinePlayback" id=14]
|
[sub_resource type="AnimationNodeStateMachinePlayback" id=14]
|
||||||
|
|
||||||
[node name="Player" type="KinematicBody2D" groups=[
|
[node name="Player" type="KinematicBody2D" groups=["player"]]
|
||||||
"player",
|
|
||||||
]]
|
|
||||||
collision_layer = 2
|
collision_layer = 2
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
@@ -200,12 +198,10 @@ visible = false
|
|||||||
rotation = 1.5708
|
rotation = 1.5708
|
||||||
shape = SubResource( 2 )
|
shape = SubResource( 2 )
|
||||||
|
|
||||||
[node name="Hitbox" type="Area2D" parent="." groups=[
|
[node name="Hitbox" type="Area2D" parent="." groups=["player_hitbox"]]
|
||||||
"player_hitbox",
|
|
||||||
]]
|
|
||||||
input_pickable = false
|
|
||||||
collision_layer = 2
|
collision_layer = 2
|
||||||
collision_mask = 4
|
collision_mask = 4
|
||||||
|
input_pickable = false
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"]
|
||||||
visible = false
|
visible = false
|
||||||
|
@@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="StreamTexture"
|
type="StreamTexture"
|
||||||
path="res://.import/resources_basic.png-128bab182945611297ec1bda48bed0c4.stex"
|
path="res://.import/Resources_Basic.png-ace2281282b93b7ae48cda9c52d377ad.stex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://Sprites/Assets/resources_basic.png"
|
source_file="res://Sprites/Assets/Resources_Basic.png"
|
||||||
dest_files=[ "res://.import/resources_basic.png-128bab182945611297ec1bda48bed0c4.stex" ]
|
dest_files=[ "res://.import/Resources_Basic.png-ace2281282b93b7ae48cda9c52d377ad.stex" ]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
|
@@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="StreamTexture"
|
type="StreamTexture"
|
||||||
path="res://.import/fire_column_medium_10.png-9ae78a0f5ef8531c3b56d09574ecd317.stex"
|
path="res://.import/Fire_Column_Medium_10.png-505d756e8645c45b6fb339fbb6f8add5.stex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://Sprites/Levels/Environment/fire_column_medium_10.png"
|
source_file="res://Sprites/Levels/Environment/Fire_Column_Medium_10.png"
|
||||||
dest_files=[ "res://.import/fire_column_medium_10.png-9ae78a0f5ef8531c3b56d09574ecd317.stex" ]
|
dest_files=[ "res://.import/Fire_Column_Medium_10.png-505d756e8645c45b6fb339fbb6f8add5.stex" ]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
|
@@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="StreamTexture"
|
type="StreamTexture"
|
||||||
path="res://.import/fire_column_medium_11.png-f6c2ac8f20428aebca0febd0f65a5806.stex"
|
path="res://.import/Fire_Column_Medium_11.png-cb278dde504fd6f8f415eda7091cfa9a.stex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://Sprites/Levels/Environment/fire_column_medium_11.png"
|
source_file="res://Sprites/Levels/Environment/Fire_Column_Medium_11.png"
|
||||||
dest_files=[ "res://.import/fire_column_medium_11.png-f6c2ac8f20428aebca0febd0f65a5806.stex" ]
|
dest_files=[ "res://.import/Fire_Column_Medium_11.png-cb278dde504fd6f8f415eda7091cfa9a.stex" ]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
|
@@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="StreamTexture"
|
type="StreamTexture"
|
||||||
path="res://.import/fire_column_medium_12.png-25bc0d063fd42a44b6e9e423e3bf2656.stex"
|
path="res://.import/Fire_Column_Medium_12.png-1e7c2da6903b243f73d7ed4b50d90f8a.stex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://Sprites/Levels/Environment/fire_column_medium_12.png"
|
source_file="res://Sprites/Levels/Environment/Fire_Column_Medium_12.png"
|
||||||
dest_files=[ "res://.import/fire_column_medium_12.png-25bc0d063fd42a44b6e9e423e3bf2656.stex" ]
|
dest_files=[ "res://.import/Fire_Column_Medium_12.png-1e7c2da6903b243f73d7ed4b50d90f8a.stex" ]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
|
@@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="StreamTexture"
|
type="StreamTexture"
|
||||||
path="res://.import/fire_column_medium_13.png-6f8490642f9a7a3884a31ae3975deb08.stex"
|
path="res://.import/Fire_Column_Medium_13.png-a147b7694df1cdf05d373697c6a4ede3.stex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://Sprites/Levels/Environment/fire_column_medium_13.png"
|
source_file="res://Sprites/Levels/Environment/Fire_Column_Medium_13.png"
|
||||||
dest_files=[ "res://.import/fire_column_medium_13.png-6f8490642f9a7a3884a31ae3975deb08.stex" ]
|
dest_files=[ "res://.import/Fire_Column_Medium_13.png-a147b7694df1cdf05d373697c6a4ede3.stex" ]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
|
@@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="StreamTexture"
|
type="StreamTexture"
|
||||||
path="res://.import/fire_column_medium_14.png-81452b14764f0dd97e4008c5f9448c38.stex"
|
path="res://.import/Fire_Column_Medium_14.png-205dacf8251c335e3becb65b0df84941.stex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://Sprites/Levels/Environment/fire_column_medium_14.png"
|
source_file="res://Sprites/Levels/Environment/Fire_Column_Medium_14.png"
|
||||||
dest_files=[ "res://.import/fire_column_medium_14.png-81452b14764f0dd97e4008c5f9448c38.stex" ]
|
dest_files=[ "res://.import/Fire_Column_Medium_14.png-205dacf8251c335e3becb65b0df84941.stex" ]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user