parent
426646f4e0
commit
a380551643
@ -0,0 +1,11 @@ |
|||||||
|
extends Area2D |
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time. |
||||||
|
func _ready(): |
||||||
|
body_entered.connect(on_body_entered) |
||||||
|
|
||||||
|
func on_body_entered(body): |
||||||
|
if body.is_in_group('player'): |
||||||
|
g_game_state.checkpoint(body.global_position) |
||||||
|
queue_free() |
||||||
@ -0,0 +1,6 @@ |
|||||||
|
[gd_scene load_steps=2 format=3 uid="uid://cjuqvtp3lhsuc"] |
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://nodes/triggers/checkpoint.gd" id="1_v47vq"] |
||||||
|
|
||||||
|
[node name="checkpoint" type="Area2D"] |
||||||
|
script = ExtResource("1_v47vq") |
||||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,31 @@ |
|||||||
|
extends Node2D |
||||||
|
class_name GGameState |
||||||
|
|
||||||
|
signal restore_checkpoint(level) |
||||||
|
|
||||||
|
var level_rising_height_now = 0 |
||||||
|
var level_rising_height_at_death = 0 |
||||||
|
|
||||||
|
var player_position_at_checkpoint = Vector2(0, 0) |
||||||
|
|
||||||
|
var must_restore_checkpoint = false |
||||||
|
|
||||||
|
func reset(): |
||||||
|
level_rising_height_now = 0 |
||||||
|
level_rising_height_at_death = 0 |
||||||
|
|
||||||
|
func save_level_rising_height(now): |
||||||
|
if must_restore_checkpoint: |
||||||
|
restore_checkpoint_now() |
||||||
|
must_restore_checkpoint = false |
||||||
|
else : |
||||||
|
level_rising_height_now = now |
||||||
|
|
||||||
|
func checkpoint(player_position): |
||||||
|
level_rising_height_at_death = level_rising_height_now |
||||||
|
player_position_at_checkpoint = player_position |
||||||
|
|
||||||
|
func restore_checkpoint_now(): |
||||||
|
prints('restoring with', level_rising_height_at_death) |
||||||
|
level_rising_height_now = level_rising_height_at_death |
||||||
|
emit_signal("restore_checkpoint", level_rising_height_at_death) |
||||||
@ -0,0 +1,7 @@ |
|||||||
|
extends Button |
||||||
|
|
||||||
|
@export_file('*.tscn') var GAME_SCENE |
||||||
|
|
||||||
|
func _pressed(): |
||||||
|
get_tree().change_scene_to_file(GAME_SCENE) |
||||||
|
g_game_state.must_restore_checkpoint = true |
||||||
Loading…
Reference in new issue