Пример #1
0
    def play(self, wi):
        import time
        while self.playing:
            direction = self.getdirection(wi)
            if direction == "R":
                self.right()
                time.sleep(0.23)
            elif direction == "L":
                self.left()
                time.sleep(0.3)
            elif direction == "U":
                self.up()
                time.sleep(0.3)
            elif direction == "D":
                self.down()
                time.sleep(0.3)
            if self.checkboard():
                self.playing = False
                print "You win"

		text, textwidth = self.textHandler.make_text("YOU WIN!", 16,1, color="00ff00")
                engine =matrixHandler.MatrixEngine(text)

                for i in range(textwidth+16):
	            engine.shift_left()
                    matrix = engine.get_matrix(cycle=True, cycle_size_col = textwidth+16)
                    sp.set_panel_memory_from_matrix(matrix)

		return
                for _ in range(5):
                    sp.set_panel_color("003000")
                    time.sleep(1)
                    sp.panel_clear()
                    time.sleep(1)
Пример #2
0
def showtext( inputtext, inputcolor="0000ff", times=1):
    for _ in range(times):
        text, textwidth = textHandler.make_text(inputtext, 16,1, color=inputcolor)
        engine =matrixHandler.MatrixEngine(text)
    
        for i in range(textwidth+16):
            engine.shift_left()
            matrix = engine.get_matrix(cycle=True, cycle_size_col = textwidth+16)
            sp.set_panel_memory_from_matrix(matrix)
Пример #3
0
    def checkforlost(self):
        self.oldboard = copy.deepcopy(self.board)
        self.shiftleft()
        self.leftcount()
        if self.board == self.oldboard:
            #cannot move left
            self.shiftright()
            self.rightcount()
            if self.board == self.oldboard:
                #cannot move right
                self.shiftup()
                self.upcount()
                if self.board == self.oldboard:
                    #cannot move up
                    self.shiftdown()
                    self.downcount()
                    if self.board == self.oldboard:
                        #cannot move down
                        #you lose!
                        self.playing = False
                        print "Game over"
                        text, textwidth = self.textHandler.make_text(
                            "GAME OVER!", 16, 1, color="ff0000")
                        engine = matrixHandler.MatrixEngine(text)

                        for i in range(textwidth + 16):
                            engine.shift_left()
                            matrix = engine.get_matrix(
                                cycle=True, cycle_size_col=textwidth + 16)
                            sp.set_panel_memory_from_matrix(matrix)

                        return
                        if self.paneldisplay:
                            for _ in range(5):
                                sp.set_panel_color("300000")
                                time.sleep(1)
                                sp.panel_clear()
                                time.sleep(1)

                    else:
                        self.board = self.oldboard
                else:
                    self.board = self.oldboard
            else:
                self.board = self.oldboard
        else:
            self.board = self.oldboard