Esempio n. 1
0
class Chase(Game, StageHandler):
    POSITION = Coordinate(0, 0)
    GRID_SIZE = Coordinate(10, 18)
    MAX_PLAYER = 4
    def __init__(self):
        Game.__init__(self)
        StageHandler.__init__(self)
        self._screen = None

    def initialize(self, screen):
        tile_sheet = AsciiTileSheet().initialize('Courier New', 18)
        AsciiTileLocator.provide(tile_sheet)
        StageHandler.initialize()
        TerrainMapHandler.load('data/map.data')
        actor_list = [Actor(player_id) for player_id in range(self.MAX_PLAYER)]
        PlayerHandler.initialize(actor_list)
        status_window = StatusWindow(
                [actor for actor in actor_list],\
                Coordinate(0, 18))
        self._screen = window = GridWindow(screen, self.POSITION, self.GRID_SIZE)
        actors = Actors(actor_list)
        Scene.register_chase_scene(ChaceScene(status_window, actors))
        Scene.register_ranking_scene(RankingScene(actors))
        Scene.change_chase_scene()

    def update(self):
        if Key.ESCAPE in self._keyboard.pressed_keys(): sys.exit()
        Scene.update(self._controllers, self._keyboard)

    def render(self):
        Scene.render(self._screen)
Esempio n. 2
0
 def load(cls, filename):
     f = open(filename, 'r')
     lines = [line.rstrip('\n') for line in f]
     w, h = len(lines[0]), len(lines)
     cls._terrain_map = TerrainMap(w, h)
     for y, line in enumerate(lines):
         for x, glyph in enumerate(line):
             cls.put_terrain(glyph, Coordinate(x, y))
     f.close()
Esempio n. 3
0
 def initialize(self, screen):
     tile_sheet = AsciiTileSheet().initialize('Courier New', 18)
     AsciiTileLocator.provide(tile_sheet)
     StageHandler.initialize()
     TerrainMapHandler.load('data/map.data')
     actor_list = [Actor(player_id) for player_id in range(self.MAX_PLAYER)]
     PlayerHandler.initialize(actor_list)
     status_window = StatusWindow(
             [actor for actor in actor_list],\
             Coordinate(0, 18))
     self._screen = window = GridWindow(screen, self.POSITION, self.GRID_SIZE)
     actors = Actors(actor_list)
     Scene.register_chase_scene(ChaceScene(status_window, actors))
     Scene.register_ranking_scene(RankingScene(actors))
     Scene.change_chase_scene()
Esempio n. 4
0
 def render(self, window):
     x, y = self._position.xy()
     for index, actor in enumerate(self._actors):
         actor.render_status(window, Coordinate(x, index+y))
Esempio n. 5
0
 def walkable_coordinates(self):
     for y, line in enumerate(self._terrain):
         for x, tile in enumerate(line):
             if self._terrain[y][x].is_walkable():
                 yield Coordinate(x, y)
Esempio n. 6
0
 def render(self, screen):
     for y, line in enumerate(self._terrain):
         for x, tile in enumerate(line):
             tile.lender(screen, Coordinate(x, y))
Esempio n. 7
0
 def render(self, screen):
     screen.fill()
     screen.write('Ranking', Coordinate(0, 0), Color.OLIVE)
     self._ranking.render(screen, Coordinate(0, 2))
     screen.write('Press [Start]+[Skill] Key', Coordinate(0, 10),
                  Color.YELLOW)
Esempio n. 8
0
 def render(self, screen):
     screen.fill()
     screen.write('Chaise', Coordinate(0, 0), Color.OLIVE)