コード例 #1
0
ファイル: game.py プロジェクト: piratf/Game_Boxes
    def initAttr(self):
        self.turn = True
        self.hudWidth = HUD["HUD_WIDTH"]
        self.edgeWidth = GAME["EDGE_WIDTH"]

        # 先获取 board 部分的大小,再自适应自己的大小
        self.board = Board((self.hudWidth, self.edgeWidth))
        Div.__init__(self, (self.board.width + self.hudWidth, self.board.height + self.edgeWidth * 2))
        # 根据窗口高度设置 HUD 高度
        self.hud = Hud((0, self.height), (0, 0))
        self.hud.setMark(self.turn)
        self.board.setTurn(self.turn)
        self.gameID = 0
        self.order = None
コード例 #2
0
    def initAttr(self):
        self.turn = True
        self.hudWidth = HUD["HUD_WIDTH"]
        self.edgeWidth = GAME["EDGE_WIDTH"]

        # 先获取 board 部分的大小,再自适应自己的大小
        self.board = Board((self.hudWidth, self.edgeWidth))
        Div.__init__(self, (self.board.width + self.hudWidth,
                            self.board.height + self.edgeWidth * 2))
        # 根据窗口高度设置 HUD 高度
        self.hud = Hud((0, self.height), (0, 0))
        self.hud.setMark(self.turn)
        self.board.setTurn(self.turn)
        self.gameID = 0
        self.order = None
コード例 #3
0
 def __new__(self):
     return Div(children=['hello', Div(children=['world'])])
コード例 #4
0
ファイル: setLevel.py プロジェクト: piratf/Game_Boxes
 def __init__(self, width, height):
     # super(SetLevel, self).__init__()
     Div.__init__(self, (width, height))
     self.initAttr(width, height)
コード例 #5
0
#!/usr/bin/env python3
# vim: sta:et:sw=2:ts=2:sts=2

from div import Div
from lib import *

if __name__ == "__main__":
    seed(1)
    n = 10000
    d = Div([r() * 0.05
             for _ in range(n)] + [0.2 + r() * 0.05 for _ in range(n)] +
            [0.4 + r() * 0.05
             for _ in range(n)] + [0.6 + r() * 0.05 for _ in range(n)] +
            [0.8 + r() * 0.05 for _ in range(n)])

    for x in d.ranges:
        print("! %5s   %6.4f    %6.4f" % (x.n, x.lo, x.hi))
    print(d.b4.sd(), d.gain)

    print("")
    #  0                   1
    #  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
    d = Div([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2])
    for x in d.ranges:
        print("! %5s   %6.4f    %6.4f" % (x.n, x.lo, x.hi))
    print(d.b4.sd(), d.gain)

print("")
#  0                   1
#  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
d = Div(
コード例 #6
0
ファイル: background.py プロジェクト: piratf/Game_Boxes
# -*- coding: utf-8 -*
# Filename: backGround.py

__author__ = "Piratf"

from div import Div
import pygame


class Background(Div, object):
    """draw background"""

    def __init__(self, (width, height), (x, y)=(0, 0)):
        # super(Background, self).__init__()
        Div.__init__(self, (width, height), (x, y))
        self.panel = pygame.Surface((self.width, self.height), depth=32)

    def setColor(self, color):
        if isinstance(color, pygame.Surface):
            self.panel = color
        else:
            self.panel.fill(color)

    def draw(self, screen):
        screen.blit(self.panel, (self.x, self.y))
コード例 #7
0
 def __init__(self, width, height):
     # super(SetLevel, self).__init__()
     Div.__init__(self, (width, height))
     self.initAttr(width, height)
コード例 #8
0
ファイル: background.py プロジェクト: zhy0313/Game_Boxes
# -*- coding: utf-8 -*
# Filename: backGround.py

__author__ = 'Piratf'

from div import Div
import pygame


class Background(Div, object):
    """draw background"""
    def __init__(self, (width, height), (x, y)=(0, 0)):
        # super(Background, self).__init__()
        Div.__init__(self, (width, height), (x, y))
        self.panel = pygame.Surface((self.width, self.height), depth=32)

    def setColor(self, color):
        if isinstance(color, pygame.Surface):
            self.panel = color
        else:
            self.panel.fill(color)

    def draw(self, screen):
        screen.blit(self.panel, (self.x, self.y))