from PIL import Image class Rotate: down = 0.0 right = 90.0 up = 180.0 left = 270.0 class Dialogs: dreaming = [] class Frames: """These strings do match to the PNGs of the VPet which are representation the frames of an animation""" def __init__(self): self.idle_1 = Image.open('pets_sprites/demonite/idle1.png') self.idle_2 = Image.open('pets_sprites/demonite/idle2.png') self.idle_3 = Image.open('pets_sprites/demonite/idle3.png') self.move_1 = Image.open('pets_sprites/demonite/moving_1.png') self.move_2 = Image.open('pets_sprites/demonite/moving_2.png') self.hearts_1 = Image.open('pets_sprites/demonite/heart.png') self.floating = Image.open('pets_sprites/demonite/floating.png') class Animations: @staticmethod def idle_1(rotation: float): pass @staticmethod def move_right(rotation: float): pass @staticmethod def move_left(rotation: float): pass @staticmethod def move_up(rotation: float): pass @staticmethod def move_down(rotation: float): pass @staticmethod def sleep(rotation: float): pass @staticmethod def wakeup(rotation: float): pass class Activity: def __init__(self): self.is_idle = True self.is_sleeping = False self.is_dreaming = False self.is_moving = False self.is_talking = False self.is_thinking = False self.is_interacting_with_user = False def set_idle(self): print('Setting idle') self.is_idle = True self.is_sleeping = False self.is_dreaming = False self.is_moving = False self.is_talking = False self.is_thinking = False self.is_interacting_with_user = False def set_sleeping(self): print('Setting sleeping') self.is_idle = False self.is_sleeping = True self.is_moving = False self.is_talking = False self.is_thinking = False def set_dreaming(self): print('Setting dreaming') self.is_idle = False self.is_dreaming = True self.is_moving = False self.is_talking = False self.is_thinking = False def set_moving(self): print('Setting moving') self.is_idle = False self.is_moving = True self.is_sleeping = False self.is_dreaming = False def set_talking(self): print('Setting talking') self.is_idle = False self.is_talking = True self.is_thinking = False self.is_sleeping = False def set_thinking(self): self.is_idle = False self.is_talking = False self.is_thinking = True self.is_sleeping = False def set_interacting_with_user(self): print('Setting interacting with user') self.is_idle = False self.is_sleeping = False self.is_dreaming = False self.is_moving = False self.is_talking = False self.is_thinking = False self.is_interacting_with_user = True class VPet: def __init__(self, move, pos, draw, x=0, y=100, screen=1): self.screen = screen self.pos = pos self.x_postion = x self.y_postion = y self.x_destination = 0 self.y_destination = 0 self.rotation = Rotate.up self.p = 0 self.move = move self.draw = draw self.frames = Frames() self.activity = Activity() def action_loop(self): # print(f'Interacting with user: {self.activity.is_interacting_with_user}') self.update_position() print(self.x_postion, self.y_postion) if self.activity.is_interacting_with_user: return self.x_postion = self.pos().x() + 3 self.draw(self.frames.idle_1) self.move(self.x_postion, self.y_postion) def update_position(self): self.x_postion = self.pos().x() self.y_postion = self.pos().y() def choose_walk_destination(self): """Decide, where the VPet should move to""" pass def choose_activity(self): """Decide, what kind of activity should be done""" pass def walk(self, x: int, y: int): """Move the VPet to xy""" self.activity.is_moving = True def sleep(self): """Set the VPet asleep""" self.activity.set_sleeping() Animations.sleep(rotation=self.rotation) def wakeup(self): """Wake up the VPet from sleep""" if not self.activity.is_sleeping: return Animations.wakeup(rotation=self.rotation) self.activity.set_idle() def blink_eyes(self): """Make the VPet blink""" pass def detect_orientation(self): """Detect the desired rotation based on the postion on the screen, like left border, bottom, etc""" pass def talk(self, message: str): """Make the VPet talk to the user via a speech bubble""" pass def think(self): """Make the VPet think""" pass def dream(self): """Make the VPet dream""" pass