本文整理汇总了Python中brain.Brain.pop方法的典型用法代码示例。如果您正苦于以下问题:Python Brain.pop方法的具体用法?Python Brain.pop怎么用?Python Brain.pop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类brain.Brain
的用法示例。
在下文中一共展示了Brain.pop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from brain import Brain [as 别名]
# 或者: from brain.Brain import pop [as 别名]
#.........这里部分代码省略.........
self.left = load('left')
self.right = load('right')
# build images
img = pyglet.resource.image('tank/bullet.png')
img.anchor_x = img.width * 0.5
img.anchor_y = img.height * 0.5
# lookup table for bullet facing
self.bullet_facing_img = {
Facing.UP: img.get_transform(rotate=0),
Facing.RIGHT: img.get_transform(rotate=90),
Facing.DOWN: img.get_transform(rotate=180),
Facing.LEFT: img.get_transform(rotate=270),
}
# lookup table for tank facing
self.tank_facing_img = {
Facing.UP: self.up,
Facing.RIGHT: self.right,
Facing.DOWN: self.down,
Facing.LEFT: self.left,
}
def blit(self, x, y, z):
x += self.offset[0]
y += self.offset[1]
self.tank_facing_img[self.facing].blit(x, y, z)
#self.rect().debug_draw()
def read_command(self):
'''Pop a command from the brain memory and interpret it'''
if self.brain:
command = self.brain.pop()
if command in (Command.FORWARD, Command.BACKWARD):
self.state = TankState.MOVING
self.offset_dt = FACING_TO_VEC[self.facing]
self.driving_forward = (command is Command.FORWARD)
end = self.world.tile_size[0]
if self.facing in (Facing.DOWN, Facing.UP):
end = self.world.tile_size[1]
self.animation = Animation(0, abs(end), 1.0)
if command in (Facing.UP, Facing.DOWN, Facing.LEFT, Facing.RIGHT):
self.state = TankState.TURNING
self.turn_to = command # bleh
time_to_turn = 1.0
if command in (Facing.UP, Facing.DOWN):
if self.facing in (Facing.LEFT, Facing.RIGHT):
time_to_turn = 0.5
else:
if self.facing in (Facing.UP, Facing.DOWN):
time_to_turn = 0.5
if command == self.facing:
time_to_turn = 0
self.animation = Animation(0, time_to_turn, 1.0)
if command is Command.SHOOT and self.bullet is None: