test: 八项无头回归测试(道具/弹道/Boss/海面/地面单位/浮游炮/炸弹/冒烟模拟)
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
extends SceneTree
|
||||
## 海面覆盖回归测试:滚动两个完整周期(1200 帧),
|
||||
## 逐帧断言贴图联合覆盖包含整屏 Rect2(0,0,540,960)。
|
||||
## 运行:godot --headless -s tests/ocean_test.gd
|
||||
|
||||
const SCREEN := Rect2(0.0, 0.0, 540.0, 960.0)
|
||||
const TILE_HALF := Vector2(270.0, 270.0)
|
||||
const FRAMES := 1200
|
||||
|
||||
var _ocean: OceanScroll
|
||||
var _frames := 0
|
||||
var _fails := 0
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
_ocean = OceanScroll.new()
|
||||
root.add_child(_ocean)
|
||||
print("[ocean_test] ocean instantiated")
|
||||
|
||||
|
||||
func _process(_delta: float) -> bool:
|
||||
_frames += 1
|
||||
# 第 1 帧本回调先于海面节点的首个 _process,跳过(贴图尚未定位)
|
||||
if _frames >= 2:
|
||||
var covered := Rect2()
|
||||
var first := true
|
||||
for tile in _ocean._tiles:
|
||||
var rect := Rect2(tile.position - TILE_HALF, TILE_HALF * 2.0)
|
||||
if first:
|
||||
covered = rect
|
||||
first = false
|
||||
else:
|
||||
covered = covered.merge(rect)
|
||||
if not covered.encloses(SCREEN):
|
||||
_fails += 1
|
||||
if _fails <= 3:
|
||||
print("[FAIL] frame %d coverage=%s tiles=%s" % [_frames, covered, _ocean._tiles.map(func(t): return t.position)])
|
||||
|
||||
if _frames >= FRAMES:
|
||||
if _fails == 0:
|
||||
print("[ocean_test] PASS: %d 帧整屏全覆盖" % FRAMES)
|
||||
else:
|
||||
print("[ocean_test] FAIL: %d/%d 帧覆盖不足" % [_fails, FRAMES])
|
||||
quit(1 if _fails > 0 else 0)
|
||||
return true
|
||||
return false
|
||||
Reference in New Issue
Block a user