End sequence
parent
23b26d0f35
commit
6e20d982c3
|
@ -4,6 +4,7 @@ extends CharacterBody2D
|
||||||
@onready var death_sfx = preload("res://scenes/assets/jingles/fail.wav")
|
@onready var death_sfx = preload("res://scenes/assets/jingles/fail.wav")
|
||||||
@onready var raycast: RayCast2D = $RayCast2D
|
@onready var raycast: RayCast2D = $RayCast2D
|
||||||
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
|
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
|
||||||
|
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||||
@onready var map: MainLevel = get_tree().root.get_child(0).get_node("TileMap")
|
@onready var map: MainLevel = get_tree().root.get_child(0).get_node("TileMap")
|
||||||
@onready var tile_map: TileMapLayer = get_tree().root.get_child(0).get_node("TileMap/TileMapLayer")
|
@onready var tile_map: TileMapLayer = get_tree().root.get_child(0).get_node("TileMap/TileMapLayer")
|
||||||
@onready var camera: Camera2D = $AnimatedSprite2D/Camera2D
|
@onready var camera: Camera2D = $AnimatedSprite2D/Camera2D
|
||||||
|
@ -26,6 +27,8 @@ var rng := RandomNumberGenerator.new()
|
||||||
var camera_shake: float = 0.0
|
var camera_shake: float = 0.0
|
||||||
var camera_shake_fade: float = 0.0
|
var camera_shake_fade: float = 0.0
|
||||||
var attack_frame := 0
|
var attack_frame := 0
|
||||||
|
var lock_for_end := false
|
||||||
|
var end_tick := 0
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
_respawn()
|
_respawn()
|
||||||
|
@ -59,6 +62,7 @@ func _respawn():
|
||||||
|
|
||||||
func _try_get_input():
|
func _try_get_input():
|
||||||
should_move = false
|
should_move = false
|
||||||
|
if not lock_for_end:
|
||||||
if Input.is_action_pressed("move_up"):
|
if Input.is_action_pressed("move_up"):
|
||||||
input_dir = Vector2.UP
|
input_dir = Vector2.UP
|
||||||
should_move = true
|
should_move = true
|
||||||
|
@ -71,6 +75,13 @@ func _try_get_input():
|
||||||
elif Input.is_action_pressed("move_left"):
|
elif Input.is_action_pressed("move_left"):
|
||||||
input_dir = Vector2.LEFT
|
input_dir = Vector2.LEFT
|
||||||
should_move = true
|
should_move = true
|
||||||
|
else:
|
||||||
|
input_dir = Vector2.UP
|
||||||
|
should_move = true
|
||||||
|
end_tick += 1
|
||||||
|
|
||||||
|
if end_tick > 250:
|
||||||
|
animation_player.play(&"end")
|
||||||
|
|
||||||
_change_sprite()
|
_change_sprite()
|
||||||
|
|
||||||
|
@ -141,6 +152,9 @@ func apply_camera_shake(strength: float = 10.0, fade: float = 5.0):
|
||||||
camera_shake_fade = fade
|
camera_shake_fade = fade
|
||||||
|
|
||||||
func _try_interact():
|
func _try_interact():
|
||||||
|
if lock_for_end:
|
||||||
|
return
|
||||||
|
|
||||||
raycast.target_position = input_dir * 8
|
raycast.target_position = input_dir * 8
|
||||||
raycast.force_raycast_update()
|
raycast.force_raycast_update()
|
||||||
|
|
||||||
|
@ -163,3 +177,7 @@ func _shake_camera(delta):
|
||||||
func _on_area_entered(area: Area2D):
|
func _on_area_entered(area: Area2D):
|
||||||
if area.is_in_group("death"):
|
if area.is_in_group("death"):
|
||||||
die()
|
die()
|
||||||
|
|
||||||
|
func _on_animation_player_animation_finished(anim_name: String):
|
||||||
|
if anim_name == &"end":
|
||||||
|
get_tree().quit()
|
||||||
|
|
|
@ -98,7 +98,7 @@ animations = [{
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
"texture": SubResource("AtlasTexture_okcjq")
|
"texture": SubResource("AtlasTexture_okcjq")
|
||||||
}],
|
}],
|
||||||
"loop": false,
|
"loop": true,
|
||||||
"name": &"move_down",
|
"name": &"move_down",
|
||||||
"speed": 10.0
|
"speed": 10.0
|
||||||
}, {
|
}, {
|
||||||
|
@ -115,7 +115,7 @@ animations = [{
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
"texture": SubResource("AtlasTexture_580lu")
|
"texture": SubResource("AtlasTexture_580lu")
|
||||||
}],
|
}],
|
||||||
"loop": false,
|
"loop": true,
|
||||||
"name": &"move_right",
|
"name": &"move_right",
|
||||||
"speed": 10.0
|
"speed": 10.0
|
||||||
}, {
|
}, {
|
||||||
|
@ -132,7 +132,7 @@ animations = [{
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
"texture": SubResource("AtlasTexture_xuq2e")
|
"texture": SubResource("AtlasTexture_xuq2e")
|
||||||
}],
|
}],
|
||||||
"loop": false,
|
"loop": true,
|
||||||
"name": &"move_up",
|
"name": &"move_up",
|
||||||
"speed": 10.0
|
"speed": 10.0
|
||||||
}, {
|
}, {
|
||||||
|
@ -188,16 +188,39 @@ animations = [{
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_ve5nf"]
|
[sub_resource type="Animation" id="Animation_ve5nf"]
|
||||||
resource_name = "RESET"
|
resource_name = "RESET"
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("CanvasModulate:color")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Color(1, 1, 1, 1)]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_ab576"]
|
[sub_resource type="Animation" id="Animation_jmi7y"]
|
||||||
resource_name = "move"
|
resource_name = "fade_out"
|
||||||
length = 0.5
|
length = 10.0
|
||||||
loop_mode = 1
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("CanvasModulate:color")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 10),
|
||||||
|
"transitions": PackedFloat32Array(1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Color(1, 1, 1, 1), Color(0, 0, 0, 1)]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_dx4e7"]
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_dx4e7"]
|
||||||
_data = {
|
_data = {
|
||||||
"RESET": SubResource("Animation_ve5nf"),
|
"RESET": SubResource("Animation_ve5nf"),
|
||||||
"move": SubResource("Animation_ab576")
|
"end": SubResource("Animation_jmi7y")
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_l7fhd"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_l7fhd"]
|
||||||
|
@ -213,7 +236,7 @@ script = ExtResource("1_jrd75")
|
||||||
|
|
||||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||||
sprite_frames = SubResource("SpriteFrames_icodh")
|
sprite_frames = SubResource("SpriteFrames_icodh")
|
||||||
animation = &"move_down"
|
animation = &"move_right"
|
||||||
|
|
||||||
[node name="Camera2D" type="Camera2D" parent="AnimatedSprite2D"]
|
[node name="Camera2D" type="Camera2D" parent="AnimatedSprite2D"]
|
||||||
|
|
||||||
|
@ -239,4 +262,7 @@ shape = SubResource("RectangleShape2D_x0fgp")
|
||||||
|
|
||||||
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
|
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
|
||||||
|
|
||||||
|
[node name="CanvasModulate" type="CanvasModulate" parent="."]
|
||||||
|
|
||||||
|
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_animation_player_animation_finished"]
|
||||||
[connection signal="area_entered" from="Area2D" to="." method="_on_area_entered"]
|
[connection signal="area_entered" from="Area2D" to="." method="_on_area_entered"]
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
extends Area2D
|
||||||
|
|
||||||
|
func _on_body_entered(body):
|
||||||
|
if body is Player:
|
||||||
|
(body as Player).lock_for_end = true
|
File diff suppressed because one or more lines are too long
Reference in New Issue