Exemple #1
0
    def __init__(self, screen, player, foe):
        global hp_bar_textures, base_textures
        hp_bar_textures = get_texture("hpbars")
        base_textures = get_texture("battlebases")
        self.base_selection = 2
        self.active = True
        self.player, self.foe = player, foe
        self.screen_surf = screen
        self.screen_rect = screen.get_rect()

        # Positioning of the visual components
        self.visuals_rect = self.screen_rect.copy()
        self.visuals_rect.height = 144

        self.menu_rect = self.screen_rect.copy()
        self.menu_rect.y = self.visuals_rect.height
        self.menu_rect.height = self.screen_rect.height - self.visuals_rect.height

        self.inFieldFriend = self.player.party[0]
        self.inFieldFoe = self.foe.party[0]
        self.status_bar_friend = StatusBar("friend", self.inFieldFriend)
        self.status_bar_foe = StatusBar("foe", self.inFieldFoe)

        # State will be either one of: "intro", "select", "animation"
        self.state = 'intro'
        self.intro_frame = 0
        self.foe_pos = -50
        self.friend_pos = self.screen_rect.width + 20
        self.bg = Background()
        self.friendSize = pygame.Rect(0, 0, 80, 80)
Exemple #2
0
def getSprite(name, state):
    if state == 'front':
        return get_texture(
            f'main-sprites\\diamond-pearl\\{dex.getIndex(name)}')
    elif state == 'back':
        return get_texture(
            f'main-sprites\\diamond-pearl\\back\\{dex.getIndex(name)}')
    else:
        raise ValueError("Invalid state argument.")
Exemple #3
0
    def __init__(self, pixel_screen):
        self.pixel_screen = pixel_screen
        self.active = False

        # Text box stuff
        self.text_box_textures = get_texture("dialogue box")
        self.current_text_box_texture = pygame.Surface((250, 44),
                                                       pygame.SRCALPHA)
        self.current_text_box_texture.blit(self.text_box_textures, (0, 0),
                                           (1, 1, 250, 44))
        self.rest_text = ""

        # Positioning of the text box
        self.pos_rect = pygame.Rect(0, 0,
                                    self.current_text_box_texture.get_width(),
                                    self.current_text_box_texture.get_height())
        self.pos_rect.centerx = self.pixel_screen.get_width() / 2
        self.pos_rect.bottom = self.pixel_screen.get_height() - 2

        # Positioning of the text in the box
        self.text_rect = self.pos_rect.inflate(-self.pos_rect.width * 0.1,
                                               -self.pos_rect.height * 0.25)
        self.text_rect.move_ip(0, 2)
        self.text_rect.width -= 10
        self.text_top_rect = self.text_rect.copy()
        self.text_top_rect.height = self.text_rect.height // 2
        self.text_bottom_rect = self.text_top_rect.copy().move(
            0, self.text_top_rect.height)
Exemple #4
0
 def __init__(self, currentMap, npcmanager):
     self.pos = Pos(0, 0)
     self.texturemap = get_texture("player-kaori")
     self.textures = {
         'downidle': (0, 0),
         'down1': (32, 0),
         'down2': (64, 0),
         'upidle': (0, 32),
         'up1': (32, 32),
         'up2': (64, 32),
         'rightidle': (0, 64),
         'right1': (32, 64),
         'right2': (64, 64),
         'leftidle': (0, 96),
         'left1': (32, 96),
         'left2': (64, 96),
         'run_down1': (96, 0),
         'run_down2': (128, 0),
         'run_down3': (160, 0),
         'run_up1': (96, 32),
         'run_up2': (128, 32),
         'run_up3': (160, 32),
         'run_right1': (96, 64),
         'run_right2': (128, 64),
         'run_right3': (160, 64),
         'run_left1': (96, 96),
         'run_left2': (128, 96),
         'run_left3': (160, 96),
     }
     self.animations = {
         'idle_north': ['upidle'],
         'idle_east': ['rightidle'],
         'idle_south': ['downidle'],
         'idle_west': ['leftidle'],
         'walk_north': ['up2', 'upidle', 'up1', 'upidle'],
         'walk_east': ['right2', 'rightidle', 'right1', 'rightidle'],
         'walk_south': ['down2', 'downidle', 'down1', 'downidle'],
         'walk_west': ['left2', 'leftidle', 'left1', 'leftidle'],
         'run_north': ['run_up2', 'run_up1', 'run_up3', 'run_up1'],
         'run_east':
         ['run_right2', 'run_right1', 'run_right3', 'run_right1'],
         'run_south': ['run_down2', 'run_down1', 'run_down3', 'run_down1'],
         'run_west': ['run_left2', 'run_left1', 'run_left3', 'run_left1'],
     }
     self.currentStance = 'downidle'
     self.setAnimation('idle_south', 1)
     self.displacement = Pos(0, 0)
     self.remainingDuration = 0
     self.currentMap = currentMap
     self.npcmanager = npcmanager
     self.trainerdata = pkm.Trainer('Player')
     self.trainerdata.party.append(pkm.Pokemon('Charmander'))
     self.trainerdata.party[0].setlevel(4)
     self.moving = False
     self.direction = 'south'
