コード例 #1
0
ファイル: animation_system.py プロジェクト: blindseth/rpeg
    def dispatch(self, message, game):
        """Function for determining what action to call depending on the
        message"""
        width, height = pygame.display.get_surface().get_size()
        if message.mtype == "message":
            # Set hovered object from a slot
            text, colour = message.args
            surface = draw_text(text, self.message_font, colour)
            animation = anime.Anime(surface, width // 2, 500)
            animation.set_filter('y', anime.filter.linear, 2)
            animation.set_filter('opacity', anime.filter.linear, 5)
            animation.y = 400
            animation.opacity = 0
            self.animations.append(animation)
        elif message.mtype == "battle-message":
            target, text, colour = message.args
            x = random.randint(-20, 20)
            y = random.randint(-20, 20)
            if target in game.party.players:
                index = game.party.players.index(target)
                x = x + 156 + 312 * index
                y = y + height - 100
            elif game.encounter and target in game.encounter:
                index = game.encounter.index(target)
                num_enemies = len(game.encounter)
                x = x + width // (num_enemies + 1) * (index + 1)
                y = y + 200

            surface = draw_text(text, self.battle_font, colour)
            animation = anime.Anime(surface, x, y)
            animation.set_filter('y', anime.filter.linear, 1)
            animation.set_filter('opacity', anime.filter.linear, 4)
            animation.y = y - 100
            animation.opacity = 0
            self.animations.append(animation)
コード例 #2
0
    def render_clicked(self, game):
        surface = frame.draw_highlight_frame(self.width,
                                             self.height,
                                             highlight=(0, 255, 0),
                                             seed=self.draw_seed)
        if self.move is None:
            return surface

        # Draw the move iself.mage
        icon_filename = self.move.icon
        if icon_filename:
            icon_surface = simple.draw_image(icon_filename, 6)
        else:
            icon_surface = simple.draw_image(ItemSlot.DEFAULTICON, 6)

        surface.blit(icon_surface,
                     (self.width // 2 - icon_surface.get_width() // 2, 12))

        # Text elements
        surface.blit(
            simple.draw_text(self.move.name.title(),
                             self.title_font, (0, 255, 0),
                             self.width - 24,
                             justify="center"), (12, 100))
        surface.blit(
            simple.draw_text(self.move.description,
                             self.font, (0, 255, 0),
                             self.width - 24,
                             justify="center"), (12, 130))
        return surface
コード例 #3
0
 def render_hover(self, game):
     surface = pygame.Surface((280, 186), pygame.SRCALPHA)
     surface.fill((0, 0, 0, 0))
     if self.character is None:
         surface.blit(
             simple.draw_text("", self.font, (255, 255, 255), 280, True),
             (0, 0))
         surface.blit(
             frame.draw_highlight_frame(280,
                                        156, (255, 255, 255),
                                        seed=self.draw_seed), (0, 24))
     else:
         surface.blit(
             simple.draw_text(self.character.name, self.font,
                              (255, 255, 255), 280, True), (0, 0))
         surface.blit(
             frame.draw_highlight_frame(280,
                                        156, (255, 255, 255),
                                        seed=self.draw_seed), (0, 24))
         surface.blit(simple.draw_image(self.character.portrait, 4),
                      (4, 16))
         surface.blit(simple.draw_image("image/ui/player_bar.png", 4),
                      (132, 32))
         surface.blit(simple.draw_image("image/ui/player_bar.png", 4),
                      (132, 52))
     return surface
コード例 #4
0
ファイル: animation_system.py プロジェクト: SodaCookie/rpeg
    def dispatch(self, message, game):
        """Function for determining what action to call depending on the
        message"""
        width, height = pygame.display.get_surface().get_size()
        if message.mtype == "message":
            # Set hovered object from a slot
            text, colour = message.args
            surface = draw_text(text, self.message_font, colour)
            animation = anime.Anime(surface, width // 2, 500)
            animation.set_filter('y', anime.filter.linear, 2)
            animation.set_filter('opacity', anime.filter.linear, 5)
            animation.y = 400
            animation.opacity = 0
            self.animations.append(animation)
        elif message.mtype == "battle-message":
            target, text, colour= message.args
            x = random.randint(-20, 20)
            y = random.randint(-20, 20)
            if target in game.party.players:
                index = game.party.players.index(target)
                x = x + 156 + 312 * index
                y = y + height - 100
            elif game.encounter and target in game.encounter:
                index = game.encounter.index(target)
                num_enemies = len(game.encounter)
                x = x + width // (num_enemies + 1) * (index + 1)
                y = y + 200

            surface = draw_text(text, self.battle_font, colour)
            animation = anime.Anime(surface, x, y)
            animation.set_filter('y', anime.filter.linear, 1)
            animation.set_filter('opacity', anime.filter.linear, 4)
            animation.y = y - 100
            animation.opacity = 0
            self.animations.append(animation)
コード例 #5
0
ファイル: charactercard.py プロジェクト: SodaCookie/rpeg
 def render_hover(self, game):
     surface = pygame.Surface((280, 186), pygame.SRCALPHA)
     surface.fill((0, 0, 0, 0))
     if self.character is None:
         surface.blit(simple.draw_text("", self.font, (255, 255, 255), 280,
             True), (0, 0))
         surface.blit(frame.draw_highlight_frame(280, 156,
             (255, 255, 255), seed=self.draw_seed), (0, 24))
     else:
         surface.blit(simple.draw_text(self.character.name, self.font,
             (255, 255, 255), 280, True), (0, 0))
         surface.blit(frame.draw_highlight_frame(280, 156,
             (255, 255, 255), seed=self.draw_seed), (0, 24))
         surface.blit(simple.draw_image(self.character.portrait, 4),
             (4, 16))
         surface.blit(simple.draw_image("image/ui/player_bar.png", 4),
             (132, 32))
         surface.blit(simple.draw_image("image/ui/player_bar.png", 4),
             (132, 52))
     return surface
コード例 #6
0
ファイル: movecard.py プロジェクト: SodaCookie/rpeg
    def render_clicked(self, game):
        surface = frame.draw_highlight_frame(self.width, self.height,
            highlight=(0, 255, 0), seed=self.draw_seed)
        if self.move is None:
            return surface

        # Draw the move iself.mage
        icon_filename = self.move.icon
        if icon_filename:
            icon_surface = simple.draw_image(icon_filename, 6)
        else:
            icon_surface = simple.draw_image(ItemSlot.DEFAULTICON, 6)

        surface.blit(icon_surface,
            (self.width // 2 - icon_surface.get_width() // 2, 12))

        # Text elements
        surface.blit(simple.draw_text(self.move.name.title(), self.title_font,
            (0, 255, 0), self.width - 24, justify="center"), (12, 100))
        surface.blit(simple.draw_text(self.move.description, self.font,
            (0, 255, 0), self.width - 24, justify="center"), (12, 130))
        return surface
コード例 #7
0
ファイル: text.py プロジェクト: blindseth/rpeg
 def __init__(self, name, x, y, text, size, colour=pygame.Color("white"),
         width=None, justify="left"):
     self.font = pygame.font.Font("assets/fonts/VT323-Regular.ttf",
         size)
     surface = draw_text(text, self.font, colour,
         width, True, justify)
     super().__init__(name, x, y, surface)
     self.text = text
     self.size = size
     self.dirty = False
     self.colour = colour
     self.width = width
     self.justify = justify
コード例 #8
0
ファイル: monstercard.py プロジェクト: SodaCookie/rpeg
 def render_hover(self, game):
     surface = None
     monster_image = None
     if self.monster:
         if self.monster.graphic.get("hover"):
             try:
                 filename = self.monster.graphic.get("hover")
                 monster_image = simple.draw_image(filename, 4)
             except pygame.error:
                 monster_image = simple.draw_rect(240, 80, (255, 255, 0))
                 logging.warning("Could not load: " + filename)
         else:
             monster_image = simple.draw_rect(240, 80, (255, 255, 0))
         surface = pygame.Surface((monster_image.get_width(),
             monster_image.get_height() + 30), pygame.SRCALPHA)
         surface.fill((0, 0, 0, 0))
         surface.blit(monster_image, (0, 30))
         surface.blit(simple.draw_text(self.monster.name, self.font,
             (255, 255, 0), surface.get_width(), justify="center"),
             (0, 0))
     return surface
コード例 #9
0
ファイル: monstercard.py プロジェクト: blindseth/rpeg
 def render_hover(self, game):
     surface = None
     monster_image = None
     if self.monster:
         if self.monster.graphic.get("hover"):
             try:
                 filename = self.monster.graphic.get("hover")
                 monster_image = simple.draw_image(filename, 4)
             except pygame.error:
                 monster_image = simple.draw_rect(240, 80, (255, 255, 0))
                 logging.warning("Could not load: " + filename)
         else:
             monster_image = simple.draw_rect(240, 80, (255, 255, 0))
         surface = pygame.Surface(
             (monster_image.get_width(), monster_image.get_height() + 30),
             pygame.SRCALPHA)
         surface.fill((0, 0, 0, 0))
         surface.blit(monster_image, (0, 30))
         surface.blit(
             simple.draw_text(self.monster.name,
                              self.font, (255, 255, 0),
                              surface.get_width(),
                              justify="center"), (0, 0))
     return surface
コード例 #10
0
ファイル: text.py プロジェクト: blindseth/rpeg
 def refresh(self, game):
     self.set_surface(draw_text(self.text, self.font, self.colour,
         self.width, True, self.justify))