Cambiados los aspectos visuales del juego a algo gotico
This commit is contained in:
1 parent
ec7e35ddf6
commit
967b3a286d
205 files changed
+7056
-1630
No files matched your search
@@ -0,0 +1,93 @@
|
||||
"""Small PNG/AtlasTexture readers for art contracts, using only the standard library."""
|
||||
from functools import lru_cache
|
||||
from hashlib import sha256
|
||||
from pathlib import Path
|
||||
import re
|
||||
import struct
|
||||
import zlib
|
||||
|
||||
|
||||
@lru_cache(maxsize=12)
|
||||
def rgba_png(path: Path) -> tuple[int, int, bytes]:
|
||||
"""Decode an ordinary non-interlaced RGBA8 PNG; reject another export format."""
|
||||
data = path.read_bytes()
|
||||
assert data[:8] == b"\x89PNG\r\n\x1a\n", f"Not a PNG: {path}"
|
||||
offset = 8
|
||||
payload = bytearray()
|
||||
width = height = 0
|
||||
while offset < len(data):
|
||||
length = struct.unpack_from(">I", data, offset)[0]
|
||||
kind = data[offset + 4:offset + 8]
|
||||
chunk = data[offset + 8:offset + 8 + length]
|
||||
if kind == b"IHDR":
|
||||
width, height, depth, color_type, compression, filtering, interlace = struct.unpack(">IIBBBBB", chunk)
|
||||
assert (depth, color_type, compression, filtering, interlace) == (8, 6, 0, 0, 0), path
|
||||
elif kind == b"IDAT":
|
||||
payload.extend(chunk)
|
||||
elif kind == b"IEND":
|
||||
break
|
||||
offset += length + 12
|
||||
stride = width * 4
|
||||
raw = zlib.decompress(payload)
|
||||
assert width > 0 and height > 0 and len(raw) == (stride + 1) * height, path
|
||||
result = bytearray(stride * height)
|
||||
for y in range(height):
|
||||
start = y * (stride + 1)
|
||||
mode = raw[start]
|
||||
row = bytearray(raw[start + 1:start + 1 + stride])
|
||||
previous = result[(y - 1) * stride:y * stride] if y else bytes(stride)
|
||||
if mode:
|
||||
for x in range(stride):
|
||||
left = row[x - 4] if x >= 4 else 0
|
||||
up = previous[x]
|
||||
upper_left = previous[x - 4] if x >= 4 else 0
|
||||
if mode == 1:
|
||||
prediction = left
|
||||
elif mode == 2:
|
||||
prediction = up
|
||||
elif mode == 3:
|
||||
prediction = (left + up) // 2
|
||||
elif mode == 4:
|
||||
base = left + up - upper_left
|
||||
distances = (abs(base - left), abs(base - up), abs(base - upper_left))
|
||||
prediction = (left, up, upper_left)[distances.index(min(distances))]
|
||||
else:
|
||||
raise AssertionError(f"Unknown PNG filter {mode}: {path}")
|
||||
row[x] = (row[x] + prediction) & 255
|
||||
result[y * stride:(y + 1) * stride] = row
|
||||
return width, height, bytes(result)
|
||||
|
||||
|
||||
def atlas_path(root: Path, frames_source: str) -> Path:
|
||||
paths = re.findall(r'\[ext_resource type="Texture2D"[^\n]*path="res://([^\"]+)"', frames_source)
|
||||
assert len(paths) == 1, paths
|
||||
return root / paths[0]
|
||||
|
||||
|
||||
def atlas_regions(frames_source: str) -> dict[str, tuple[int, int, int, int]]:
|
||||
regions = {}
|
||||
for name, body in re.findall(r'\[sub_resource type="AtlasTexture" id="([^\"]+)"\]([^\[]+)', frames_source):
|
||||
match = re.search(r'region = Rect2\(([\d.]+), ([\d.]+), ([\d.]+), ([\d.]+)\)', body)
|
||||
assert match, name
|
||||
regions[name] = tuple(int(float(value)) for value in match.groups())
|
||||
return regions
|
||||
|
||||
|
||||
def animation_frames(frames_source: str, name: str) -> list[str]:
|
||||
for frame_block, animation in re.findall(
|
||||
r'"frames":\s*\[(.*?)\],\s*"loop":\s*(?:true|false),\s*"name":\s*&"([^\"]+)"',
|
||||
frames_source, re.S,
|
||||
):
|
||||
if animation == name:
|
||||
return re.findall(r'SubResource\("([^\"]+)"\)', frame_block)
|
||||
raise AssertionError(f"Missing animation: {name}")
|
||||
|
||||
|
||||
def region_hash(image: tuple[int, int, bytes], region: tuple[int, int, int, int]) -> str:
|
||||
width, height, rgba = image
|
||||
x, y, w, h = region
|
||||
assert x >= 0 and y >= 0 and x + w <= width and y + h <= height
|
||||
digest = sha256()
|
||||
for row in range(y, y + h):
|
||||
digest.update(rgba[(row * width + x) * 4:(row * width + x + w) * 4])
|
||||
return digest.hexdigest()
|
||||
@@ -6,7 +6,10 @@ static func prepare(tree: SceneTree) -> PlayerProgressStore:
|
||||
var path: String = "user://__test_progress_%d_%d.json" % [OS.get_process_id(), Time.get_ticks_usec()]
|
||||
var profile: PlayerProgressStore = tree.root.get_node_or_null("PlayerProgress") as PlayerProgressStore
|
||||
if profile == null:
|
||||
profile = preload("res://game/player_progress.tscn").instantiate() as PlayerProgressStore
|
||||
# La carga diferida evita precargar el mismo PackedScene antes de que Godot
|
||||
# inicialice su autoload cuando la suite arranca mediante --script.
|
||||
var profile_scene: PackedScene = load("res://game/player_progress.tscn") as PackedScene
|
||||
profile = profile_scene.instantiate() as PlayerProgressStore
|
||||
profile.name = "PlayerProgress"
|
||||
profile.save_path = path
|
||||
tree.root.add_child(profile)
|
||||
|
||||
@@ -2,22 +2,20 @@
|
||||
from pathlib import Path
|
||||
import re
|
||||
import unittest
|
||||
import xml.etree.ElementTree as ET
|
||||
try:
|
||||
from .art_asset_helpers import animation_frames, atlas_path, atlas_regions, region_hash, rgba_png
|
||||
except ImportError: # unittest discover -s tests imports each module at the top level.
|
||||
from art_asset_helpers import animation_frames, atlas_path, atlas_regions, region_hash, rgba_png
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
ROLES = ('guitarist', 'drummer', 'bassist', 'singer')
|
||||
NAMES = ('Diego', 'Ivan', 'Fer', 'Hector')
|
||||
SVG_NS = '{http://www.w3.org/2000/svg}'
|
||||
|
||||
|
||||
def source(path):
|
||||
return (ROOT / path).read_text(encoding='utf-8')
|
||||
|
||||
|
||||
def cell_groups(path):
|
||||
return {group.attrib['id']: group for group in ET.parse(ROOT / path).getroot().findall(SVG_NS + 'g')}
|
||||
|
||||
|
||||
class BandResourceTests(unittest.TestCase):
|
||||
def test_named_profiles_have_independent_frames(self):
|
||||
for role, name in zip(ROLES, NAMES):
|
||||
@@ -82,63 +80,51 @@ class BandResourceTests(unittest.TestCase):
|
||||
expected_names = {'idle', 'walk', 'jump', 'fall', 'punch', 'ground_pound',
|
||||
'land', 'pound_land', 'special_start', 'special', 'special_end', 'hurt'}
|
||||
for role in ROLES:
|
||||
atlas = ET.parse(ROOT / f'assets/characters/band/{role}.svg').getroot()
|
||||
self.assertEqual((atlas.attrib['width'], atlas.attrib['height']), ('512', '320'))
|
||||
self.assertEqual(atlas.attrib['shape-rendering'], 'geometricPrecision')
|
||||
self.assertFalse(list(atlas.iter(SVG_NS + 'image')))
|
||||
self.assertFalse(list(atlas.iter(SVG_NS + 'text')))
|
||||
text = source(f'player/characters/animations/{role}_frames.tres')
|
||||
self.assertEqual(set(re.findall(r'"name": &"([^"]+)"', text)), expected_names)
|
||||
atlas_file = atlas_path(ROOT, text)
|
||||
self.assertEqual(atlas_file.suffix, '.png')
|
||||
width, height, rgba = rgba_png(atlas_file)
|
||||
self.assertEqual((width, height), (1152, 768))
|
||||
alpha = rgba[3::4]
|
||||
self.assertEqual(min(alpha), 0, 'El fondo del atlas debe ser transparente')
|
||||
self.assertGreaterEqual(max(alpha), 250, 'Los cuerpos deben contener pixeles opacos')
|
||||
self.assertTrue(expected_names <= set(re.findall(r'"name": &"([^"]+)"', text)))
|
||||
declared = re.findall(r'\[sub_resource type="AtlasTexture" id="([^"]+)"\]', text)
|
||||
self.assertEqual(len(declared), 40)
|
||||
self.assertGreaterEqual(len(declared), 40)
|
||||
self.assertEqual(set(declared), set(re.findall(r'SubResource\("([^"]+)"\)', text)))
|
||||
self.assertEqual(set(declared), set(cell_groups(f'assets/characters/band/{role}.svg')))
|
||||
for x, y, w, h in re.findall(r'region = Rect2\((\d+), (\d+), (\d+), (\d+)\)', text):
|
||||
x, y, w, h = map(int, (x, y, w, h))
|
||||
self.assertEqual((w, h), (64, 64))
|
||||
self.assertLessEqual(x+w, 512)
|
||||
self.assertLessEqual(y+h, 320)
|
||||
regions = atlas_regions(text)
|
||||
self.assertEqual(set(declared), set(regions))
|
||||
for x, y, w, h in regions.values():
|
||||
self.assertEqual((w, h), (192, 192))
|
||||
self.assertEqual((x % 192, y % 192), (0, 0))
|
||||
self.assertLessEqual(x+w, width)
|
||||
self.assertLessEqual(y+h, height)
|
||||
self.assertEqual(int(re.search(r'load_steps=(\d+)', text)[1]),
|
||||
1+len(re.findall(r'^\[(?:ext|sub)_resource ', text, re.M)))
|
||||
|
||||
def test_playable_art_has_distinct_identity_and_correct_instruments(self):
|
||||
generator = source('tools/generate_vector_character_art.py')
|
||||
# Rasgos visibles y paletas propias, no solo cambios de nombre en los SVG.
|
||||
for token in ('Barba abundante', 'Chaleco vaquero oscuro',
|
||||
'Camiseta negra', 'Rizo pequeño', 'Chaqueta negra con solapas',
|
||||
'count = 4 if is_bass else 6'):
|
||||
self.assertIn(token, generator)
|
||||
guitarist = source('assets/characters/band/guitarist.svg')
|
||||
bassist = source('assets/characters/band/bassist.svg')
|
||||
drummer = source('assets/characters/band/drummer.svg')
|
||||
singer = source('assets/characters/band/singer.svg')
|
||||
self.assertIn('Diego', guitarist)
|
||||
self.assertIn('Fer', bassist)
|
||||
self.assertIn('Iván', drummer)
|
||||
self.assertIn('Héctor', singer)
|
||||
# El instrumento aparece en las poses especiales, no en el idle.
|
||||
identities = set()
|
||||
for role in ROLES:
|
||||
groups = cell_groups(f'assets/characters/band/{role}.svg')
|
||||
idle_paths = list(groups['idle_0'].iter(SVG_NS + 'path'))
|
||||
special_paths = list(groups['special_0'].iter(SVG_NS + 'path'))
|
||||
self.assertGreater(len(special_paths), len(idle_paths), role)
|
||||
self.assertIn('Dos baquetas cruzadas', generator)
|
||||
self.assertIn('nunca aparecen en Fer', generator)
|
||||
self.assertIn('verde de cuatro cuerdas', source('assets/characters/band/README.md'))
|
||||
frames = source(f'player/characters/animations/{role}_frames.tres')
|
||||
regions = atlas_regions(frames)
|
||||
image = rgba_png(atlas_path(ROOT, frames))
|
||||
idle = region_hash(image, regions[animation_frames(frames, 'idle')[0]])
|
||||
special = {region_hash(image, regions[name]) for name in animation_frames(frames, 'special')}
|
||||
self.assertTrue(any(pose != idle for pose in special), role)
|
||||
identities.add(idle)
|
||||
# Los instrumentos y siluetas se inspeccionan ademas en la captura real.
|
||||
portrait = ROOT / f'assets/ashen/portraits/{role}.png'
|
||||
self.assertTrue(portrait.is_file(), role)
|
||||
self.assertEqual(len(identities), 4, 'Cada integrante conserva un sprite propio')
|
||||
|
||||
def test_vector_walk_uses_six_distinct_leg_contacts(self):
|
||||
# Ninguna celda conserva los rectangulos originales; pasos con tobillo y rodilla.
|
||||
def test_pixel_walk_uses_distinct_animation_cells(self):
|
||||
for role in ROLES:
|
||||
groups = cell_groups(f'assets/characters/band/{role}.svg')
|
||||
paths = []
|
||||
for i in range(6):
|
||||
group = groups[f'walk_{i}']
|
||||
paths.append(group.find(SVG_NS+'path').attrib['d'])
|
||||
self.assertTrue(any('url(#jacket)' in str(node.attrib)
|
||||
for node in group.iter(SVG_NS+'path')), role)
|
||||
self.assertGreaterEqual(len(set(paths)), 5, role)
|
||||
self.assertIn('def draw_shoe(', source('tools/generate_vector_character_art.py'))
|
||||
self.assertIn('def pose_parameters(', source('tools/generate_vector_character_art.py'))
|
||||
frames = source(f'player/characters/animations/{role}_frames.tres')
|
||||
walk = animation_frames(frames, 'walk')
|
||||
regions = atlas_regions(frames)
|
||||
image = rgba_png(atlas_path(ROOT, frames))
|
||||
self.assertEqual(len(walk), 6)
|
||||
self.assertGreaterEqual(len({region_hash(image, regions[name]) for name in walk}), 5, role)
|
||||
|
||||
def test_punch_uses_identical_timing_in_every_profile(self):
|
||||
expected = [('1.0', 'punch_0'), ('0.75', 'punch_1'), ('1.15', 'punch_2'),
|
||||
@@ -162,7 +148,8 @@ class BandResourceTests(unittest.TestCase):
|
||||
self.assertNotIn(identifier, fx)
|
||||
for kind in ('electric_pound', 'vocal_dome', 'bass_cracks', 'vocal_wave', 'drum_cymbals', 'bass_pulse'):
|
||||
self.assertIn(f'func _draw_{kind}(', fx)
|
||||
self.assertIn('draw_colored_polygon(dome', fx)
|
||||
self.assertIn('draw_texture_rect_region(FX_ATLAS', fx)
|
||||
self.assertIn('CanvasItem.TEXTURE_FILTER_NEAREST', fx)
|
||||
self.assertIn('draw_set_transform(Vector2.ZERO, 0.0, Vector2.ONE)', fx)
|
||||
|
||||
def test_bass_notes_and_camera_share_the_combat_pulse(self):
|
||||
|
||||
@@ -67,16 +67,18 @@ func _test_chasing_and_return() -> void:
|
||||
|
||||
func _test_jumping() -> void:
|
||||
var flat: Array[Rect2] = [Rect2(-500, 300, 1500, 200)]
|
||||
if not await _arena("pogo_fan", flat, Vector2(100, 270), Vector2(430, 274)):
|
||||
var step: Array[Rect2] = [Rect2(-500, 300, 700, 200), Rect2(200, 250, 800, 250)]
|
||||
# La IA salta para salvar un obstaculo/desnivel; no salta sin motivo en suelo plano.
|
||||
if not await _arena("pogo_fan", step, Vector2(100, 270), Vector2(430, 224)):
|
||||
return
|
||||
var pogo_result: Dictionary = await _advance(55)
|
||||
_check(bool(pogo_result["jump_seen"]), "Pogo must hop while pursuing on flat ground")
|
||||
var pogo_result: Dictionary = await _advance(40)
|
||||
_check(bool(pogo_result["jump_seen"]), "Pogo must jump towards a reachable elevated target")
|
||||
_check(float(pogo_result["minimum_y"]) < 210.0, "Pogo must physically leave the floor")
|
||||
_check(_enemy.position.x > 200.0, "Pogo jump must advance towards the target")
|
||||
_check(not _enemy.is_on_floor(), "The sweep check must run while Pogo is airborne")
|
||||
_player.position = _enemy.position + Vector2(40, 0)
|
||||
_check(not bool(_enemy.call("_is_target_in_attack_trigger")), "Do not start ground sweeps in mid-air")
|
||||
|
||||
var step: Array[Rect2] = [Rect2(-500, 300, 700, 200), Rect2(200, 250, 800, 250)]
|
||||
if not await _arena("rival_guitarist", step, Vector2(120, 270), Vector2(400, 224)):
|
||||
return
|
||||
await _advance(125)
|
||||
|
||||
@@ -21,18 +21,23 @@ class Level00ResourceTests(unittest.TestCase):
|
||||
for asset in re.findall(r'preload\("res://([^"]+)"\)', SCRIPT):
|
||||
self.assertTrue((ROOT / asset).is_file(), asset)
|
||||
|
||||
def test_pixel_art_is_real_rgba_png_and_parallax_is_repeated(self):
|
||||
graphics = list((ROOT / "assets/city").glob("*.png"))
|
||||
self.assertEqual(len(graphics), 15)
|
||||
def test_pixel_art_uses_png_depth_layers_and_repeated_parallax(self):
|
||||
graphics = [ROOT / path for path in re.findall(
|
||||
r'\[ext_resource type="Texture2D" path="res://([^\"]+)"', BACKGROUND)]
|
||||
self.assertEqual(len(graphics), 3)
|
||||
for png in graphics:
|
||||
content = png.read_bytes()
|
||||
self.assertTrue(content.startswith(b"\x89PNG\r\n\x1a\n"), png.name)
|
||||
width, height = struct.unpack(">II", content[16:24])
|
||||
self.assertGreater(width, 15)
|
||||
self.assertGreater(height, 15)
|
||||
self.assertEqual(BACKGROUND.count('type="Parallax2D"'), 4)
|
||||
self.assertEqual(BACKGROUND.count('repeat_size = Vector2(1024, 0)'), 4)
|
||||
self.assertIn('autoscroll = Vector2(3, 0)', BACKGROUND)
|
||||
self.assertGreater(width, 512)
|
||||
self.assertGreater(height, 256)
|
||||
self.assertEqual(BACKGROUND.count('type="Parallax2D"'), 3)
|
||||
for name in ('Distant', 'Middle', 'Near'):
|
||||
self.assertIn(f'[node name="{name}" type="Parallax2D"', BACKGROUND)
|
||||
vista = (ROOT / 'world/backgrounds/ashen_vista.gd').read_text()
|
||||
self.assertIn('layer.repeat_size = Vector2(width * 2.0, 0.0)', vista)
|
||||
self.assertIn('panel.flip_h = index == 1', vista)
|
||||
self.assertNotIn('HighClouds', BACKGROUND)
|
||||
self.assertIn('texture_repeat = 2', LEVEL)
|
||||
|
||||
def test_road_is_continuous_and_has_end_walls(self):
|
||||
|
||||
@@ -53,14 +53,24 @@ func _run() -> void:
|
||||
_fail("Pickup sin datos/icono: " + node.name)
|
||||
return
|
||||
|
||||
for name: String in ["Sky", "HighClouds", "FarBuildings", "NearBuildings"]:
|
||||
var previous_speed: float = 0.0
|
||||
for name: String in ["Distant", "Middle", "Near"]:
|
||||
var layer: Parallax2D = level.get_node("CityBackground/" + name) as Parallax2D
|
||||
if layer == null or layer.repeat_size.x != 1024:
|
||||
if layer == null or layer.repeat_size.x <= 0.0:
|
||||
_fail("Falta la capa de parallax repetible: " + name)
|
||||
return
|
||||
if (layer.get_node("Strip") as Sprite2D).texture == null:
|
||||
var normal: Sprite2D = layer.get_node("Normal") as Sprite2D
|
||||
var mirrored: Sprite2D = layer.get_node("Mirrored") as Sprite2D
|
||||
if normal.texture == null or mirrored.texture != normal.texture or not mirrored.flip_h:
|
||||
_fail("Falta la textura de la capa: " + name)
|
||||
return
|
||||
if not is_equal_approx(layer.repeat_size.x, normal.texture.get_width() * normal.scale.x * 2.0):
|
||||
_fail("La repeticion no coincide con el ancho dibujado: " + name)
|
||||
return
|
||||
if layer.scroll_scale.x <= previous_speed or layer.scroll_scale.x >= 1.0:
|
||||
_fail("Las capas necesitan velocidades de profundidad distintas: " + name)
|
||||
return
|
||||
previous_speed = layer.scroll_scale.x
|
||||
|
||||
if level.get_node("World/Ground").get_child_count() != 8:
|
||||
_fail("Numero incorrecto de calles")
|
||||
@@ -75,7 +85,7 @@ func _run() -> void:
|
||||
_fail("Faltan las barreras de inicio y final")
|
||||
return
|
||||
|
||||
print("OK LEVEL00: escena, 30 HP, pound 7-12, 29 enemigos, 14 pickups, 4 parallax, calles, plataformas y barreras")
|
||||
print("OK LEVEL00: escena, 30 HP, pound 7-12, 29 enemigos, 14 pickups, 3 planos parallax, calles, plataformas y barreras")
|
||||
quit(0)
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,10 @@ Verifica recursos sin sustituir la inspeccion visual ni las pruebas del motor.
|
||||
from pathlib import Path
|
||||
import re
|
||||
import unittest
|
||||
from xml.etree import ElementTree
|
||||
try:
|
||||
from .art_asset_helpers import atlas_path, atlas_regions, region_hash, rgba_png
|
||||
except ImportError:
|
||||
from art_asset_helpers import atlas_path, atlas_regions, region_hash, rgba_png
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
LEVEL = (ROOT / "levels/level_02.tscn").read_text(encoding="utf-8")
|
||||
@@ -21,13 +24,24 @@ class Level02VisualResourceTests(unittest.TestCase):
|
||||
self.assertTrue((ROOT / resource).is_file(), resource)
|
||||
|
||||
def test_reaper_has_real_animation_frames_and_separate_weapon(self):
|
||||
atlas = ROOT / "assets/bosses/muerte/muerte_body_atlas.svg"
|
||||
scythe = ROOT / "assets/bosses/muerte/spectral_scythe.svg"
|
||||
for path in (atlas, scythe):
|
||||
root = ElementTree.parse(path).getroot()
|
||||
self.assertIn("viewBox", root.attrib)
|
||||
self.assertGreater(int(root.attrib["width"]), 90)
|
||||
frames = (ROOT / "assets/bosses/muerte/muerte_frames.tres").read_text()
|
||||
atlas = atlas_path(ROOT, frames)
|
||||
self.assertEqual(atlas.suffix, ".png")
|
||||
image = rgba_png(atlas)
|
||||
self.assertEqual(image[:2], (1536, 1536))
|
||||
self.assertEqual(min(image[2][3::4]), 0)
|
||||
self.assertGreaterEqual(max(image[2][3::4]), 250)
|
||||
regions = atlas_regions(frames)
|
||||
self.assertEqual(len(regions), 16)
|
||||
self.assertEqual(len({region_hash(image, region) for region in regions.values()}), 16)
|
||||
for x, y, width, height in regions.values():
|
||||
self.assertEqual((width, height), (384, 384))
|
||||
self.assertEqual((x % 384, y % 384), (0, 0))
|
||||
scythe = ROOT / "assets/ashen/bosses/spectral_scythe.png"
|
||||
weapon = rgba_png(scythe)
|
||||
self.assertEqual(weapon[:2], (192, 288))
|
||||
self.assertEqual(min(weapon[2][3::4]), 0)
|
||||
self.assertIn('path="res://assets/ashen/bosses/spectral_scythe.png"', BOSS)
|
||||
for animation in ("idle", "approach", "telegraph", "slash", "cast", "dash", "phase", "hurt", "death"):
|
||||
self.assertIn(f'"name": &"{animation}"', frames)
|
||||
self.assertIn('name="WeaponPivot"', BOSS)
|
||||
@@ -44,6 +58,7 @@ class Level02VisualResourceTests(unittest.TestCase):
|
||||
|
||||
def test_gate_uses_reusable_scene_and_opens_visibly(self):
|
||||
gate_scene = (ROOT / "world/triggers/kill_gate.tscn").read_text()
|
||||
gate_visual = (ROOT / "world/triggers/ossuary_gate_visual.tscn").read_text()
|
||||
gate_code = (ROOT / "world/triggers/kill_gate.gd").read_text()
|
||||
victory_code = (ROOT / "world/triggers/boss_victory.gd").read_text()
|
||||
self.assertIn('instance=ExtResource("gate")', LEVEL)
|
||||
@@ -55,9 +70,15 @@ class Level02VisualResourceTests(unittest.TestCase):
|
||||
self.assertIn('gate_visual.fully_open.connect(', gate_code)
|
||||
self.assertIn('gate_visual.set_unlocked(_open)', gate_code)
|
||||
self.assertIn('fully_open.emit()', GATE_CODE)
|
||||
self.assertIn('func _draw_skull(', GATE_CODE)
|
||||
self.assertIn('func _draw_leaf(', GATE_CODE)
|
||||
self.assertIn('name="Visual" type="Node2D"', gate_scene)
|
||||
self.assertIn('name="Visual" parent="." instance=ExtResource("visual")', gate_scene)
|
||||
for name in ("LeftLeaf", "RightLeaf", "Arch", "Seal"):
|
||||
self.assertIn(f'name="{name}" type="Sprite2D"', gate_visual)
|
||||
textures = re.findall(r'\[ext_resource type="Texture2D" path="res://([^\"]+)"', gate_visual)
|
||||
self.assertGreaterEqual(len(textures), 5)
|
||||
for path in textures:
|
||||
self.assertTrue((ROOT / path).is_file(), path)
|
||||
self.assertEqual(Path(path).suffix, ".png")
|
||||
self.assertIn('texture_filter = 1', gate_visual)
|
||||
self.assertIn('level.complete_level()', victory_code)
|
||||
self.assertNotIn('res://levels/level_02.gd', LEVEL)
|
||||
|
||||
|
||||
@@ -37,14 +37,33 @@ func _test_gate() -> void:
|
||||
gate.set("enemies_root_path", NodePath("../Enemies"))
|
||||
world.add_child(gate)
|
||||
await process_frame
|
||||
var visual: Node2D = gate.get_node("Visual") as Node2D
|
||||
var left_leaf: Sprite2D = visual.get_node("LeftLeaf") as Sprite2D
|
||||
var right_leaf: Sprite2D = visual.get_node("RightLeaf") as Sprite2D
|
||||
visual.set_process(false)
|
||||
var closed_left: float = left_leaf.position.x
|
||||
var closed_right: float = right_leaf.position.x
|
||||
_check(int(gate.get("remaining")) == 1, "Gate counts configured enemies")
|
||||
_check(not (gate.get_node("CollisionShape2D") as CollisionShape2D).disabled,
|
||||
"A locked gate still blocks the route")
|
||||
foe.died.emit()
|
||||
_check(int(gate.get("remaining")) == 0, "Gate tracks enemy death")
|
||||
gate.get_node("Visual").call("_process", 1.3)
|
||||
visual.set_process(false)
|
||||
visual.call("_process", 0.3)
|
||||
await process_frame
|
||||
_check(left_leaf.position.x < closed_left and right_leaf.position.x > closed_right,
|
||||
"The two painted iron leaves visibly move apart during opening")
|
||||
_check(not (gate.get_node("CollisionShape2D") as CollisionShape2D).disabled,
|
||||
"Partial visual opening retains the blocking collision")
|
||||
visual.call("_process", 1.3)
|
||||
await process_frame
|
||||
await physics_frame
|
||||
_check((gate.get_node("CollisionShape2D") as CollisionShape2D).disabled,
|
||||
"Gate collision is removed after full visual opening")
|
||||
_check((visual.get_node("Seal") as Sprite2D).modulate.a == 0.0,
|
||||
"The broken seal disappears once the route is open")
|
||||
_check(left_leaf.position.x < -100.0 and right_leaf.position.x > 100.0,
|
||||
"Open leaves clear the full passage instead of only changing tint")
|
||||
world.queue_free()
|
||||
await process_frame
|
||||
|
||||
|
||||
@@ -132,12 +132,27 @@ func _verify_presets() -> void:
|
||||
if packed == null:
|
||||
continue
|
||||
var instance: Node = packed.instantiate()
|
||||
root.add_child(instance)
|
||||
# Los componentes vinculados se prueban con sus objetivos obligatorios.
|
||||
# Instanciarlos sueltos solo produciria el error de configuracion esperado.
|
||||
var fixture := Node.new()
|
||||
if path.ends_with("/boss_victory.tscn"):
|
||||
var boss := Node.new()
|
||||
boss.name = "Boss"
|
||||
boss.add_user_signal("died")
|
||||
fixture.add_child(boss)
|
||||
instance.set("boss_path", NodePath("../Boss"))
|
||||
elif path.ends_with("/kill_gate.tscn"):
|
||||
var enemies := Node.new()
|
||||
enemies.name = "Enemies"
|
||||
fixture.add_child(enemies)
|
||||
instance.set("enemies_root_path", NodePath("../Enemies"))
|
||||
fixture.add_child(instance)
|
||||
root.add_child(fixture)
|
||||
await process_frame
|
||||
if instance is Pickup:
|
||||
_check((instance as Pickup).pickup_data != null, "Objeto sin datos: " + path)
|
||||
_check((instance.get_node("Sprite2D") as Sprite2D).texture != null, "Objeto sin icono: " + path)
|
||||
instance.queue_free()
|
||||
fixture.queue_free()
|
||||
await process_frame
|
||||
|
||||
|
||||
@@ -148,6 +163,7 @@ func _verify_levels() -> void:
|
||||
"res://levels/examples/scenery_catalog.tscn",
|
||||
"res://levels/level_01.tscn",
|
||||
"res://levels/level_00.tscn",
|
||||
"res://levels/level_02.tscn",
|
||||
]:
|
||||
var packed: PackedScene = load(path) as PackedScene
|
||||
_check(packed != null, "No se pudo cargar el nivel " + path)
|
||||
|
||||
@@ -4,6 +4,7 @@ extends SceneTree
|
||||
## Ejecutar con: godot --headless --path . --script res://tests/test_pause_result_runtime.gd
|
||||
const BETA: String = "res://levels/level_00.tscn"
|
||||
const NEXT: String = "res://levels/level_01.tscn"
|
||||
const LAST: String = "res://levels/level_02.tscn"
|
||||
const MENU: String = "res://ui/menu/main_menu.tscn"
|
||||
const DIEGO: CharacterData = preload("res://player/characters/guitarist.tres")
|
||||
var _failures: int = 0
|
||||
@@ -60,6 +61,16 @@ func _run() -> void:
|
||||
_check(level.get_node("Player").get("character_data") == DIEGO, "Avanzar conserva personaje")
|
||||
_check(level.call("complete_level"), "Level01 tiene salida de victoria")
|
||||
controls = level.get_node("LevelNavigation/Overlay/Dialog/Panel/Margin/Options")
|
||||
_check(not (controls.get_node("Next") as Button).disabled, "Level01 conduce a Level02")
|
||||
(controls.get_node("Next") as Button).pressed.emit()
|
||||
level = await _wait_for_scene(LAST)
|
||||
if level == null:
|
||||
quit(1)
|
||||
return
|
||||
_check(not paused, "Entrar al tercer nivel reanuda")
|
||||
_check(level.get_node("Player").get("character_data") == DIEGO, "El tercer nivel conserva personaje")
|
||||
_check(level.call("complete_level"), "Level02 tiene salida de victoria")
|
||||
controls = level.get_node("LevelNavigation/Overlay/Dialog/Panel/Margin/Options")
|
||||
_check((controls.get_node("Next") as Button).disabled, "En el ultimo nivel no hay siguiente")
|
||||
(controls.get_node("Levels") as Button).pressed.emit()
|
||||
var menu: Node = await _wait_for_scene(MENU)
|
||||
|
||||
@@ -3,43 +3,43 @@ from pathlib import Path
|
||||
import math
|
||||
import re
|
||||
import unittest
|
||||
import xml.etree.ElementTree as ET
|
||||
try:
|
||||
from .art_asset_helpers import atlas_path, atlas_regions, rgba_png
|
||||
except ImportError: # unittest discover -s tests imports each module at the top level.
|
||||
from art_asset_helpers import atlas_path, atlas_regions, rgba_png
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
FRAMES = ROOT / "player/characters/shared/prototype_sprite_frames.tres"
|
||||
FRAMES = ROOT / "player/characters/animations/guitarist_frames.tres"
|
||||
|
||||
|
||||
class PixelCombatResourceTests(unittest.TestCase):
|
||||
def test_all_animation_cells_exist_and_fit_atlas(self):
|
||||
text = FRAMES.read_text(encoding="utf-8")
|
||||
atlas = ET.parse(ROOT / "assets/characters/ankarde/player_pixel.svg").getroot()
|
||||
width, height = int(atlas.attrib["width"]), int(atlas.attrib["height"])
|
||||
width, height, _ = rgba_png(atlas_path(ROOT, text))
|
||||
declared = re.findall(r'\[sub_resource type="AtlasTexture" id="([^"]+)"\]', text)
|
||||
used = re.findall(r'SubResource\("([^"]+)"\)', text)
|
||||
self.assertEqual(len(declared), 37)
|
||||
self.assertGreaterEqual(len(declared), 40)
|
||||
self.assertEqual(set(declared), set(used))
|
||||
self.assertEqual(len(declared), len(set(declared)))
|
||||
for x, y, w, h in re.findall(r'region = Rect2\((\d+), (\d+), (\d+), (\d+)\)', text):
|
||||
x, y, w, h = map(int, (x, y, w, h))
|
||||
self.assertEqual((w, h), (64, 64))
|
||||
for x, y, w, h in atlas_regions(text).values():
|
||||
self.assertEqual((w, h), (192, 192))
|
||||
self.assertLessEqual(x + w, width)
|
||||
self.assertLessEqual(y + h, height)
|
||||
|
||||
def test_player_poses_and_vector_scale(self):
|
||||
def test_player_poses_and_pixel_scale(self):
|
||||
names = set(re.findall(r'"name": &"([^"]+)"', FRAMES.read_text()))
|
||||
self.assertEqual(names, {"idle", "walk", "jump", "fall", "punch", "ground_pound",
|
||||
"land", "special_start", "special", "special_end", "hurt"})
|
||||
self.assertTrue({"idle", "walk", "jump", "fall", "punch", "ground_pound",
|
||||
"land", "pound_land", "special_start", "special", "special_end", "hurt"} <= names)
|
||||
scene = (ROOT / "player/player.tscn").read_text()
|
||||
self.assertIn("size = Vector2(26, 52)", scene)
|
||||
self.assertIn("texture_filter = 2", scene)
|
||||
self.assertNotIn("scale = Vector2(0.56, 0.56)", scene)
|
||||
self.assertIn("texture_filter = 1", scene)
|
||||
self.assertIn("scale = Vector2(0.5, 0.5)", scene)
|
||||
self.assertIn("speed_scale = 1.0", scene)
|
||||
|
||||
def test_new_asset_has_no_external_dependencies(self):
|
||||
atlas = ET.parse(ROOT / "assets/characters/ankarde/player_pixel.svg").getroot()
|
||||
self.assertEqual(atlas.attrib["shape-rendering"], "crispEdges")
|
||||
self.assertFalse(list(atlas.iter("{http://www.w3.org/2000/svg}image")))
|
||||
self.assertFalse(list(atlas.iter("{http://www.w3.org/2000/svg}text")))
|
||||
frames = FRAMES.read_text(encoding="utf-8")
|
||||
self.assertEqual(atlas_path(ROOT, frames).suffix, ".png")
|
||||
self.assertNotIn('.svg', frames)
|
||||
for rel in ("player/player.gd", "enemies/walker/walker.gd", str(FRAMES.relative_to(ROOT))):
|
||||
for path in re.findall(r'res://([^"\s]+)', (ROOT / rel).read_text()):
|
||||
self.assertTrue((ROOT / path).is_file(), path)
|
||||
|
||||
@@ -95,7 +95,9 @@ func _run() -> void:
|
||||
"Death must grant special charge exactly once")
|
||||
enemy.call("_update_death_animation", 0.20)
|
||||
var enemy_visual: AnimatedSprite2D = enemy.get_node("Visual") as AnimatedSprite2D
|
||||
_check(enemy.visible and not is_zero_approx(enemy_visual.rotation), "Missing collapse animation")
|
||||
_check(enemy.visible and enemy_visual.animation == &"death"
|
||||
and enemy_visual.sprite_frames.get_frame_count(&"death") >= 2,
|
||||
"The visible enemy must play its drawn collapse poses before disappearing")
|
||||
enemy.call("_update_death_animation", 1.0)
|
||||
_check(not enemy.visible, "Enemy must hide after the death animation")
|
||||
_check(is_instance_valid(enemy), "Keep the dead node for level KO/total tracking")
|
||||
|
||||
@@ -4,7 +4,7 @@ extends SceneTree
|
||||
## La existencia de este script no implica que se haya ejecutado.
|
||||
const PLAYER_SCENE: PackedScene = preload("res://player/player.tscn")
|
||||
const RARE_SCENE: PackedScene = preload("res://rare_items/variants/lost_pick.tscn")
|
||||
const PROGRESS_SCENE: PackedScene = preload("res://game/player_progress.tscn")
|
||||
const PROGRESS_PATH: String = "res://game/player_progress.tscn"
|
||||
var _failures: int = 0
|
||||
var _profile: PlayerProgressStore
|
||||
var _level: LevelRoot
|
||||
@@ -79,7 +79,7 @@ func _run() -> void:
|
||||
_close_level()
|
||||
|
||||
# Reabrir el archivo demuestra el contrato de carga, no solo el estado de la misma instancia.
|
||||
var loaded: PlayerProgressStore = PROGRESS_SCENE.instantiate() as PlayerProgressStore
|
||||
var loaded: PlayerProgressStore = (load(PROGRESS_PATH) as PackedScene).instantiate() as PlayerProgressStore
|
||||
loaded.save_path = _profile.save_path
|
||||
loaded.rare_items.append(reward)
|
||||
root.add_child(loaded)
|
||||
@@ -118,7 +118,7 @@ func _test_backup_and_bad_data() -> void:
|
||||
var file: FileAccess = FileAccess.open(_profile.save_path, FileAccess.WRITE)
|
||||
file.store_string("not valid JSON")
|
||||
file.close()
|
||||
var loaded: PlayerProgressStore = PROGRESS_SCENE.instantiate() as PlayerProgressStore
|
||||
var loaded: PlayerProgressStore = (load(PROGRESS_PATH) as PackedScene).instantiate() as PlayerProgressStore
|
||||
loaded.save_path = _profile.save_path
|
||||
root.add_child(loaded)
|
||||
_check(loaded.has_item(&"lost_pick"), "Recupera los objetos de la copia valida")
|
||||
@@ -128,7 +128,7 @@ func _test_backup_and_bad_data() -> void:
|
||||
file = FileAccess.open(_profile.save_path, FileAccess.WRITE)
|
||||
file.store_string('{"version":999,"rare_items":[]}')
|
||||
file.close()
|
||||
loaded = PROGRESS_SCENE.instantiate() as PlayerProgressStore
|
||||
loaded = (load(PROGRESS_PATH) as PackedScene).instantiate() as PlayerProgressStore
|
||||
loaded.save_path = _profile.save_path
|
||||
root.add_child(loaded)
|
||||
var ids: Array[StringName] = [&"lost_pick"]
|
||||
|
||||
@@ -17,6 +17,10 @@ func _run() -> void:
|
||||
root.size = Vector2i(1152, 648)
|
||||
var arena := Node2D.new()
|
||||
var player: CharacterBody2D = load("res://player/player.tscn").instantiate() as CharacterBody2D
|
||||
# El escenario de la barra usa 50 HP sin imponer ese balance al recurso real.
|
||||
var health_test_data: CharacterData = (player.get("character_data") as CharacterData).duplicate() as CharacterData
|
||||
health_test_data.max_health = 50
|
||||
player.set("character_data", health_test_data)
|
||||
var enemy: CharacterBody2D = load("res://enemies/walker/walker.tscn").instantiate() as CharacterBody2D
|
||||
player.position = Vector2(200, 200)
|
||||
enemy.position = Vector2(250, 200)
|
||||
|
||||
Reference in new issue
Block a user