Skip to content
This repository has been archived by the owner on Feb 18, 2025. It is now read-only.

Commit

Permalink
Add absolute animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Virashu committed Feb 20, 2024
1 parent 35a9b0d commit 9985f47
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions danmaku/game/animated.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ def animate(self) -> None:
)
self.texture_file = self.animation_frames[self.animation_current]

def animate_absolute(self, time: int) -> None:
"""Set frame according to time (milliseconds)"""
frame_duration = self.animation_period * 1000

self.animation_current = int(time // frame_duration) % len(
self.animation_frames
)

self.texture_file = self.animation_frames[self.animation_current]


class AnimatedDirectional(Animated):
"""Base class for animated objects, that change animations based on direction"""
Expand Down

0 comments on commit 9985f47

Please sign in to comment.