本文整理汇总了Python中GameEngine.GameEngine类的典型用法代码示例。如果您正苦于以下问题:Python GameEngine类的具体用法?Python GameEngine怎么用?Python GameEngine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GameEngine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ViewTest
class ViewTest(unittest.TestCase):
def testTransition(self):
l1 = TestLayer()
l2 = TestLayer()
l3 = TestLayer()
v = self.e.view
v.pushLayer(l1)
v.pushLayer(l2)
v.pushLayer(l3)
while l3.visibility < 1.0:
self.e.run()
v.popLayer(l3)
v.popLayer(l2)
v.popLayer(l1)
while l1 in v.layers or l2 in v.layers or l3 in v.layers:
self.e.run()
assert not v.layers
def setUp(self):
config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
self.e = GameEngine(config)
def tearDown(self):
self.e.quit()
示例2: ViewTest
class ViewTest(unittest.TestCase):
def testTransition(self):
l1 = TestLayer()
l2 = TestLayer()
l3 = TestLayer()
v = self.e.view
v.pushLayer(l1)
v.pushLayer(l2)
v.pushLayer(l3)
while l3.visibility < 1.0:
self.e.run()
v.popLayer(l3)
v.popLayer(l2)
v.popLayer(l1)
while l1 in v.layers or l2 in v.layers or l3 in v.layers:
self.e.run()
assert not v.layers
def setUp(self):
self.e = GameEngine()
def tearDown(self):
self.e.quit()
示例3: SvgTest
class SvgTest(unittest.TestCase):
def testRendering(self):
self.svg.transform.translate(256, 256)
self.svg.transform.rotate(3.141592)
self.svg.draw()
self.e.video.flip()
def testRenderToTexture(self):
scale = 4
fullwidth, fullheight = 512, 512
width, height = int(fullwidth / scale), int(fullheight / scale)
t = Texture()
self.e.svg.setProjection((0, 0, fullwidth, fullheight))
glViewport(0, 0, width, height)
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
self.svg.transform.translate(width * scale / 2, height * scale / 2)
self.svg.transform.rotate(3.141592)
self.svg.draw()
glViewport(0, 0, fullwidth, fullheight)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluOrtho2D(0.0, 1.0, 0.0, 1.0)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
t.bind()
glEnable(GL_TEXTURE_2D)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
glClear(GL_COLOR_BUFFER_BIT)
glColor3f(1.0, 1.0, 1.0)
glBegin(GL_TRIANGLE_STRIP)
glTexCoord2f(0.0, 0.0)
glVertex2f(0.0, 0.0)
glTexCoord2f(1.0, 0.0)
glVertex2f(1.0, 0.0)
glTexCoord2f(0.0, 1.0)
glVertex2f(0.0, 1.0)
glTexCoord2f(1.0, 1.0)
glVertex2f(1.0, 1.0)
glEnd()
self.e.video.flip()
import time
time.sleep(2)
def setUp(self):
config = Config.load(Version.appName() + ".ini", setAsDefault = True)
self.e = GameEngine(config)
self.e.loadImgDrawing(self, "svg", "mfhlogo.png")
while not self.svg:
self.e.run()
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
示例4: DialogTestInteractive
class DialogTestInteractive(unittest.TestCase):
def testGetTest(self):
text = getText(self.e, "Please enter your name:", "Wario")
def setUp(self):
self.e = GameEngine()
def tearDown(self):
self.e.quit()
示例5: DialogTestInteractive
class DialogTestInteractive(unittest.TestCase):
def testGetTest(self):
text = getText(self.e, "Please enter your name:", "Wario")
def setUp(self):
config = Config.load(Version.appName() + ".ini", setAsDefault = True)
self.e = GameEngine(config)
def tearDown(self):
self.e.quit()
示例6: ResourceTest
class ResourceTest(unittest.TestCase):
def testAsynchLoad(self):
self.r = Resource()
self.e.addTask(self.r, synchronized = False)
self.r.load(self, "result", lambda: loader())
while not self.result:
self.e.run()
assert self.result == 0xdada
def testSynchLoad(self):
self.r = Resource()
self.e.addTask(self.r, synchronized = False)
assert self.r.load(self, "result2", loader, synch = True) == 0xdada
assert self.result2 == 0xdada
def testAsynchLoadSeries(self):
self.r = Resource()
self.e.addTask(self.r, synchronized = False)
for i in range(10):
self.r.load(self, "result%d" % i, loader)
while not self.result9:
self.e.run()
assert self.result9 == 0xdada
def testCallback(self):
self.r = Resource()
self.e.addTask(self.r, synchronized = False)
self.quux = None
def loaded(r):
self.quux = r
self.r.load(self, "fuuba", loader, onLoad = loaded).join()
while not self.fuuba:
self.e.run()
assert self.fuuba == self.quux
def setUp(self):
Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
# Resource expects game_priority to be an integer,
# Config won't know unless we define it as such.
Config.define("performance", "game_priority", int, 2)
self.e = GameEngine()
def tearDown(self):
self.e.quit()
示例7: MenuTest
class MenuTest(unittest.TestCase):
def testMenuNavigation(self):
m = Menu(self.e, rootMenu)
self.e.view.pushLayer(m)
def setUp(self):
config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
self.e = GameEngine(config)
def tearDown(self):
self.e.quit()
示例8: MenuTestInteractive
class MenuTestInteractive(unittest.TestCase):
def testMenuNavigation(self):
m = Menu(self.e, rootMenu)
self.e.view.pushLayer(m)
while self.e.view.layers:
self.e.run()
def setUp(self):
config = Config.load(Version.appName() + ".ini", setAsDefault = True)
self.e = GameEngine(config)
def tearDown(self):
self.e.quit()
示例9: MenuTestInteractive
class MenuTestInteractive(unittest.TestCase):
def testMenuNavigation(self):
m = Menu(self.e, rootMenu)
self.e.view.pushLayer(m)
while self.e.view.layers:
rootMenu[0][0] = "%.1f FPS" % self.e.fpsEstimate
self.e.run()
def setUp(self):
self.e = GameEngine()
def tearDown(self):
self.e.quit()
示例10: MenuTest
class MenuTest(unittest.TestCase):
def testMenuNavigation(self):
m = Menu(self.e, rootMenu)
self.e.view.pushLayer(m)
while self.e.view.layers and 0:
rootMenu[0][0] = "%.1f FPS" % self.e.fpsEstimate
self.e.run()
# FIXME: keyboard event injection for testing
def setUp(self):
self.e = GameEngine()
def tearDown(self):
self.e.quit()
示例11: setUp
def setUp(self):
self.e = GameEngine()
self.e.loadSvgDrawing(self, "svg", "koopa.svg")
while not self.svg:
self.e.run()
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
示例12: setUp
def setUp(self):
config = Config.load(Version.appName() + ".ini", setAsDefault = True)
self.e = GameEngine(config)
self.e.loadImgDrawing(self, "svg", "mfhlogo.png")
while not self.svg:
self.e.run()
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
示例13: testVideoPlayerLayer
def testVideoPlayerLayer(self):
config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
self.e = GameEngine(config)
winWidth, winHeight = (self.e.view.geometry[2], self.e.view.geometry[3])
vidPlayer = VideoPlayer(framerate, self.src, (winWidth, winHeight),
loop = False, startTime = 10000, endTime = 14000)
self.e.view.pushLayer(vidPlayer)
while not vidPlayer.finished:
self.e.run()
self.e.view.popLayer(vidPlayer)
self.e.audio.close()
self.e.quit()
示例14: testVideoPlayerLayer
def testVideoPlayerLayer(self):
config = Config.load(Version.appName() + ".ini", setAsDefault = True)
self.e = GameEngine(config)
winWidth, winHeight = (self.e.view.geometry[2], self.e.view.geometry[3])
vidPlayer = VideoPlayer(framerate, self.src, (winWidth, winHeight),
loop = False)
self.e.view.pushLayer(vidPlayer)
while not vidPlayer.finished:
self.e.run()
self.e.view.popLayer(vidPlayer)
self.e.audio.close()
self.e.quit()
示例15: __init__
def __init__(self, engine=None, home_team=None, away_team=None):
self.state = GameState()
if home_team is None:
home_team = Team()
if away_team is None:
away_team = Team()
self.state.homeTeam = home_team
self.state.awayTeam = away_team
self.event_callbacks = []
self.game_end_callbacks = []
if engine is None:
self.engine = GameEngine()
else:
self.engine = engine