View difference between Paste ID: c8kbqc4w and vJfUzUgX
SHOW: | | - or go back to the newest paste.
1
def draw():
2
    draw = tcod.console_put_char_ex
3
    w, h = screen_size()
4
    for x in range(w):
5
        for y in range(h):
6
            c, fg, bg = yield cartesian.Point(x, y)
7
            fg, bg = (getattr(tcod, str(fg), tcod.white),
8
                      getattr(tcod, str(bg), tcod.black))
9
            draw(None, x, y, c, fg, bg)
10-
    yield None
10+
11
# Outside the generator
12
def render(self):
13
    draw = render.draw()
14
    point = draw.send(None)
15
    world = self.world
16
    while True:
17
        world_coord = self.camera.position + point
18
        tile_data = ('.', 'red', 'blue')
19
        if world_coord in world:
20
            tile = world[world_coord]
21
            tile_data = (tile.repr, tile.fg, tile.bg)
22
        try:
23
            point = draw.send(tile_data)
24
        except StopIteration:
25
            break