Add one HP per second regeneration and Half-Life starfield sky
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
"""Convert local Half-Life space sky faces to a Godot panorama (Pillow + ffmpeg)."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import pathlib
|
||||
import subprocess
|
||||
import tempfile
|
||||
from PIL import Image
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('source', type=pathlib.Path, help='Half-Life valve/gfx/env directory')
|
||||
args = parser.parse_args()
|
||||
out = pathlib.Path(__file__).resolve().parents[1] / 'assets/textures/sky'
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
faces = ['rt', 'lf', 'up', 'dn', 'ft', 'bk']
|
||||
images = [Image.open(args.source / f'space{s}.tga').convert('RGB') for s in faces]
|
||||
w, h = images[0].size
|
||||
assert w == h and all(im.size == (w, h) for im in images)
|
||||
strip = Image.new('RGB', (6*w, h))
|
||||
for i, im in enumerate(images):
|
||||
strip.paste(im, (i*w, 0))
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
src = pathlib.Path(tmp) / 'cube.png'
|
||||
strip.save(src)
|
||||
subprocess.run(['ffmpeg', '-y', '-loglevel', 'error', '-i', str(src),
|
||||
'-vf', 'v360=input=c6x1:output=e:in_forder=rludfb:w=2048:h=1024',
|
||||
'-frames:v', '1', str(out / 'space_panorama.png')], check=True)
|
||||
manifest = {f'space{s}.tga': hashlib.sha256((args.source / f'space{s}.tga').read_bytes()).hexdigest() for s in faces}
|
||||
(out / 'source_manifest.json').write_text(json.dumps(manifest, indent=2) + '\n')
|
||||
print(out / 'space_panorama.png')
|
||||
@@ -0,0 +1,54 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user