Animaciones
This commit is contained in:
1 parent
b365c79251
commit
8a5290c5ef
10 files changed
+1581
-288
No files matched your search
@@ -0,0 +1,62 @@
|
||||
"""Engine-independent checks. Run: python -m unittest discover -s tests -v."""
|
||||
from pathlib import Path
|
||||
import math
|
||||
import re
|
||||
import unittest
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
FRAMES = ROOT / "player/characters/shared/prototype_sprite_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"])
|
||||
declared = re.findall(r'\[sub_resource type="AtlasTexture" id="([^"]+)"\]', text)
|
||||
used = re.findall(r'SubResource\("([^"]+)"\)', text)
|
||||
self.assertEqual(len(declared), 37)
|
||||
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))
|
||||
self.assertLessEqual(x + w, width)
|
||||
self.assertLessEqual(y + h, height)
|
||||
|
||||
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"})
|
||||
scene = (ROOT / "player/player.tscn").read_text()
|
||||
self.assertIn("size = Vector2(26, 52)", scene)
|
||||
self.assertIn("texture_filter = 1", scene)
|
||||
self.assertNotIn("scale = Vector2(0.56, 0.56)", 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")))
|
||||
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)
|
||||
|
||||
def test_pulse_rounding_preserves_the_damage_budget(self):
|
||||
# Mathematical invariant used by the GDScript cumulative damage formula.
|
||||
# Runtime behaviour is covered separately by test_pixel_combat_runtime.gd.
|
||||
for total in range(1, 101):
|
||||
for count in range(1, 9):
|
||||
dealt = 0
|
||||
for index in range(count):
|
||||
cumulative = math.ceil(total * (index + 1) / count)
|
||||
damage = cumulative - dealt
|
||||
self.assertGreaterEqual(damage, 0)
|
||||
dealt = cumulative
|
||||
self.assertEqual(dealt, total)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user