Deli-Slicer / CatBurglar

0 stars 0 forks source link

Add prototype for Actor movement system #2

Closed pushfoo closed 3 years ago

pushfoo commented 3 years ago

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.

    still_right
    still_left
    walk_right
    walk_left
    turnfrom_right2left
    turnrom_left2right
    goupstairs_right
    goupstairs_left
    godownstairs_right
    godownstairs_left

Important notes:

  1. 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.
  2. 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.