コード例 #1
0
ファイル: master.py プロジェクト: halcat0x15a/matrix
# -*- coding: utf-8 -*-

import time
import threading
import feedparser
from subprocess import call
from image import Matrix
from news import News
from tetris import Tetris
import joystick

if __name__ == '__main__':
    matrix = Matrix(1, 1)
    (js, queue) = joystick.queue('/dev/input/js0')
    js.daemon = True
    js.start()
    app = News(matrix, queue)
    while True:
        if not app.run():
            if isinstance(app, News):
                app = Tetris(matrix, 0, queue)
            else:
                app = News(matrix, queue)
        time.sleep(1 / 20)
コード例 #2
0
ファイル: tetris.py プロジェクト: halcat0x15a/matrix
        if self.counter < LEVEL - self.score / 4:
            self.counter += 1
        else:
            if self.current.move(0, 1).check(self.display):
                (self.display, n) = clear(self.current.fix(self.display), self.width, self.height)
                self.score += n
                self.current = None
            else:
                self.current = self.current.move(0, 1)
            self.counter = 0
        show = functools.partial(show_vertical, self.pos - 1) if self.pos else show_horizontal
        self.matrix.vsync(show(self.matrix, self.matrix.create_canvas(), self.current.fix(self.display) if self.current else self.display, self.width, self.height))
        return True

if __name__ == '__main__' and False:
    (js0, queue0) = joystick.queue('/dev/input/js0')
    js0.daemon = True
    a = Tetris(1, queue0)
    (js1, queue1) = joystick.queue('/dev/input/js1')
    b = Tetris(3, queue1)
    js0.start()
    js1.start()
    canvas = matrix.matrix.CreateFrameCanvas()
    clock = pygame.time.Clock()
    playing = True
    while playing:
        clock.tick(10)
        playing = a.run() and b.run()
        canvas.Clear()
        canvas = a.show(canvas)
        canvas = b.show(canvas)