コード例 #1
0
ファイル: new_character.py プロジェクト: gragas/fph
def update_race_labels():

    global race_name, race_description, race_icon
    global race_cons_mod, race_endu_mod, race_pneu_mod
    global race_resi_mod, race_reso_mod, race_prov_mod
    
    global label_race_description_value
    global label_race_cons_mod_value, label_race_endu_mod_value, label_race_pneu_mod_value
    global label_race_resi_mod_value, label_race_reso_mod_value, label_race_prov_mod_value

    if not storage.races:
        race_description = "None"
        race_icon = utils.empty_surface( (0, 0) )
        race_cons_mod = "None"
        race_endu_mod = "None"
        race_pneu_mod = "None"
        race_resi_mod = "None"
        race_reso_mod = "None"
        race_prov_mod = "None"
    else:
        race_description = storage.races[race_name].description
        try:
            race_icon = pygame.image.load(
                os.path.join(
                    'data','races','icons',storage.races[race_name].icon_filename
                )
            ).convert_alpha()
        except:
            race_icon = utils.empty_surface( (0, 0) )
        race_cons_mod = str(storage.races[race_name].cons_mod)
        race_endu_mod = str(storage.races[race_name].endu_mod)
        race_pneu_mod = str(storage.races[race_name].pneu_mod)
        race_resi_mod = str(storage.races[race_name].resi_mod)
        race_reso_mod = str(storage.races[race_name].reso_mod)
        race_prov_mod = str(storage.races[race_name].prov_mod)
        for n in ("cons", "endu", "pneu", "resi", "reso", "prov",):
            if int(globals()["race_" + n + "_mod"]) > 0:
                globals()["race_" + n + "_mod"] = "+" + globals()["race_" + n + "_mod"]

    label_race_description_value.text = race_description
    label_race_description_value.render()
    label_race_cons_mod_value.text = race_cons_mod
    label_race_cons_mod_value.render()
    label_race_endu_mod_value.text = race_endu_mod
    label_race_endu_mod_value.render()
    label_race_pneu_mod_value.text = race_pneu_mod
    label_race_pneu_mod_value.render()
    label_race_resi_mod_value.text = race_resi_mod
    label_race_resi_mod_value.render()
    label_race_reso_mod_value.text = race_reso_mod
    label_race_reso_mod_value.render()
    label_race_prov_mod_value.text = race_prov_mod
    label_race_prov_mod_value.render()
コード例 #2
0
ファイル: camera.py プロジェクト: gragas/fph
def init():
    
    global TILE_SIZE, SURFACE_SIZE
    global SW_IN_TILES, SH_IN_TILES
    global BOARDER_SIZE, BLIT_POSITION

    TILE_SIZE = 32
    BOARDER_SIZE = 10
    NUM_TILES_SW = utils.SCREEN_W // TILE_SIZE
    NUM_TILES_SH = utils.SCREEN_H // TILE_SIZE
    if not utils.SCREEN_W % TILE_SIZE == 0:
        NUM_TILES_SW += 1
    if not utils.SCREEN_H % TILE_SIZE == 0:
        NUM_TILES_SH += 1
    SURFACE_SIZE = (
        (NUM_TILES_SW + 2 * BOARDER_SIZE) * TILE_SIZE,
        (NUM_TILES_SH + 2 * BOARDER_SIZE) * TILE_SIZE,
        )
    BLIT_POSITION = (-BOARDER_SIZE * TILE_SIZE, -BOARDER_SIZE * TILE_SIZE)
    
    global zero, one, two
    
    zero = utils.empty_surface( SURFACE_SIZE )
    one = utils.empty_surface( SURFACE_SIZE )
    two = utils.empty_surface( SURFACE_SIZE )

    global LOCK_TO_PLAYER
    LOCK_TO_PLAYER = True

    # Fill zero with randomly colored tiles
    for y in range(
            0,
            SURFACE_SIZE[1] + TILE_SIZE,
            TILE_SIZE
    ):
        for x in range(
                0,
                SURFACE_SIZE[0] + TILE_SIZE,
                TILE_SIZE
        ):
            pygame.draw.rect( zero,
                              (
                                  int(random() * 50) + 50,
                                  int(random() * 50) + 150,
                                  int(random() * 50) + 50,
                                  255
                              ),
                              ( x, y, TILE_SIZE, TILE_SIZE )
                          )
コード例 #3
0
ファイル: levels.py プロジェクト: GlassLlamas/heistboys
 def render(self):
     if not hasattr(self, "surface"):
         self.surface = utils.empty_surface(self.backgroundImage.get_size())
     self.surface.blit(self.backgroundImage, (0, 0))
     for (pos, surface) in self.nonblockingObjects:
         self.surface.blit(surface, pos)
     for (pos, rect, surface, drops) in self.destructibleObjects:
         self.surface.blit(surface, pos)
     for (pos, rect, surface) in self.blockingObjects:
         self.surface.blit(surface, pos)
