本文整理匯總了Python中objects.Objects.update方法的典型用法代碼示例。如果您正苦於以下問題:Python Objects.update方法的具體用法?Python Objects.update怎麽用?Python Objects.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類objects.Objects
的用法示例。
在下文中一共展示了Objects.update方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from objects import Objects [as 別名]
# 或者: from objects.Objects import update [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