本文整理汇总了Python中GameEngine.GameEngine.startServer方法的典型用法代码示例。如果您正苦于以下问题:Python GameEngine.startServer方法的具体用法?Python GameEngine.startServer怎么用?Python GameEngine.startServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameEngine.GameEngine
的用法示例。
在下文中一共展示了GameEngine.startServer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testNetworking
# 需要导入模块: from GameEngine import GameEngine [as 别名]
# 或者: from GameEngine.GameEngine import startServer [as 别名]
def testNetworking(self):
config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
e1 = GameEngine(config)
e1.startServer()
session1 = e1.connect("localhost")
session2 = e1.connect("localhost")
while not session1.isConnected() or not session2.isConnected():
e1.run()
session1.world.createPlayer("mario")
session2.world.createPlayer("luigi")
for i in range(10):
e1.run()
assert len(e1.server.world.players) == 2
assert len(session1.world.players) == 2
assert len(session2.world.players) == 2
session3 = e1.connect("localhost")
for i in range(10):
e1.run()
assert len(session3.world.players) == 2
session1.disconnect()
for i in range(10):
e1.run()
assert len(e1.server.world.players) == 1
assert len(session2.world.players) == 1
e1.quit()
示例2: testNetworking
# 需要导入模块: from GameEngine import GameEngine [as 别名]
# 或者: from GameEngine.GameEngine import startServer [as 别名]
def testNetworking(self):
e1 = GameEngine()
e1.startServer()
session1 = e1.connect("localhost")
session2 = e1.connect("localhost")
while not session1.isConnected() or not session2.isConnected():
e1.run()
session1.world.createPlayer("mario")
session2.world.createPlayer("luigi")
for i in range(10):
e1.run()
assert len(e1.server.world.players) == 2
assert len(session1.world.players) == 2
assert len(session2.world.players) == 2
session3 = e1.connect("localhost")
for i in range(10):
e1.run()
assert len(session3.world.players) == 2
session1.disconnect()
for i in range(10):
e1.run()
assert len(e1.server.world.players) == 1
assert len(session2.world.players) == 1
e1.quit()