30 lines
856 B
GDScript
30 lines
856 B
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()
|
|
var events := []
|
|
game.game_won.connect(func(): events.append("won"))
|
|
game.state="playing"
|
|
game._bullet(Vector2(100,200),Vector2(0,-100),true)
|
|
game.win_game()
|
|
assert(game.state=="victory" and events.is_empty())
|
|
game._tick(0.5)
|
|
assert(game.bullets[0].node.position.y==150)
|
|
assert(game.state=="victory")
|
|
game.win_game()
|
|
game._tick(1.01)
|
|
assert(game.state=="won" and not game.is_running and events.size()==1)
|
|
var before: float=game.clock
|
|
game._physics_process(0.5)
|
|
assert(game.clock>before)
|
|
game.reset_game()
|
|
assert(game.state=="idle")
|
|
print("VICTORY TRANSITION PASS")
|
|
game.queue_free()
|
|
await process_frame
|
|
quit()
|