extends SceneTree var failures := 0 func check(value: bool, message: String) -> void: if not value: failures += 1 push_error(message) func _initialize() -> void: call_deferred("run") func run() -> void: var g = load("res://games/frogger/Frogger.tscn").instantiate() root.add_child(g) g.set_physics_process(false) g.music_enabled = false check(g.start_game(),"Start rejected") check(not g.start_game(),"Duplicate start accepted") g._physics_process(1.6) check(g.phase == "play","Ready transition") g.lanes.clear() check(g.hop(Vector2i.UP),"Hop rejected") check(not g.hop(Vector2i.RIGHT),"Overlapping hop accepted") g.step_world(.12) check(g.frog == Vector2(112,216) and g.score == 10,"Hop distance/score") g.make_lanes() g.frog = Vector2(25,216) g.step_world(0) check(g.phase == "dead" and g.lives == 2,"Road collision") g._physics_process(1.2) check(g.phase == "play" and g.frog == Vector2(112,232),"Respawn") g.frog = Vector2(50,104) g.step_world(.01) check(g.phase == "play" and g.frog.x > 50,"Log carry") g.frog = Vector2(90,104) g.step_world(0) check(g.phase == "dead" and g.death_kind == "plunk","Water collision") g._physics_process(1.2) g.clock = 6 g.frog = Vector2(24,72) g.step_world(0) check(g.phase == "dead","Submerged turtle collision") g._physics_process(1.2) check(g.phase == "lost" and not g.is_running,"Lose event state") g.start_game() g.phase = "play" for i in range(5): g.frog = Vector2(g.HOME_X[i],40) g.step_world(0) check(g.homes[i] and g.phase == "home","Home entry") g._physics_process(.9) check(g.phase == "clear","Five homes transition") g._physics_process(2.1) check(g.phase == "won" and not g.is_running,"Win state") g.start_game() g.boards_to_win = 0 g.phase = "clear" g.phase_time = 0 g._physics_process(.01) check(g.board_number == 2 and g.phase == "ready","Endless progression") g.reset_game() check(g.phase == "title" and not g.is_running and not g.homes.has(true),"Reset") print("Frogger checks: ",failures," failures") g.queue_free() await process_frame quit(failures)