mejoras en interfaz y movimento de personaje
This commit is contained in:
1 parent
7a8b03e760
commit
f0fa01607c
29 files changed
+504320
-280
No files matched your search
@@ -0,0 +1,55 @@
|
||||
"""Contratos geometricos del overlay; la suite GDScript prueba los eventos reales."""
|
||||
from itertools import combinations
|
||||
from math import hypot
|
||||
from pathlib import Path
|
||||
import re
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SURFACE = (ROOT / 'ui/mobile_controls/touch_surface.gd').read_text(encoding='utf-8')
|
||||
|
||||
|
||||
class MobileControlResources(unittest.TestCase):
|
||||
def test_circular_action_layout_is_spaced_inside_safe_area(self):
|
||||
buttons = {
|
||||
name: (float(x), float(y), float(radius))
|
||||
for name, x, y, radius in re.findall(
|
||||
r'&"(\w+)": \{"offset": Vector2\((\d+), (\d+)\), "radius": ([\d.]+)',
|
||||
SURFACE,
|
||||
)
|
||||
}
|
||||
self.assertEqual(set(buttons), {'jump', 'attack', 'ground_pound', 'special_attack'})
|
||||
padding = float(re.search(r'HIT_PADDING: float = ([\d.]+)', SURFACE)[1])
|
||||
self.assertGreaterEqual(buttons['jump'][2], 75)
|
||||
self.assertGreaterEqual(buttons['attack'][2], 75)
|
||||
self.assertTrue(all(r > 56 for _, _, r in buttons.values()))
|
||||
# Se prueba el layout a escala 1, en panoramica y con recortes laterales/inferiores.
|
||||
for width, height in [(1280, 720), (1600, 720), (1504, 690), (1100, 600)]:
|
||||
scale = min(1, width / 1280, height / 720)
|
||||
for name, (x, y, radius) in buttons.items():
|
||||
hit = (radius + padding) * scale
|
||||
cx, cy = width - x * scale, height - y * scale
|
||||
self.assertGreater(cx - hit, width / 2, name)
|
||||
self.assertLessEqual(cx + hit, width, name)
|
||||
self.assertGreaterEqual(cy - hit, 0, name)
|
||||
self.assertLessEqual(cy + hit, height, name)
|
||||
for (a, (ax, ay, ar)), (b, (bx, by, br)) in combinations(buttons.items(), 2):
|
||||
self.assertGreater(hypot(ax - bx, ay - by) * scale,
|
||||
(ar + br + 2 * padding) * scale, (a, b))
|
||||
self.assertEqual(len({x for x, _, _ in buttons.values()}), 4)
|
||||
self.assertEqual(len({y for _, y, _ in buttons.values()}), 4)
|
||||
|
||||
def test_all_levels_keep_one_shared_overlay(self):
|
||||
for name in ('level_00', 'level_01', 'level_02'):
|
||||
text = (ROOT / f'levels/{name}.tscn').read_text(encoding='utf-8')
|
||||
self.assertIn('res://ui/mobile_controls/mobile_controls.tscn', text)
|
||||
self.assertEqual(text.count('[node name="MobileControls"'), 1)
|
||||
scene = (ROOT / 'ui/mobile_controls/mobile_controls.tscn').read_text(encoding='utf-8')
|
||||
self.assertIn('path="res://ui/mobile_controls/touch_surface.gd"', scene)
|
||||
self.assertIn('mouse_filter = 2', scene)
|
||||
self.assertNotIn('type="Button"', scene)
|
||||
self.assertNotIn('button_plate.png', scene)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user