Exemple #5
0
    def __init__(self, pixel_screen):
        self.pixel_screen = pixel_screen
        self.active = False

        # Choose box stuff
        self.box_texture = get_texture("choose box")
        self.selector_texture = get_texture("choose selector")
        self.box_active = False

        # Positioning of the text box
        self.pos_rect = pygame.Rect(0, 0, self.box_texture.get_width(),
                                    self.box_texture.get_height())
        self.pos_rect.centerx = self.pixel_screen.get_width() / 2
        self.pos_rect.bottom = self.pixel_screen.get_height() - 2

        self.box_rect = pygame.Rect(0, 0, self.box_texture.get_width(),
                                    self.box_texture.get_height())
        self.box_rect.bottomright = (self.pixel_screen.get_width(),
                                     self.pixel_screen.get_height())
        self.box_rect.move_ip(-1, -1)

        self.text_rect = self.box_rect.inflate(-self.pos_rect.width * 0.1,
                                               -self.pos_rect.height * 0.25)
        self.text_rect.move_ip(0, 2)
        self.text_rect.width -= 10
        self.topleft_rect = self.text_rect.copy()
        self.topleft_rect.height = self.topleft_rect.height // 2
        self.topleft_rect.width = self.topleft_rect.width // 2
        self.topright_rect = self.topleft_rect.move(self.topleft_rect.width, 0)
        self.bottomleft_rect = self.topleft_rect.move(0,
                                                      self.topleft_rect.height)
        self.bottomright_rect = self.bottomleft_rect.move(
            self.topleft_rect.width, 0)
        self.selector_positions = []
        for rect in [
                self.topleft_rect, self.topright_rect, self.bottomleft_rect,
                self.bottomright_rect
        ]:
            self.selector_positions.append(rect.topleft)
            rect.width -= 8
            rect.move_ip(8, 0)
Exemple #6
0
 def setup(self, npcmanager):
     self.npcmanager = npcmanager
     self.vars = {}
     self.path = [Pos(p) for p in self.path]
     self.abspos = self.path[0]
     self.pos = self.path[0]*16
     self.texturemap = get_texture("npcs\\npcsheet")
     self.textures = {
         'downidle'  : (64,  32),
         'down1'     : (64,  64),
         'down2'     : (64,  96),
         'upidle'    : (0,    0),
         'up1'       : (64,   0),
         'up2'       : (32,  96),
         'rightidle' : (32,   0),
         'right1'    : (32,  32),
         'right2'    : (32,  64),
         'leftidle'  : (0,   64),
         'left1'     : (0,   32),
         'left2'     : (0,   96),
     }
     self.textures = {key: (tex[0]+self.sprite[0]*96, tex[1]+self.sprite[1]*128) for (key, tex) in self.textures.items()}
     self.animations = {
         'idle_north': ['upidle'],
         'idle_east' : ['rightidle'],
         'idle_south': ['downidle'],
         'idle_west' : ['leftidle'],
         'walk_north': ['up2', 'upidle', 'up1', 'upidle'],
         'walk_east' : ['right2', 'rightidle', 'right1', 'rightidle'],
         'walk_south': ['down2', 'downidle', 'down1', 'downidle'],
         'walk_west' : ['left2', 'leftidle', 'left1', 'leftidle'],
     }
     self.currentStance = 'downidle'
     self.setAnimation('idle_south', 1)
     self.displacement = (0, 0)
     self.remainingDuration = 0
     self.moving = False
     self.talking = False
