forked from wxm/Fighting_Rthythm_game
41 lines
996 B
GDScript
41 lines
996 B
GDScript
extends SceneTree
|
|
|
|
const ORIGINAL_JUMP_INTENSITY := 430.0
|
|
const GRAVITY := 1200.0
|
|
|
|
var failures: Array[String] = []
|
|
|
|
|
|
func _init() -> void:
|
|
var scene: PackedScene = load("res://scenes/characters/player.tscn")
|
|
if scene == null:
|
|
push_error("Could not load player.tscn")
|
|
quit(1)
|
|
return
|
|
|
|
var player: Node = scene.instantiate()
|
|
var jump_intensity: float = float(player.get("jump_intensity"))
|
|
var expected_height: float = _jump_height(ORIGINAL_JUMP_INTENSITY) * 0.5
|
|
var actual_height: float = _jump_height(jump_intensity)
|
|
|
|
if absf(actual_height - expected_height) > 0.01:
|
|
failures.append("jump height expected %.3f, got %.3f from jump_intensity %.3f" % [
|
|
expected_height,
|
|
actual_height,
|
|
jump_intensity,
|
|
])
|
|
|
|
player.free()
|
|
|
|
if failures.is_empty():
|
|
print("PASS jump height")
|
|
quit(0)
|
|
else:
|
|
for failure: String in failures:
|
|
push_error(failure)
|
|
quit(1)
|
|
|
|
|
|
func _jump_height(jump_intensity: float) -> float:
|
|
return jump_intensity * jump_intensity / (2.0 * GRAVITY)
|