Esempio n. 1
7
def waitForInput(key = None):
    c = -1
    if key == None:
        while str(c)=="-1":
            c = gfx.scr().getch()
        return c
    else:
        while str(c) != str(key):
            c = gfx.scr().getch()
            if c!=-1:
                log.log(str(c))
Esempio n. 2
7
    def play(self):
        log.log("Launching the game")
        gfx.start()
        self.running = True
        self.screen = gfx.scr()
        self.gui.init()
        self.gui.owner = self.world.player

        self.loop()
        self.quit()
Esempio n. 3
6
 def draw(self):
     gfx.clear()
     if self.moving:
         self.fov = self.raycast(10, 3)
         self.max_y = gfx.scr().getmaxyx()[0]
         self.max_x = int(0.60*gfx.scr().getmaxyx()[1])
         for e in self.entities:
             e.randomMove(self)
         self.moving = False
     for y in range(self.min_y, self.max_y):
         for x in range(self.min_x, self.max_x):
             if (self.player.x, self.player.y) == (x, y):
                 gfx.draw(y, x, "☺", "b")
             elif y>=0 and x>=0 and y<len(self.fov) and x<len(self.fov[0]):
                 if self.fov[y][x] == 1:
                     empty = True
                     for e in self.entities:
                         if (x, y) == (e.x, e.y):
                             empty = False
                             gfx.draw(y, x, e.char, "r")
                     for c in self.chests:
                         if (c.x, c.y) == (x, y):
                             empty = False
                             gfx.draw(y, x, "÷", "c")
                     if empty:
                             c = self.map[y][x]
                             gfx.draw(y, x, c, "g" if c == "." else "y")
                     self.seen[y][x] = 1
                 elif self.seen[y][x]:
                     empty = True
                     for c in self.chests:
                         if (c.x, c.y) == (x, y):
                             empty = False
                             gfx.draw(y, x, "÷", "dc")
                     if empty:
                         c = self.map[y][x]
                         gfx.draw(y, x, c, "dg" if c == "." else "dy")
Esempio n. 4
1
 def init(self):
     self.max_x = gfx.scr().getmaxyx()[1]-1
     self.max_y = gfx.scr().getmaxyx()[0]-1
     self.x = int(0.60*self.max_x)
     self.y = 0