Exemple #7
0
 def __init__(self, time='Day', place='Forest'):
     self.source = get_texture("20102")
     self.time = time
Exemple #8
0
    def get_surface(self):
        self.textures = get_texture("hpbars")
        if self.gender == 'male':
            bg_texture_x = 0
        elif self.gender == 'female':
            bg_texture_x = 120
        else:
            bg_texture_x = 240
        hp_prop = self.pokemon.currentStats['HP'] / self.pokemon.stats['HP']

        # We use ceil because because we want to still show a pixel if the health
        # is reduced to something that would cause the hp bar to disappear if
        # we rounded down.
        hp_texture = pygame.Surface((ceil(hp_prop * 48), 7))
        if hp_prop >= 0.5:
            # Use green texture
            hp_texture_rect = pygame.Rect(0, 85, 48, 7)
        elif hp_prop > 0.25:
            # Use yellow texture
            hp_texture_rect = pygame.Rect(0, 78, 48, 7)
        else:
            # Use red texture
            hp_texture_rect = pygame.Rect(0, 71, 48, 7)
        hp_texture.blit(self.textures, (0, 0), hp_texture_rect)

        nametag = render_text(self.pokemon.custom_name)
        level_tag = render_number(self.pokemon.level)

        if self.pokemon.status:
            status_texture_x = {
                'burned': 0,
                'frozen': 20,
                'poisened': 40,
                'paralyzed': 60,
                'asleep': 80,
            }[self.pokemon.status]
            status_texture = pygame.Surface((20, 7), pygame.SRCALPHA)
            status_texture.blit(self.textures, (0, 0),
                                pygame.Rect(status_texture_x, 102, 20, 7))

        if self.side == 'friend':
            background = pygame.Surface((120, 41), pygame.SRCALPHA)
            background_rect = background.get_rect()
            background.blit(self.textures, (0, 0),
                            background_rect.move(bg_texture_x, 30))

            background.blit(nametag, (13, 3))
            background.blit(level_tag, (94, 8))

            current_hp_tag = render_number(self.pokemon.currentStats['HP'])
            current_hp_tag_rect = current_hp_tag.get_rect()
            current_hp_tag_rect.topright = (87, 28)
            background.blit(current_hp_tag, current_hp_tag_rect)

            max_hp_tag = render_number(self.pokemon.stats['HP'])
            background.blit(max_hp_tag, (94, 28))

            background.blit(hp_texture, (62, 19))

            xp_prop = self.pokemon.XP / self.pokemon.goalXP
            xp_texture = pygame.Surface((xp_prop * 90, 3), pygame.SRCALPHA)
            xp_texture.blit(self.textures, (0, 0),
                            pygame.Rect(0, 92, xp_prop * 90, 3))
            background.blit(xp_texture, (29, 38))

            if self.pokemon.status:
                background.blit(status_texture, (23, 19))

        elif self.side == 'foe':
            background = pygame.Surface((120, 30), pygame.SRCALPHA)
            background_rect = background.get_rect()
            background.blit(self.textures, (0, 0),
                            background_rect.move(bg_texture_x, 0))

            background.blit(nametag, (2, 3))
            background.blit(level_tag, (82, 8))
            background.blit(hp_texture, (50, 19))

            if self.pokemon.status:
                background.blit(status_texture, (13, 19))
        else:
            raise ValueError(
                f"self.side '{self.side}' was not 'friend' or 'foe'.")
        return background
Exemple #9
0
npcmanager = npc.NPCManager()
currentMap = maploader.loadMapObject(mapToLoad)
npcmanager.set_npcs(currentMap)

# Pokemon dex data
dex = pkm.dex.Dex()

player = Player(currentMap, npcmanager)
player.pos = Pos(currentMap.warps[0])

base_resolution = (256, 192)
map_surface = pygame.Surface(base_resolution)
zoom = 1

# Menu vars
menublit = get_texture('menu2')
menuselect = get_texture('menuselect2')
menu = False
menupos = 0
menuframes = 0
menudisp = 0

quickstart = True  # set to true for quick(er) debugging
if not quickstart:
    with open("credits.txt", "r") as file:
        creditscreen = map(lambda line: line.strip(), file.readlines())

    screen.fill((0, 0, 0))
    counter = 0
    f = pygame.font.SysFont("arial", 20)
    h = f.render('test', False, (255, 255, 255)).get_height() + 3