コード例 #1
0
    def __init__(self, columns=COLUMNS, rows=ROWS, demo=False,
                 fadeColor=(100, 100, 100)):
        self.tileBatch = pyglet.graphics.Batch()
        self.tokenBatch = pyglet.graphics.Batch()

        self.tiles = []
        self.tokens = []
        self.people = []

        self.playerBoxes = []

        self.dragTile = False

        self.moving = False
        self.movingTiles = []

        self.columns = columns
        self.rows = rows

        self.ourTurn = False

        # make the colour dimmer if we're not running in a real game
        self.started = False
        self.demo = demo
        self.color = (255, 255, 255)
        self.fadeColor = fadeColor

        self.settings = settings.GameSettings()

        # XXX - fix me with something dynamic

        offset_x = OFFSET_X
        if columns == 7:
            offset_x = BOARD_OFFSET_X

        offset_y = OFFSET_Y
        if rows == 7:
            offset_y = BOARD_OFFSET_Y

        for y in range(rows):
            for x in range(columns):
                self.tiles.append(Tile(x * 81 + offset_x,
                                         768 - (y * 81) - offset_y,
                                         x, y,
                                         color=self.color,
                                         tileType=random.randint(1, 3),
                                         tileRotation=random.randint(0, 3),
                                         batch=self.tileBatch))


        self.floatingTile = Tile(-100, -100, -1, -1,
                                 color=self.color,
                                 tileType=random.randint(1, 3),
                                 tileRotation=random.randint(0, 3),
                                 batch=self.tileBatch)

        events.addListener(self)

        pyglet.clock.schedule(self.update)
コード例 #2
0
ファイル: network.py プロジェクト: pdevine/happytown-python
    def __init__(self,
                 host='localhost',
                 port=server.port,
                 nick='foobar',
                 blocking=False):

        ClientSocketHandler.__init__(self, blocking=blocking)
        self.sock.setblocking(int(blocking))

        self.playerNumber = 0

        events.addListener(self)

        self.connect(host, port)
        self.setNick(nick)

        self.settings.board = board.Board()
        self.startLocation = (-1, -1)