Skip to content

Commit 1c78c5f

Browse files
committed
Store animation frame starts in an array
1 parent 1b7587e commit 1c78c5f

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

engine/core/animation.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import bisect
99
import pygame
1010

11+
from array import array
12+
1113
from typing import Optional, Union
1214

1315
from ..loaders.nut_loader import nut_source, nut_call_function
@@ -47,7 +49,7 @@ def __init__(self, anim_path: str, loop: bool = True) -> None:
4749
self.frames = []
4850
self.loop: bool = loop
4951

50-
self._starts: list[float] = []
52+
self._starts: array[float] = array("d")
5153
self._duration: float = 0.0
5254
self._started_at: int = 0
5355

@@ -84,7 +86,9 @@ def set_image(self, anim_path: str, loop: Optional[bool] = None) -> None:
8486
self.loop = loop
8587

8688
delays = [delay for _, delay in loaded]
87-
timings = [float(t) for t in nut_call_function("frame_starts", delays, len(delays))]
89+
timings = array(
90+
"d", [float(t) for t in nut_call_function("frame_starts", delays, len(delays))]
91+
)
8892

8993
self._starts = timings[:-1]
9094
self._duration = timings[-1]

0 commit comments

Comments
 (0)