本文整理汇总了Python中engine.Engine.render方法的典型用法代码示例。如果您正苦于以下问题:Python Engine.render方法的具体用法?Python Engine.render怎么用?Python Engine.render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类engine.Engine
的用法示例。
在下文中一共展示了Engine.render方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import render [as 别名]
class Application:
def __init__(self):
self.clock = pygame.time.Clock()
self.fps = 30.0
self.camera = None
self.handler = None
self.engine = None
self.audio = None
def set_caption(self):
pygame.display.set_caption("RTS Project - {:.2f}".format(self.clock.get_fps()))
def start(self):
self.engine = Engine(800, 600)
load_textures(self.engine)
while True:
r = self.menu_loop()
if not r:
break
self.engine.stop()
print('Goodbye')
def menu_loop(self):
m = Menu(self.engine)
m.menu_start()
while True:
s = m.update()
m.render()
self.engine.render()
if s['clicked'] is not None:
break
if s['clicked'] in ['Campaign', 'Skirmish']:
game = Game('Test 1', FutureWar)
worldmap = Map.from_csv("World map", "textures", MAP_PATH + r"\worldmap.csv")
#worldmap = Map.from_csv("World map", "textures", MAP_PATH + r"\smallmap.csv")
print("worldmap width = ", worldmap.width)
print("worldmap height = ", worldmap.height)
world = game.set_world(worldmap)
player = game.create_player("Bob", "RedScum", Colors.YELLOW, 100, 100, 0, 0)
game.create_player("Hicks", "BlueAngels", Colors.SKY_BLUE, 0, 0, 0, 0)
game.create_player("Neutral", "BlueAngels", Colors.GREY, 20, 20, 0, 0)
game.create_unit("Bob", "Soldier", 1, 1, 1.0)
game.create_unit("Bob", "Elite", 3, 3, 0.5)
game.create_unit("Bob", "Heavy", 2, 5, 0.5)
game.create_unit("Neutral", "Defender", 20, 20, 1.0)
#plant = Building(Hicks, x=4, y=4, profile=FutureWar.get_profile("barracks"), constructed=1, plife=0.50)
#s1 = Unit(Hicks, x=9, y=9, profile=FutureWar.get_profile("soldier"), plife=0.50)
#writeln(f"plant life = {plant.life}")
self.camera = Camera(800, 600, world, player, self.engine)
self.handler = InputHandler(self.camera, auto_scroll_zone=-1)
self.audio = AudioHandler(AUDIO_PATH)
#self.audio.play("ds.ogg")
r = self.game_loop(game)
return r
elif s['clicked'] == 'Options':
pass
elif s['clicked'] == 'Quit':
return False
def in_game_menu_loop(self):
m = Menu(self.engine)
m.menu_pause()
while True:
s = m.update()
m.render()
self.engine.render()
if s['clicked'] is not None: break
if s['clicked'] == 'Options':
pass
else:
return s['clicked']
def game_loop(self, game):
start_time = pygame.time.get_ticks()
self.clock.tick(self.fps)
while True:
res_gam = game.update()
res_han = self.handler.update()
self.camera.render()
self.engine.render()
self.clock.tick(self.fps)
self.set_caption()
if not res_han:
self.audio.pause()
r = self.in_game_menu_loop()
if r != 'Resume':
break
self.audio.resume()
self.handler.resume()
if not res_gam:
r = 'Game Finished'
break
if r in ('Game Finished', 'Quit'):
print('Game has ended.')
end_time = pygame.time.get_ticks()
#.........这里部分代码省略.........