本文整理汇总了Python中unit.Unit.update方法的典型用法代码示例。如果您正苦于以下问题:Python Unit.update方法的具体用法?Python Unit.update怎么用?Python Unit.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unit.Unit
的用法示例。
在下文中一共展示了Unit.update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import update [as 别名]
def update(self, time):
self.applyForceFrom(-0.1, self.player.getPos())
Unit.update(self, time)
angle = math.atan2(self.player.getY() - self.getY(), \
self.player.getX() - self.getX())
self.setH(angle * 180 / math.pi)
示例2: update
# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import update [as 别名]
def update(self, time):
"""Run all major player operations each frame"""
#check for weapon switch key
if self.controlScheme.keyDown(SWITCH):
if not self.switchPressed:
self.switchWeapon()
self.switchPressed = True
else:
self.switchPressed = False
self.targetEnemy()
#check for attack keys
if self.controlScheme.keyDown(PUSH) and not self.controlScheme.keyDown(PULL):
self.attack(PUSH, time)
#include sound
#self.electricSound.play()
if self.electricSound.status() is not self.electricSound.PLAYING:
#self.electricSound.setTime(self.electricSound.getTime())#reset to the current time and play it from there
self.electricSound.setVolume(.1)
self.electricSound.play()
elif self.controlScheme.keyDown(PULL) and not self.controlScheme.keyDown(PUSH):
self.attack(PULL, time)
#include sound
#self.magnetSound.setLoop(True)
if self.magnetSound.status() is not self.magnetSound.PLAYING:
#self.magnetSound.setTime(self.magnetSound.getTime())
self.magnetSound.play()
else:
self.sustainedAttack = False
#self.target = None
if self.electricSound.status() == self.electricSound.PLAYING:
#self.electricSound.setTime(float(0))#for some reason this is not resetting the time
self.electricSound.stop()
if self.magnetSound.status() == self.magnetSound.PLAYING:
#self.magnetSound.setTime(float(0))#for some reason this is not resetting the time
self.magnetSound.stop()
#i am of the opinion that sound is somehow completely borked here
#automatically regenerate energy
self.energy += self.energyRegen * time
self.energy = min(self.maxEnergy, self.energy)
self.move(time)
Unit.update(self, time)
示例3: update
# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import update [as 别名]
def update(self, time):
Unit.update(self, time)
示例4:
# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import update [as 别名]
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
sys.exit()
elif event.key == pygame.K_z:
trooper.action()
elif event.key == pygame.K_UP:
cursor.update('up')
elif event.key == pygame.K_DOWN:
cursor.update('down')
elif event.key == pygame.K_LEFT:
cursor.update('left')
elif event.key == pygame.K_RIGHT:
cursor.update('right')
cursor_x, cursor_y = cursor.get_location()
trooper.update( cursor_x, cursor_y )
background.draw()
trooper.draw()
cursor.draw()
pygame.display.flip()
moveflag = 0
clock.tick(FPS)