本文整理汇总了Python中enemy.Enemy.getCoordinates方法的典型用法代码示例。如果您正苦于以下问题:Python Enemy.getCoordinates方法的具体用法?Python Enemy.getCoordinates怎么用?Python Enemy.getCoordinates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enemy.Enemy
的用法示例。
在下文中一共展示了Enemy.getCoordinates方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1:
# 需要导入模块: from enemy import Enemy [as 别名]
# 或者: from enemy.Enemy import getCoordinates [as 别名]
player.moveVertically(10)
if keys_pressed[K_SPACE]:
if shotCooldown <= 0:
shots.append(Shot(screen, player))
shotCooldown = 500 # adds a half second cooldown
shotCooldown -= dt
allShots=pygame.sprite.Group(shots)
for shot in shots:
if shot.update():
shots.remove(shot)
if pygame.sprite.spritecollide(shot,allEnemies,True):
shots.remove(shot)
shot.playExplosion()
for enemy in enemies:
if enemy.getCoordinates()[0] > screen.get_width() - 50:
movement = -1
elif enemy.getCoordinates()[0] < 50:
movement = 1
else:
movement = movement
enemy.moveVertically(movement)
allEnemies.clear(screen,background)
allShots.clear(screen,background)
playerSprite.clear(screen,background)
allEnemies.update()
playerSprite.update()
allEnemies.draw(screen)
allShots.draw(screen)
playerSprite.draw(screen)