Exemplo n.º 1
0
 def main_loop(self):
     self.cursor = BuildCursor(self.ship)
     self.cursor.set_terrain_type(g.E.WALL1)
     
     while True:
         
         for newEvent in pygame.event.get():
             if newEvent.type == pygame.KEYDOWN:
                 unicode = newEvent.unicode
                 key = newEvent.key
                 print(key)
                 if key in [273,274,275,276]:
                     dir = self.cursor.chooseDir(key)
                     self.cursor.move(dir)
                 elif unicode == "<":
                     self.cursor.ascend()  
                 elif unicode == ">":
                     self.cursor.descend()
                 elif key == 13:
                     if self.mode == self.modes.TERRAIN:
                         self.cursor.place_terrain()
                     elif self.mode == self.modes.COMPONENT:
                         self.cursor.place_component()
                     elif self.mode == self.modes.LINK:
                         try:
                             self.cursor.link_component()
                         except:
                             self.console.logNow("No component there")
                 elif unicode == "t":
                     self.change_terrain_type()
                     self.set_mode(self.modes.TERRAIN)
                 elif unicode == "c":
                     self.change_component_type()
                     self.set_mode(self.modes.COMPONENT)
                 elif unicode == "l":
                     self.set_mode(self.modes.LINK)
                     self.logNow("Choose item you would like to link to a control panel")
                 elif unicode == "w":
                     self.save_ship()
                 elif unicode == " ":
                     self.cursor = None
                     return 0
                 elif unicode == "o":
                     self.load_ship()
                 misc.displayMap(self.cursor.xDisp,self.cursor.yDisp,self.cursor.zPos,self.ship)
                 g.SCREEN.blit(self.cursor.tile.image, self.cursor.pos)
                 self.commands_list.display()
                 pygame.display.update()