コード例 #1
0
    def __init__(self, type):
        self.type = type
        self.cost = Settings.tower_costs[type]

        self.images = {
            f'{direction}': pygame.image.load(f'images/tower_tiles/{type}_{direction}.png')
            for direction in 'NESW'
        }

        self.font = pygame.font.SysFont('Arial', 24)
        self.cost_text_active = self.font.render(f'({self.cost})', True, pygame.Color('yellow'))
        self.cost_text_inactive = self.font.render(f'({self.cost})', True, pygame.Color('grey'))
        self.image_menu_active = pygame.image.load(f'images/tower_tiles/{type}_menu.png')
        self.image_menu_inactive = pygame.image.load(f'images/tower_tiles/{type}_menu_grey.png')
        self.image_heart = pygame.image.load(f'images/misc/heart_{type}.png')

        self.menu_location = utils.cell_to_isometric(Settings.menu_tower_locations[type]) + \
            Vector(0, Settings.tile_height - self.image_menu_active.get_rect().height)

        self.cost_location = utils.cell_to_isometric(
            Settings.menu_tower_locations[type] + Settings.tower_cost_offset
        )

        self.offset = Vector(0, Settings.tile_height - self.images['E'].get_rect().height)
コード例 #2
0
 def set_location(self):
     self.location = utils.cell_to_isometric(
         self.grid_location) + self.abstract_tile.offset
コード例 #3
0
 def set_location(self):
     offset, direction = self.offset_and_direction_on_tile()
     self.location = utils.cell_to_isometric(self.route[0].grid_location + offset + Vector(0.9, -2.3))
     self.direction = direction
コード例 #4
0
 def show_level_name(self):
     self.canvas.blit(
         self.font.render(self.level_name, True, pygame.Color('white')),
         utils.cell_to_isometric(Settings.level_name_location).as_int_list
     )
コード例 #5
0
 def show_score(self):
     self.canvas.blit(
         self.font.render(f'{self.score}/{Settings.target_score}', True, pygame.Color('white')),
         utils.cell_to_isometric(Settings.score_location).as_int_list
     )
コード例 #6
0
 def show_wealth(self):
     self.canvas.blit(
         self.font.render(f'{self.wealth}', True, pygame.Color('yellow')),
         utils.cell_to_isometric(Settings.wealth_location).as_int_list
     )