The core idea is decoupling loading animation states and logical game states with a sprite class (and eventually load assist functions) that do more than what the built-in Sprite classes provide. This makes it much faster and easier to hide hardcoded behaviors for cops in each puzzle area ("Sleepy" cop class, "Angry" Cop class, etc).
Usage could look something like this if we don't have any AI controller classes and keep logic entirely inside the cops:
# example taken from the cop that switches directions included in the PR
def update(self, delta_time: float = 1 / 60):
self.reverse_timer.update(delta_time)
if self.reverse_timer.remaining <= delta_time:
if self.current_animation_name == WALK_RIGHT:
self.current_animation_name = WALK_LEFT
else:
self.current_animation_name = WALK_RIGHT
self.reverse_timer.remaining = self.delay_between_reversals
We'll eventually have a common set of state names expressed as constants or enums. The player and all or most cops will share state names for the following, and many (or all) cops will share sprite sets.
I'm not strictly attached to individual files for frames. If there's a compelling reason to, we could use sheets (single files with multiple frames) as well or instead.
With the current implementation, it should also be possible to override frame set selection behavior in subclasses to have a range of appearances in cops. It might also be possible to automate this with pillow or use shaders to tint.
If we want to reduce asset load even further, we can work on using speech or thought bubbles to express the differences in desires between cops when a player enters an area. Text on screen might also work.
The core idea is decoupling loading animation states and logical game states with a sprite class (and eventually load assist functions) that do more than what the built-in
Sprite
classes provide. This makes it much faster and easier to hide hardcoded behaviors for cops in each puzzle area ("Sleepy" cop class, "Angry" Cop class, etc).Usage could look something like this if we don't have any AI controller classes and keep logic entirely inside the cops:
We'll eventually have a common set of state names expressed as constants or enums. The player and all or most cops will share state names for the following, and many (or all) cops will share sprite sets.
Important notes:
If we want to reduce asset load even further, we can work on using speech or thought bubbles to express the differences in desires between cops when a player enters an area. Text on screen might also work.