extends Node2D const PLAYER := preload("res://scenes/game/player_ship.tscn") func _ready() -> void: GameState.start_new_run() var ship := PLAYER.instantiate() as CharacterBody2D add_child(ship) ship.set_physics_process(false) ship.get_node("WeaponController").set_physics_process(false) ship.set("energy_regeneration", 0.0) ship.set("energy", 100.0) ship.velocity = Vector2.UP*ship.max_speed var boost_cost: float = ship.get_mini_boost_energy_cost() var tab := InputEventKey.new() tab.physical_keycode = KEY_TAB assert(InputMap.action_has_event("ship_mini_boost", tab)) Input.action_press("ship_mini_boost") ship.call("_physics_process", 1.0) assert(ship.call("is_mini_boosting")) assert(is_equal_approx(ship.get("energy"), 100.0-boost_cost)) assert(is_equal_approx(ship.velocity.length(), ship.get("max_speed") * 2.0)) var engine := ship.get_node("EngineVisual") engine.call("_process", 0.2) assert(engine.get("_mini_boost")) var particles: Array = engine.get("_trail_particles") assert(not particles.is_empty() and particles[0]["boost"]) Input.action_release("ship_mini_boost") ship.call("_physics_process", 0.1) assert(not ship.call("is_mini_boosting")) var released_speed := ship.velocity.length() assert(released_speed > ship.get("max_speed")) assert(is_equal_approx(released_speed, ship.get("max_speed") * 2.0 - ship.get("space_drag") * 0.1)) Input.action_press("ship_thrust") ship.call("_physics_process", 0.1) assert(is_equal_approx(ship.velocity.length(), released_speed - ship.get("space_drag") * 0.1)) Input.action_release("ship_thrust") for frame in 120: ship.call("_physics_process", 0.1) assert(ship.velocity.length() <= ship.get("max_speed")) ship.set("energy", 0.0) Input.action_press("ship_mini_boost") ship.call("_physics_process", 0.1) assert(not ship.call("is_mini_boosting")) ship.set("energy", 100.0) ship.velocity = Vector2.UP*ship.max_speed Input.action_release("ship_mini_boost") ship.call("_physics_process", 0.1) Input.action_press("ship_mini_boost") ship.call("_physics_process", 1.0) ship.set("energy", 0.0) ship.call("_physics_process", 0.1) assert(not ship.call("is_mini_boosting")) assert(is_equal_approx(ship.velocity.length(), ship.get("max_speed") * 2.0 - ship.get("space_drag") * 0.1)) ship.set("energy", 20.0) ship.call("_physics_process", 0.1) assert(not ship.call("is_mini_boosting") and ship.get("energy") == 20.0) Input.action_release("ship_mini_boost") ship.call("_physics_process", 0.1) Input.action_press("ship_mini_boost") ship.call("_physics_process", 0.1) assert(ship.call("is_mini_boosting") and is_equal_approx(ship.get("energy"),20.0-boost_cost*0.1)) Input.action_press("ship_brake") ship.call("_physics_process", 0.1) assert(not ship.call("is_mini_boosting") and is_equal_approx(ship.get("energy"),20.0-boost_cost*0.1)) Input.action_release("ship_brake") ship.call("start_boost", 2.0, 0.5) ship.set("_boost_speed", ship.get("max_speed") * 2.0) ship.call("_physics_process", 0.1) assert(ship.call("_get_allowed_speed") == ship.get("max_speed") * 3.0) ship.set("is_docked", true) ship.call("_physics_process", 0.1) assert(not ship.call("is_mini_boosting")) Input.action_release("ship_mini_boost") print("MINI_BOOST_TEST: PASS (Tab mapping, double speed, energy drain, chassis-colored boost trail, release, exhaustion latch, braking, afterburner and docking)")