def update(self, *args, **kwargs) -> None: '''Checks if user's cursor overlaps the button''' if pg.sprite.collide_rect(self, MSloc(pg.mouse.get_pos())): self.image = load_image(self.clicked_pic, folder=self.folder) pg.event.post(self.event[0]) else: self.image = load_image(self.unclicked_pic, folder=self.folder) pg.event.post(self.event[1])
def __init__(self, group, pos_x, pos_y, orientation=0, pic='border_lazer.png'): super(BorderLazer, self).__init__(group) if orientation == 0: self.image = load_image(pic, folder='data\game') elif orientation == 1: self.image = pg.transform.rotate( load_image(pic, folder='data\game'), 90) self.rect = self.image.get_rect() self.rect.x = pos_x self.rect.y = pos_y
def __init__(self, group, pos_x, pos_y, picture, folder): super().__init__(group) self.folder = folder self.image = load_image(picture, folder=folder) self.rect = self.image.get_rect() self.rect.x = WINDOW_SIZE[0] * pos_x - self.rect.w * 0.5 self.rect.y = WINDOW_SIZE[1] * pos_y
def __init__(self, group): super(Player, self).__init__(group) self.image = load_image('player.png', folder='data\game') self.rect = self.image.get_rect() self.rect.x = 400 self.rect.y = 400 self.vel = 5 self.last_direction = list()
def __init__(self, group, pos_x, pos_y, clicked_pic, unclicked_pic, event, folder): super().__init__(group) self.folder = folder self.image = load_image(unclicked_pic, folder=self.folder) self.rect = self.image.get_rect() self.rect.x = WINDOW_SIZE[0] * pos_x - self.rect.w * 0.5 self.rect.y = WINDOW_SIZE[1] * pos_y self.clicked_pic = clicked_pic self.unclicked_pic = unclicked_pic self.event = event
def spawn_reward(self): self.image = load_image('coin.png', folder='data\game') self.rect = self.image.get_rect() self.rect.x = choice(range(*self.spawn_field[0])) self.rect.y = choice(range(*self.spawn_field[1]))
def __init__(self, group): super(Reward, self).__init__(group) self.spawn_field = [(193, 387), (217, 608)] self.image = load_image('coin.png', folder='data\game') self.rect = self.image.get_rect() self.point = 0
def __init__(self, group, pos_x, pos_y, pic='wall.png'): super(BorderBlock, self).__init__(group) self.image = load_image(pic, folder='data\game') self.rect = self.image.get_rect() self.rect.x = pos_x self.rect.y = pos_y
def switch_difficulty(self, difficulty_name): self.image = load_image(difficulty_name, folder=self.folder)
def unselect(self, difficulty): self.image = load_image(f'{difficulty}notselected.png', folder='data/settings/difficulty')