本文整理汇总了Python中objects.Objects.load_map方法的典型用法代码示例。如果您正苦于以下问题:Python Objects.load_map方法的具体用法?Python Objects.load_map怎么用?Python Objects.load_map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类objects.Objects
的用法示例。
在下文中一共展示了Objects.load_map方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from objects import Objects [as 别名]
# 或者: from objects.Objects import load_map [as 别名]
class Game:
def __init__(self, window, data):
self.window = window
self.data = data
Mob.data = data
Human.data = data
self.interface = Interface()
self.ground = Ground()
self.objects = Objects()
self.player = Player()
self.timer = sf.Clock()
self.load_map("data/amd/elvine")
def run(self):
clock = sf.Clock()
fps = sf.Text()
fps.position = (620, 10)
self.loop = True
while self.loop:
for event in self.window.events:
if type(event) is sf.CloseEvent:
self.loop = False
if type(event) is sf.KeyEvent:
if event.code == sf.Keyboard.LEFT and event.pressed:
self.window.view.move(-5, 0)
elif event.code == sf.Keyboard.RIGHT and event.pressed:
self.window.view.move(5, 0)
elif event.code == sf.Keyboard.UP and event.pressed:
self.window.view.move(0, -5)
elif event.code == sf.Keyboard.DOWN and event.pressed:
self.window.view.move(0, 5)
self.update()
self.window.clear()
self.window.draw(self.ground)
self.window.draw(self.objects)
self.window.draw(self.interface)
self.window.draw(fps)
self.window.display()
fps.string = str(1000/clock.restart().milliseconds)[:4]
def update(self):
elapsed_time = self.timer.restart()
self.objects.update(elapsed_time)
def load_map(self, filename):
self.amd = Amd(filename)
self.ground.load_map(self.amd, self.data.tiles)
self.objects.load_map(self.amd, self.data.objects)
def unload_map(self):
pass