68 lines
2.3 KiB
GDScript
68 lines
2.3 KiB
GDScript
extends SceneTree
|
|
func _initialize() -> void:
|
|
call_deferred("run")
|
|
func run() -> void:
|
|
var game = load("res://games/galaga/Galaga.tscn").instantiate()
|
|
root.add_child(game)
|
|
game.set_physics_process(false)
|
|
game.start_game()
|
|
assert(game.state=="intro" and not game.player.visible)
|
|
game.field._process(0)
|
|
assert(not game.player.visible)
|
|
game._tick(game.intro_seconds+0.01)
|
|
assert(game.state=="stage_card" and not game.player.visible)
|
|
game._tick(game.stage_card_seconds+0.01)
|
|
assert(game.state=="ready" and game.player.visible)
|
|
game._tick(game.player_card_seconds+0.01)
|
|
assert(game.state=="playing")
|
|
# Different formation slots must share the same pre-docking entrance curve.
|
|
game.enemies[0].time=0.4
|
|
game.enemies[1].time=0.4
|
|
game._update_enemies(0)
|
|
assert(game.enemies[0].node.position.is_equal_approx(game.enemies[1].node.position))
|
|
for enemy in game.enemies: assert(enemy.node.scale==Vector2.ONE)
|
|
var boss: Dictionary = game.enemies[0]
|
|
boss.mode="beam"
|
|
boss.time=0
|
|
boss.node.position=Vector2(112,172)
|
|
game.beam=boss
|
|
game._update_enemies(0.01)
|
|
assert(game.state=="capturing")
|
|
game._sound("fire")
|
|
for voice in game.voices:
|
|
if voice.playing: assert(voice.stream==game.streams["capturing"])
|
|
game._tick(1.6)
|
|
assert(game.lives==2 and game.captive.visible and not game.player.visible)
|
|
for i in range(400):
|
|
if game.state=="playing": break
|
|
game._tick(1.0/60.0)
|
|
assert(game.state=="playing" and game.player.visible)
|
|
boss.node.position=Vector2(112,100)
|
|
game.captive.position=Vector2(112,84)
|
|
boss.hp=1
|
|
game._bullet(Vector2(112,100),Vector2.ZERO,true)
|
|
game._update_bullets(0)
|
|
assert(game.state=="rescue_spin" and game.captor.is_empty())
|
|
var frozen: Vector2=game.enemies[0].node.position
|
|
game._tick(0.1)
|
|
assert(game.enemies[0].node.position==frozen)
|
|
for i in range(600):
|
|
if game.state=="playing": break
|
|
game._tick(1.0/60.0)
|
|
assert(game.dual and not game.captive.visible)
|
|
game._tick(0.01)
|
|
game._clear_bullets()
|
|
game.cooldown=0
|
|
game._fire()
|
|
assert(game.bullets.size()==2)
|
|
assert(absf(game.bullets[0].node.position.x-game.bullets[1].node.position.x)==16)
|
|
game._die()
|
|
assert(not game.dual and game.lives==2 and game.state=="playing")
|
|
game.reset_game()
|
|
assert(game.captor.is_empty() and not game.captive.visible and not game.dual)
|
|
print("CAPTURE AND INTRO TESTS PASS")
|
|
game.queue_free()
|
|
await process_frame
|
|
quit()
|
|
|