56 lines
1.6 KiB
GDScript
56 lines
1.6 KiB
GDScript
extends Node
|
|
const DT := 1.0 / 60.0
|
|
func _ready() -> void:
|
|
var level := get_tree().current_scene
|
|
if level.name == "Probe":
|
|
level = level.get_node("Level1")
|
|
var fox := level.get_node("Fox")
|
|
|
|
# 1. Coin pickup: walk right into coin at 150, walk to 200
|
|
fox.position = Vector2(150, 556)
|
|
Input.action_press("move_right")
|
|
Input.action_press("jump")
|
|
await get_tree().create_timer(2.0).timeout
|
|
Input.action_release("move_right")
|
|
Input.action_release("jump")
|
|
await get_tree().create_timer(0.3).timeout
|
|
|
|
# 2. Question block bump
|
|
fox.position = Vector2(320, 556)
|
|
Input.action_press("jump")
|
|
for i in range(180):
|
|
await get_tree().physics_frame
|
|
fox._physics_process(DT)
|
|
if fox.is_on_floor():
|
|
Input.action_release("jump")
|
|
if i > 60:
|
|
break
|
|
Input.action_release("jump")
|
|
await get_tree().create_timer(0.6).timeout
|
|
|
|
# 3. Breakable brick
|
|
fox.position = Vector2(384, 556)
|
|
Input.action_press("jump")
|
|
for i in range(180):
|
|
await get_tree().physics_frame
|
|
fox._physics_process(DT)
|
|
if fox.is_on_floor():
|
|
Input.action_release("jump")
|
|
if i > 60:
|
|
break
|
|
Input.action_release("jump")
|
|
await get_tree().create_timer(0.6).timeout
|
|
|
|
# 4. Run to win zone
|
|
fox.position = Vector2(560, 556)
|
|
Input.action_press("move_right")
|
|
for i in range(120):
|
|
await get_tree().physics_frame
|
|
fox._physics_process(DT)
|
|
if not is_instance_valid(level.get_node("WinZone")):
|
|
break
|
|
Input.action_release("move_right")
|
|
await get_tree().create_timer(0.5).timeout
|
|
print("=== RESULT === state=", GameManager.state, " score=", GameManager.score, " lives=", GameManager.lives, " elapsed=", snappedf(GameManager.time_elapsed, 0.1))
|
|
get_tree().quit()
|