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
def __init__(self, width, height): # super(SetLevel, self).__init__() Div.__init__(self, (width, height)) self.initAttr(width, height)
# -*- 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))
# -*- 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))