Code cleanup and minor fixes to Level 3
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[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]
|
||||
|
||||
[sub_resource type="CircleShape2D" id=1]
|
@@ -8,7 +8,7 @@ extends Node2D
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
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.
|
||||
@@ -17,8 +17,8 @@ func _ready() -> 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:
|
||||
$GemSprite.visible = true
|
||||
$GemSprite.visible = true
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[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]
|
||||
|
||||
[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.
|
||||
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.
|
||||
@@ -22,12 +22,12 @@ func _ready() -> void:
|
||||
|
||||
|
||||
func _on_Player_Detector_area_entered(area: Area2D) -> void:
|
||||
if area.get_parent().name == 'Player':
|
||||
if is_opened == false:
|
||||
$chestClosed.visible = false
|
||||
$chestOpened.visible = true
|
||||
$Gem.visible = true
|
||||
$Gem/AnimationPlayer.play('rise')
|
||||
is_opened = true
|
||||
has_gem = false
|
||||
emit_signal('gem_collected')
|
||||
if area.get_parent().name == 'Player':
|
||||
if is_opened == false:
|
||||
$chestClosed.visible = false
|
||||
$chestOpened.visible = true
|
||||
$Gem.visible = true
|
||||
$Gem/AnimationPlayer.play('rise')
|
||||
is_opened = true
|
||||
has_gem = false
|
||||
emit_signal('gem_collected')
|
||||
|
@@ -1,52 +1,56 @@
|
||||
extends Node2D
|
||||
|
||||
onready var coin = preload("res://Levels/Interactives/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
|
||||
|
||||
onready var coin = preload('res://Levels/Interactables/Coin.tscn')
|
||||
|
||||
var screensize
|
||||
var score = 0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
$YSort/Player.load_hud($HUD)
|
||||
screensize = get_viewport_rect().size
|
||||
spawn_coins(8)
|
||||
return
|
||||
$YSort/Player.load_hud($HUD)
|
||||
screensize = get_viewport_rect().size
|
||||
spawn_coins(8)
|
||||
return
|
||||
|
||||
|
||||
func spawn_coins(num):
|
||||
for i in range(num):
|
||||
var g = coin.instance()
|
||||
$'coin_container'.add_child(g)
|
||||
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.position = Vector2(rand_range(0, screensize.x-40), rand_range(0, screensize.y-40))
|
||||
func spawn_coins(num: int) -> void:
|
||||
for _i in range(num):
|
||||
var g: Node = coin.instance()
|
||||
$'coin_container'.add_child(g)
|
||||
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.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():
|
||||
get_tree().change_scene('res://Levels/Hub World.tscn')
|
||||
func _on_coin_grabbed() -> void:
|
||||
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:
|
||||
$YSort/Door/doorClosed.visible = false
|
||||
$YSort/Door/doorOpened.visible = true
|
||||
$YSort/DoorCollision.layers = 5
|
||||
|
||||
$YSort/Door/doorClosed.visible = false
|
||||
$YSort/Door/doorOpened.visible = true
|
||||
$YSort/DoorCollision.layers = 5
|
||||
return
|
||||
|
||||
|
||||
func _on_DoorDetector_body_entered(body: Node) -> void:
|
||||
if body.get_parent().name == 'Player':
|
||||
print('WIN WIN WIN')
|
||||
get_tree().change_scene('res://Levels/Hub World.tscn')
|
||||
if body.is_in_group('player'):
|
||||
print('WIN WIN WIN')
|
||||
get_tree().change_scene('res://Levels/Hub World.tscn')
|
||||
return
|
||||
|
||||
|
||||
func _on_DoorDetector_area_entered(area: Area2D) -> void:
|
||||
if area.get_parent().name == 'Player':
|
||||
print('WIN WIN WIN')
|
||||
get_tree().change_scene('res://Levels/Hub World.tscn') # Replace with function body.
|
||||
if area.get_parent().name == 'Player':
|
||||
print('WIN WIN WIN')
|
||||
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 )
|
||||
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="."]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
@@ -184,18 +189,6 @@ __meta__ = {
|
||||
"_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="."]
|
||||
margin_left = 0.28064
|
||||
margin_top = -12.9083
|
||||
@@ -216,10 +209,17 @@ __meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Effects" type="Node" parent="."]
|
||||
[node name="HUD" parent="." instance=ExtResource( 9 )]
|
||||
|
||||
[node name="SlowTime" type="Node" parent="Effects"]
|
||||
script = ExtResource( 16 )
|
||||
[node name="Countdown Timer" parent="HUD" instance=ExtResource( 12 )]
|
||||
|
||||
[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="ice_key_collected" from="YSort/TreasureChest" to="." method="_on_TreasureChest_ice_key_collected"]
|
||||
|
@@ -3,22 +3,22 @@ extends Node2D
|
||||
var gems: int = 4
|
||||
|
||||
func _ready() -> void:
|
||||
#$YSort/Player.position = get_viewport_rect().size / 2
|
||||
$YSort/Player.load_hud($HUD)
|
||||
return
|
||||
#$YSort/Player.position = get_viewport_rect().size / 2
|
||||
$YSort/Player.load_hud($HUD)
|
||||
return
|
||||
|
||||
|
||||
func _on_TreasureChest_gem_collected() -> void:
|
||||
gems -= 1
|
||||
gems -= 1
|
||||
|
||||
if gems == 0:
|
||||
$YSort/Items/Door/doorClosed.visible = false
|
||||
$YSort/Items/Door/doorOpened.visible = true
|
||||
$DoorCollision.layers = 5
|
||||
if gems == 0:
|
||||
$YSort/Items/Door/doorClosed.visible = false
|
||||
$YSort/Items/Door/doorOpened.visible = true
|
||||
$DoorCollision.layers = 5
|
||||
|
||||
|
||||
|
||||
func _on_NextArea_area_entered(area: Area2D) -> void:
|
||||
if area.get_parent().name == 'Player':
|
||||
$YSort/Player.position.x = 195
|
||||
$YSort/Player.position.y = -335
|
||||
if area.get_parent().name == 'Player':
|
||||
$YSort/Player.position.x = 195
|
||||
$YSort/Player.position.y = -335
|
||||
|
@@ -1,18 +1,18 @@
|
||||
[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://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://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_06.png" type="Texture" id=8]
|
||||
[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_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_11.png" type="Texture" id=13]
|
||||
[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_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://Resources/Level_4_Tileset.tres" type="TileSet" id=15]
|
||||
[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="."]
|
||||
position = Vector2( -607.628, -210.601 )
|
||||
frames = SubResource( 1 )
|
||||
frame = 2
|
||||
frame = 12
|
||||
playing = true
|
||||
offset = Vector2( 679.819, 333.222 )
|
||||
|
||||
[node name="Fire2" type="AnimatedSprite" parent="."]
|
||||
position = Vector2( -543.25, -212.563 )
|
||||
frames = SubResource( 1 )
|
||||
frame = 5
|
||||
frame = 1
|
||||
playing = true
|
||||
offset = Vector2( 679.819, 333.222 )
|
||||
|
||||
[node name="Fire1" type="AnimatedSprite" parent="."]
|
||||
position = Vector2( -479.806, -214.167 )
|
||||
frames = SubResource( 1 )
|
||||
frame = 12
|
||||
frame = 8
|
||||
playing = true
|
||||
offset = Vector2( 679.819, 333.222 )
|
||||
|
||||
|
@@ -1,17 +1,16 @@
|
||||
extends Node
|
||||
|
||||
const END_VALUE = 1
|
||||
|
||||
signal unfreeze
|
||||
|
||||
var is_active = false
|
||||
var time_start
|
||||
var duration_ms
|
||||
var start_value
|
||||
const END_VALUE: int = 1
|
||||
|
||||
var is_active: bool = false
|
||||
var time_start: int
|
||||
var duration_ms: int
|
||||
var start_value: float
|
||||
|
||||
|
||||
|
||||
func start(duration = 1, strength = 0.9):
|
||||
func start(duration: int = 1, strength: float = 0.9):
|
||||
time_start = OS.get_ticks_msec()
|
||||
duration_ms = duration * 1000
|
||||
start_value = 1 - strength
|
||||
@@ -19,7 +18,7 @@ func start(duration = 1, strength = 0.9):
|
||||
is_active = true
|
||||
|
||||
|
||||
func _process(delta):
|
||||
func _process(_delta: float) -> void:
|
||||
if is_active:
|
||||
var current_time = OS.get_ticks_msec() - time_start
|
||||
var value = circl_ease_in(current_time, start_value, END_VALUE, duration_ms)
|
||||
@@ -28,7 +27,9 @@ func _process(delta):
|
||||
value = END_VALUE
|
||||
emit_signal('unfreeze')
|
||||
Engine.time_scale = value
|
||||
|
||||
return
|
||||
|
||||
|
||||
func circl_ease_in(t, b, c, d):
|
||||
t /=d
|
||||
t /= d
|
||||
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:
|
||||
if body.is_in_group('player'):
|
||||
set_deferred('monitoring', false)
|
||||
$Tile.set_deferred('disabled', true)
|
||||
|
||||
var enemy: KinematicBody2D = load(enemy_path).instance()
|
||||
enemy.position.x = position.x + (relative_x_tiles * 16 + 8)
|
||||
|
Reference in New Issue
Block a user