from kennel.engine.components.position import Position from kennel.engine.components.sprite_sheet import SpriteSheet, SpriteSpec from enum import Enum from .entity import Entity, EntityType class CatState(str, Enum): IDLE = "IDLE" FROLICKING = "FROLICKING" EEPY = "EEPY" ALERT = "ALERT" CHASING_CURSOR = "CHASING_CURSOR" CHASING_CAT = "CHASING_CAT" SCRATCHING = "SCRATCHING" ITCHY = "ITCHY" MAKING_BISCUITS = "MAKING_BISCUITS" class CatSpriteState(str, Enum): ALERT = "ALERT" MAKING_BISCUITS = "MAKING_BISCUITS" class Cat(Entity): def __init__(self, id: str, spritesheet_source: str): state_to_spritespec = self.get_state_to_spritespec() components = [ Position(50, 50), SpriteSheet( spritesheet_source, state_to_spritespec, CatSpriteState.MAKING_BISCUITS ), ] super().__init__(EntityType.CAT, id, components) def get_state_to_spritespec(self): creature_width = 32 creature_height = 32 return { CatSpriteState.ALERT: SpriteSpec( 100, creature_width * 7, creature_height * 3, creature_width * 8, creature_height * 4, 1, ), CatSpriteState.MAKING_BISCUITS: SpriteSpec( 300, 0, 0, creature_width, creature_height * 2, 2, ), } # # # IDLE, FROLICKING, EEPY, ALERT, CHASING_CURSOR, CHASING_CAT, SCRATCHING, ITCHY # state_stochastic_matrix = [ [1, 0] # # IDLE # [0.5, 0.1, 0.1, 0.1, 0.1, 0.05, 0.05, 0], # # FROLICKING # [0.1, 0.5, 0.1, 0.1, 0.1, 0.05, 0.05, 0], # # EEPY # [0.1, 0.1, 0.5, 0.1, 0.1, 0.05, 0.05, 0], # # ALERT # [0.1, 0.1, 0.1, 0.5, 0.1, 0.05, 0.05, 0], # # CHASING_CURSOR # [0.1, 0.1, 0.1, 0.1, 0.5, 0.05, 0.05, 0], # # CHASING_CAT # [0.1, 0.1, 0.1, 0.1, 0.1, 0.5, 0.05, 0], # # SCRATCHING # [0.1, 0.1, 0.1, 0.1, 0.1, 0.05, 0.5, 0], # # ITCHY # [0, 0, 0, 0, 0, 0, 0, 1], # ] # # # #