mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 08:23:45 +00:00
test(training): cover wall rebound geometry
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
extends TestCase
|
||||
extends "res://tests/test_case.gd"
|
||||
|
||||
const ShipAIControllerScript = preload("res://scripts/ship_ai_controller.gd")
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
extends "res://tests/test_case.gd"
|
||||
|
||||
const TrainingModeScript = preload("res://scripts/training_mode.gd")
|
||||
|
||||
func test_wall_play_points_into_the_field() -> void:
|
||||
var velocity: Vector3 = TrainingModeScript.wall_state_velocity(false, 1.0, 8.0, 0.1, -0.2)
|
||||
assert_true(velocity.x < 0.0, "positive-side wall play travels inward")
|
||||
assert_almost_eq(velocity.length(), 8.0, 0.0001, "wall-play speed is preserved")
|
||||
|
||||
func test_rebound_points_into_the_selected_wall() -> void:
|
||||
var velocity: Vector3 = TrainingModeScript.wall_state_velocity(true, 1.0, 8.0, 0.1, -0.2)
|
||||
assert_true(velocity.x > 0.0, "positive-side rebound travels toward the wall")
|
||||
assert_almost_eq(velocity.length(), 8.0, 0.0001, "rebound speed is preserved")
|
||||
|
||||
func test_opposite_walls_mirror_the_normal_component() -> void:
|
||||
var positive: Vector3 = TrainingModeScript.wall_state_velocity(false, 1.0, 6.0, 0.0, 0.0)
|
||||
var negative: Vector3 = TrainingModeScript.wall_state_velocity(false, -1.0, 6.0, 0.0, 0.0)
|
||||
assert_eq(positive.x, -negative.x, "opposite wall starts mirror the x direction")
|
||||
|
||||
func test_negative_speed_fails_closed() -> void:
|
||||
assert_eq(TrainingModeScript.wall_state_velocity(false, 1.0, -1.0, 0.0, 0.0), Vector3.ZERO, "negative speed cannot create velocity")
|
||||
Reference in New Issue
Block a user