55 lines
1.8 KiB
GDScript
55 lines
1.8 KiB
GDScript
extends SceneTree
|
|
|
|
func _initialize() -> void:
|
|
call_deferred("run_test")
|
|
|
|
func run_test() -> void:
|
|
var world = load("res://scenes/main.tscn").instantiate()
|
|
root.add_child(world)
|
|
world.set_process(false)
|
|
var player = world.player
|
|
player.set_physics_process(false)
|
|
player.hp = 90.0
|
|
player._regenerate_health(0.5)
|
|
assert(player.hp == 90.0)
|
|
player._regenerate_health(0.5)
|
|
assert(player.hp == 91.0)
|
|
player._regenerate_health(3.0)
|
|
assert(player.hp == 94.0)
|
|
print("PASS: +1 HP ogni secondo, recupero frame lunghi")
|
|
player.hp = 99.5
|
|
player._regenerate_health(5.0)
|
|
assert(player.hp == 100.0)
|
|
player._regenerate_health(0.0)
|
|
player.hp = 90.0
|
|
player._regenerate_health(0.5)
|
|
assert(player.hp == 90.0)
|
|
print("PASS: limite 100 HP, nessun accumulo a vita piena")
|
|
if "--screenshot" in OS.get_cmdline_user_args():
|
|
player.position = Vector3(0, 0, -6)
|
|
player.camera.rotation = Vector3.ZERO
|
|
await create_timer(0.5).timeout
|
|
await RenderingServer.frame_post_draw
|
|
root.get_texture().get_image().save_png("/tmp/zombie-star-window.png")
|
|
player.hp = 0
|
|
player._regenerate_health(10.0)
|
|
assert(player.hp == 0)
|
|
player.hp = 30
|
|
player.death_started = true
|
|
player._regenerate_health(10.0)
|
|
assert(player.hp == 30)
|
|
print("PASS: nessuna rigenerazione dopo morte")
|
|
var environment: Environment
|
|
for node in world.get_children():
|
|
if node is WorldEnvironment:
|
|
environment = node.environment
|
|
assert(environment.background_mode == Environment.BG_SKY)
|
|
assert(environment.sky.sky_material is PanoramaSkyMaterial)
|
|
var texture = environment.sky.sky_material.panorama
|
|
assert(texture.get_width() == 2048 and texture.get_height() == 1024)
|
|
assert(environment.ambient_light_source == Environment.AMBIENT_SOURCE_COLOR)
|
|
print("PASS: panorama stellato caricato, illuminazione stanza preservata")
|
|
world.queue_free()
|
|
await process_frame
|
|
quit()
|