本文整理匯總了Python中rules.Rules.draw方法的典型用法代碼示例。如果您正苦於以下問題:Python Rules.draw方法的具體用法?Python Rules.draw怎麽用?Python Rules.draw使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rules.Rules
的用法示例。
在下文中一共展示了Rules.draw方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Main
# 需要導入模塊: from rules import Rules [as 別名]
# 或者: from rules.Rules import draw [as 別名]
class Main(object):
"""main loop of the game"""
def __init__(self):
pygame.init()
# 包括讀取設置文件,設置遊戲基本屬性
self.initAttr()
# 傳遞所需的參數,實例化所包含的各個類
self.initObj()
self.initContext()
def initAttr(self):
self.width, self.height = WINDOW_WIDTH, WINDOW_HEIGHT
self.state = STATE.menu
self.running = True
self.level = SETLEVEL["DEFAULT_LEVEL"]
self.channelID = None
def initObj(self):
# 設置大小,用於背景圖片的縮放
self.gameNet = GameNet(self)
self.gameNet.connectToServer()
self.menu = Menu((self.width, self.height), self)
self.rules = Rules(self.width, self.height)
self.setLevel = SetLevel(self.width, self.height)
self.matching = Matching((self.width, self.height), self)
self.game = Game(self)
# finish 界麵的大小和遊戲界麵一樣
self.finish = Finish((self.game.width, self.game.height))
# 繪製遊戲主窗體
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 linkSuccess(self):
print "link success"
print self.channelID
def enterMatching(self):
self.matching.getRooms()
def enemyComming(self, turn, gameID):
self.gameID = gameID
self.game.enemyComming(turn)
self.game.setHome()
def joinGame(self, level, gameID, turn):
self.game = Game(self)
self.game.gameID = gameID
self.state = STATE.game
self.game.setLevel(level)
self.game.enemyComming(turn)
self.game.setAway()
def enterMenu(self):
self.state = STATE.menu
# 進入遊戲界麵事件
def enterGame(self, level):
self.game.setLevel(level)
self.game.initContext()
self.state = STATE.game
def startedNewGame(self, level):
print "open room", level
self.gameNet.openRoom(level)
def leaveServer(self, gameID):
self.gameNet.leaveServer(self.gameID)
self.state = STATE.menu
def backToMenu(self):
self.initContext()
self.state = STATE.menu
def addScore(self):
self.game.addScore()
def enemyAddScore(self):
self.game.enemyAddScore()
def getRooms(self, matching, page, num):
self.gameNet.getRooms(matching, page, num)
def update(self):
self.clock.tick(60)
self.screen.fill(0)
self.gameNet.pump()
if STATE.exit == self.state:
exit()
elif STATE.setLevel == self.state:
var = self.setLevel.draw(self.screen)
if (var in STATE):
self.state = var
else:
self.startedNewGame(var)
#.........這裏部分代碼省略.........