80 lines
2.3 KiB
GDScript
80 lines
2.3 KiB
GDScript
extends SceneTree
|
|
var game
|
|
func _initialize() -> void:
|
|
call_deferred("run")
|
|
func run() -> void:
|
|
game = load("res://games/galaga/Galaga.tscn").instantiate()
|
|
root.add_child(game)
|
|
game.set_physics_process(false)
|
|
assert(game.enemies.size()==40)
|
|
assert(game.start_game())
|
|
game.field.previous_state="idle"
|
|
game.field._process(0.0)
|
|
for enemy in game.enemies: assert(not enemy.node.visible)
|
|
game._update_enemies(0.01)
|
|
assert(game.enemies[0].node.visible)
|
|
assert(not game.enemies[1].node.visible)
|
|
assert(not game.start_game())
|
|
game._tick(game.intro_seconds+0.1)
|
|
game._tick(game.stage_card_seconds+0.1)
|
|
game._tick(game.player_card_seconds+0.1)
|
|
assert(game.state=="playing")
|
|
game._fire()
|
|
game.cooldown=0
|
|
game._fire()
|
|
game.cooldown=0
|
|
game._fire()
|
|
assert(game.bullets.size()==2 and game.shots_fired==2)
|
|
game._clear_bullets()
|
|
var boss: Dictionary = game.enemies[0]
|
|
boss.node.position=Vector2(100,100)
|
|
game._bullet(Vector2(100,100),Vector2.ZERO,true)
|
|
game._update_bullets(0)
|
|
assert(boss.hp==1 and game.score==0)
|
|
game._bullet(Vector2(100,100),Vector2.ZERO,true)
|
|
game._update_bullets(0)
|
|
assert(game.enemies.size()==39 and game.score==150)
|
|
game._die()
|
|
assert(game.lives==2 and game.state=="death")
|
|
game._tick(1.6)
|
|
assert(game.state=="playing" and game.invulnerable>0)
|
|
game.run_config={"score_to_win":200}
|
|
game._add_score(50)
|
|
assert(game.state=="victory")
|
|
game._tick(1.51)
|
|
assert(game.state=="won" and not game.is_running)
|
|
game.run_config={}
|
|
game.start_game()
|
|
game._add_score(140000)
|
|
assert(game.lives==6 and game.next_extra_life==210000)
|
|
game.reset_game()
|
|
assert(game.enemies.size()==40 and game.bullets.is_empty())
|
|
game.run_config={"stages_to_win":0}
|
|
game.start_game()
|
|
game._tick(game.intro_seconds+0.1)
|
|
game._tick(game.stage_card_seconds+0.1)
|
|
game._tick(game.player_card_seconds+0.1)
|
|
game.invulnerable=100
|
|
for i in range(1200): game._tick(1.0/60.0)
|
|
for enemy in game.enemies:
|
|
assert(is_finite(enemy.node.position.x))
|
|
assert(enemy.node.rotation==0)
|
|
game.state="playing"
|
|
game._clear_actors()
|
|
game._tick(0.01)
|
|
assert(game.state=="clear")
|
|
game._tick(2.1)
|
|
assert(game.stage==2 and game.enemies.size()==40)
|
|
game.state="playing"
|
|
game.lives=1
|
|
game._die()
|
|
game._tick(1.6)
|
|
assert(game.state=="lost" and not game.is_running)
|
|
game.queue_free()
|
|
await process_frame
|
|
await create_timer(0.1).timeout
|
|
print("GALAGA TESTS PASS")
|
|
quit()
|
|
|
|
|