示例#1
0
    def __init__(self, GAME, floorConfig=None, loop=True, cartridgeReader=False, init=True):
        self.cartridgeReader = cartridgeReader
        self.loop = loop
        self.wait = time.sleep
        if floorConfig is None:
            conf = LSFloorConfig()
            conf.selectConfig()
        else:
            conf = LSFloorConfig(floorConfig)
        if conf.containsVirtual() is True:
            self.REAL_FLOOR = False
        else:
            self.REAL_FLOOR = True

        self.audio = LSAudio(initSound=init)
        self.display = LSDisplay(conf=conf, eventCallback = self.handleTileStepEvent, initScreen=init)

        self.ROWS = conf.rows
        self.COLUMNS = conf.cols
        os.system('cls' if os.name == 'nt' else 'clear')
        print("Board size is {:d}x{:d}".format(self.ROWS, self.COLUMNS))
            
        self.GAME = GAME
        self.moves = []
        self.sensorMatrix = defaultdict(lambda: defaultdict(int))
        self.currentGame = None
        self.newGame(self.GAME)

        #these are for bookkeeping
        self.frames = 0
        self.frameRenderTime = 0
        
        # This lock prevents handleTileStepEvent() from being run by polling loops before init is complete
        self.initLock.set()
    def __init__(self, rows=None, cols=None, conf=None, eventCallback=None, initScreen=True):
        if conf is None:
            if rows is None or cols is None:
                conf = LSFloorConfig()
                conf.selectConfig()
            else:
                conf = LSFloorConfig(rows=rows, cols=cols)
                conf.makeVirtual()

        self.floor = LSFloor(conf, eventCallback = eventCallback)

        try:
            self.floor.register(LSPygameFloor)      # For now it's the only emulator we have
        except BadEmulator:
            self.floor.register(LSASCIIFloor)

        self.rows = conf.rows
        self.cols = conf.cols
        self.lastTileSetTimestamp = time.time()

        if initScreen is True:
            self.splash()
            wait(3)
            self.clearAll()