コード例 #4
0
ファイル: inventory.py プロジェクト: GlassLlamas/heistboys
 def render(self):
     if not hasattr(Inventory, "backgroundSprite"):
         Inventory.loadSprites()
     self.surface = utils.empty_surface((88, 408))
     self.surface.blit(Inventory.backgroundSprite, (0, 0))
     for index, element in enumerate(self.items.items()):
         itemName, itemStack = element
         itemStack.render()
         pos = (8 + (index % 2) * 40, 8 + (index // 2) * 40)
         itemStack.blit(self.surface, pos)
コード例 #5
0
ファイル: slider.py プロジェクト: mazinbokhari/buffalo
    def __init__(self, pos, keybindings):
        self.pos = pos
        self.up, self.down = keybindings

        x, y = self.pos
        self.fPos = float(x), float(y)
        
        self.yv = 0.0
        self.surface = utils.empty_surface( (Slider.WIDTH, Slider.HEIGHT) )
        self.surface.fill( Slider.COLOR )
コード例 #6
0
ファイル: tray.py プロジェクト: gragas/buffalo
 def render(self):
     self.surface = utils.empty_surface(self.size)
     self.surface.fill(self.color)
     for label in self.labels:
         label.blit(self.surface)
     for button in self.buttons:
         button.blit(self.surface)
     for option in self.options:
         option.blit(self.surface)
     for inpt in self.inputs:
         inpt.blit(self.surface)
コード例 #7
0
ファイル: square.py プロジェクト: gragas/buffalo
    def __init__(self, pos):
        self.pos = pos
        x, y = self.pos
        self.fPos = float(x), float(y)

        rxv, ryv = random(), random()
        minimum, mult = 3.0, 8.0
        while abs(rxv) < minimum:
            rxv = (-mult / 2) + mult * random()
        while abs(ryv) < minimum:
            ryv = (-mult / 2) + mult * random()    

        self.xv, self.yv = rxv, ryv
        self.surface = utils.empty_surface( (Square.WIDTH, Square.HEIGHT) )
        self.surface.fill( Square.COLOR )
コード例 #8
0
ファイル: _map.py プロジェクト: gragas/simplekingdomsim
 def __init__(self, size=(60, 34),
              i_temp=None, max_d_temp=5, off_d_temp=0,
              i_hum=None, max_d_hum=5, off_d_hum=0,
              i_alt=None, max_d_alt=5, off_d_alt=0,
              wood_density=10, stone_density=0.25):
     # size is a 2-tuple representing the width
     # and height of the map in tiles
     self.size = self.width, self.height = size
     # i_* is the initial value of attribute *
     # max_d_* is the maximum delta of attribute *
     self.i_temp = i_temp if i_temp is not None else random.randint(50, 90)
     self.max_d_temp = max_d_temp
     self.off_d_temp = off_d_temp
     self.temp_arr = functools.reduce(
         lambda x, y: x + y,
         [[i + self.off_d_temp]*(self.max_d_temp - i) for i in range(self.max_d_temp)]
     ) # e.g., [0, 0, 0, 0, 1, 1, 1, 2, 2, 3]
     self.temp_arr = self.temp_arr + [-i for i in self.temp_arr]
     self.i_hum = i_hum if i_hum is not None else random.randint(10, 50)
     self.max_d_hum = max_d_hum
     self.off_d_hum = off_d_hum
     self.hum_arr = functools.reduce(
         lambda x, y: x + y,
         [[i + self.off_d_hum]*(self.max_d_hum - i) for i in range(self.max_d_hum)]
     ) # e.g., [0, 0, 0, 0, 1, 1, 1, 2, 2, 3]
     self.hum_arr = self.hum_arr + [-i for i in self.hum_arr]
     self.i_alt = i_alt if i_alt is not None else random.randint(0, 200)
     self.max_d_alt = max_d_alt
     self.off_d_alt = off_d_alt
     self.alt_arr = functools.reduce(
         lambda x, y: x + y,
         [[i + self.off_d_alt]*(self.max_d_alt - i) for i in range(self.max_d_alt)]
     ) # e.g., [0, 0, 0, 0, 1, 1, 1, 2, 2, 3]
     self.alt_arr = self.alt_arr + [-i for i in self.alt_arr]
     self.tiles = dict()
     self.surface = utils.empty_surface((self.width * Map.TILE_SIZE, self.height * Map.TILE_SIZE))
     self.wood_density = wood_density
     self.stone_density = stone_density
     self.water_tiles = set()
     self.generate_map()
     self.render()
コード例 #9
0
ファイル: item.py プロジェクト: GlassLlamas/heistboys
 def render(self):
     self.surface = utils.empty_surface(self.item.size)
     self.surface.blit(self.item.surface, (0, 0))
     if self.item.inInventory:
         self.quantityLabel = Label((0, 0), str(self.quantity))
         self.quantityLabel.blit(self.surface)