本文整理汇总了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)
#.........这里部分代码省略.........