Beispiel #1
0
    def render(self, stdscr):
        WHITE = colors.get("white")
        RED   = colors.get("red")

        (X,Y) = true_terminal_size() # <---- TODO:  ok?

        layers.add_border(self.layer, color=WHITE)
        self.layer.setrange(0, 0, "<quit_main>", color=WHITE)
        self.layer.setrange(1, 1, "Quit? (Y/N)", color=RED)
        layers.render_to(self.layer, stdscr, int(X//2.7), int(Y//2.7))
Beispiel #2
0
def render_grid(visible, ppos, layer, nodes, spacing=2):

    (px,py) = ppos

    (w,h) = layer.size()

    for row in frame_coords_2d(w, h, ppos):

        for (x,y) in row:

            (abs_x, abs_y) = xy_to_screen( (x,y), (px,py), w, h, spacing=spacing )

            if not (x, y) in nodes:
                layer.set(abs_x, abs_y, BORDER_BLOCK, color=colors.get("white"))
                # pass
            elif not (x-px, y-py) in visible:
                # TODO: what does this do?
                # X/Y are REAL coords (non-relative)
                # so to check for visibility, we have to relativize them
                pass
            else:
                try:
                    nodes[(x,y)].render(layer, abs_x, abs_y)
                except KeyError:
                    pass # node out of bounds
Beispiel #3
0
    def render(self, layer, x, y):

        # base stuff
        char = self.appearance if self.appearance else Node2D.ERROR
        color = self.color

        # object stuff
        # TODO: NOTE: this forces objects to have an appearance!
        if self.objects:
            t = time.time()  # TODO:  just save one value to the class.

            if abs(t - self._object_render_last_tick) > self._object_render_threshold:
                self._object_render_last_tick = t
                self._object_render_index += 1

            self._object_render_index %= len(self.objects)

            obj = self.objects[self._object_render_index]
            char = obj.appearance
            color = obj.color

        # gas/smoke stuff
        # ...

        color = colors.get(color)
        if self.reverse_video:
            color = color | curses.A_REVERSE  # BITMASK!!!

        # actual settings
        layer.set(x, y, char.encode(CODE), color=color)
Beispiel #4
0
    def render_GUI(self):
        if self.window_too_small():
            return

        white = colors.get("white")

        layers.add_border(layers.get("main"), color=white)
        layers.get("main").setrange(0,0, "<main>", color=white)

        layers.get("gameworld").setrange(0, 0, "<gameworld>", color=white)

        layers.add_border(layers.get("gameframe"), color=white)
        layers.get("gameframe").setrange(0, 0, "<gameframe>", color=white)

        self.stats.render()
        layers.add_border(layers.get("stats"), color=white)
        layers.get("stats").setrange(0, 0, "<stats>", color=white)

        layers.add_border(layers.get("player"), color=white)
        layers.get("player").setrange(0, 0, "<player>", color=white)
        layers.get("player").setlines(5, 2, BODY, color=white)

        layers.add_border(layers.get("news"), color=white)
        layers.get("news").setrange(0, 0, "<news>", color=white)
        for (y, news) in enumerate(NEWS.latest(3), 1):
            layers.get("news").setrange(1, y, news, color=white)
Beispiel #5
0
    def render_too_small(self):
        MAIN = layers.LayerManager.get("main")
        MAIN.reset_recursive() # TODO: <---

        for (y,row) in enumerate(TOO_SMALL_MSG):
            for (x,c) in enumerate(row):
                MAIN.set(x, y, c, color=colors.get("white"))
Beispiel #6
0
    def render_player(self):
        layer = layers.LayerManager.get("gameworld")

        p = self.player.position()
        # say('player is at {} {}'.format(*p))
        if (0,0) in self.visible:
            (fx,fy) = grid2d.xy_to_screen(p, p, *layer.size())
            # say('player set {} {}'.format(fx, fy))
            layer.set(fx, fy, 'P', color=colors.get("yellow"))
Beispiel #7
0
 def render(self):
     self._layer.reset()
     self._layer.setrange(0, 1, "gameticks: {}".format(self._gameticks), colors.get("white"))