本文整理匯總了Python中background.Background.setColor方法的典型用法代碼示例。如果您正苦於以下問題:Python Background.setColor方法的具體用法?Python Background.setColor怎麽用?Python Background.setColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類background.Background
的用法示例。
在下文中一共展示了Background.setColor方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Game
# 需要導入模塊: from background import Background [as 別名]
# 或者: from background.Background import setColor [as 別名]
class Game(Div, object):
"""main frame of the game"""
def __init__(self, controller):
# super(game, self).__init__()
self.controller = controller
self.initAttr()
self.initElement()
def setLevel(self, level = 6):
self.boardWidth, self.boardHeight = self.board.setLevel(level)
self.height = self.boardHeight + self.edgeWidth * 2
self.width = self.boardWidth + self.hudWidth
self.initContext()
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 initElement(self):
# 背景
self.background = Background((self.width, self.height))
backgroundColor = GAME["GAME_BACKGROUND_COLOR"]
self.background.setColor(backgroundColor)
# 返回按鈕
self.returnButton = TextButton(GAME["RETURN_BUTTON_FONTS"], GAME["RETURN_BUTTON_CONTENT"], (30, 30))
def initContext(self):
self.screen = pygame.display.set_mode((self.width, self.height), DOUBLEBUF)
pygame.display.set_caption("Boxes")
self.clock = pygame.time.Clock();
def leaveServer(self, *args):
self.controller.gameNet.leaveServer(self.gameID)
return STATE.menu
def placeLine(self, data):
if self.hud.started:
self.controller.gameNet.placeLine(data, self.gameID, self.order)
def placeLineAnswer(self, turn, x, y, h, point, order):
self.setTurn(turn)
if order == self.order:
self.board.placeLine(x, y, h, point, True)
else:
self.board.placeLine(x, y, h, point, False)
def setTurn(self, turn):
self.hud.setMark(turn)
self.board.setTurn(turn)
def setHome(self):
self.order = 0
self.board.setHome()
self.background.setColor(GAME["HOME_COLOR"])
def setAway(self):
self.order = 1
self.board.setAway()
self.background.setColor(GAME["AWAY_COLOR"])
def addScore(self):
self.hud.addScore()
def enemyAddScore(self):
self.hud.enemyAddScore()
# 對手玩家進入遊戲
def enemyComming(self, turn):
self.setTurn(turn)
self.board.restart()
self.hud.startGame()
def newHost(self):
self.hud.restart()
# 數據清零,重新開始遊戲
def restart(self):
self.board.restart()
self.hud.restart()
def draw(self):
# self.screen.set_clip(None)
self.background.draw(self.screen)
ret = self.board.draw(self.screen)
if ret != None:
self.placeLine(ret)
self.hud.draw(self.screen)
self.returnButton.draw(self.screen)
var = self.returnButton.click(self.leaveServer)
#.........這裏部分代碼省略.........