def update(self, game): VGDLSprite.update(self, game) world = AStarWorld(game) path = world.getMoveFor(self) # Uncomment below to draw debug paths. # self._setDebugVariables(world,path) if len(path) > 1: move = path[1] nextX, nextY = world.get_sprite_tile_position(move.sprite) nowX, nowY = world.get_sprite_tile_position(self) movement = None if nowX == nextX: if nextY > nowY: movement = DOWN else: movement = UP else: if nextX > nowX: movement = RIGHT else: movement = LEFT self.physics.active_movement(self, movement)
def update(self, game): VGDLSprite.update(self, game) self._age += 1 if self._age >= self.limit: # game.kill_sprite(self) game.destroy_sprite(self)
def _draw(self, screen): """ With a triangle that shows the orientation. """ VGDLSprite._draw(self, screen) if self.draw_arrow: col = (self.color[0], 255 - self.color[1], self.color[2]) pygame.draw.polygon( screen, col, triPoints(self.rect, unitVector(self.orientation)))
def update(self, game): VGDLSprite.update(self, game) action = self._readAction(game) if action in [RIGHT, LEFT]: self.physics.activeMovement(self, action) from pygame.locals import K_SPACE if self.stype and game.keystate[K_SPACE]: game._createSprite([self.stype], (self.rect.left, self.rect.top))
def update(self, game): VGDLSprite.update(self, game) options = [] for target in self._closestTargets(game): options.extend(self._movesToward(game, target)) if len(options) == 0: options = BASEDIRS self.physics.activeMovement(self, choice(options))
def update(self, game): VGDLSprite.update(self, game) options = [] for target in self._closestTargets(game): options.extend(self._movesToward(game, target)) if len(options) == 0: raise "Cannot move!" self.physics.active_movement(self, options[0]) #TODO: GONNA LOOK AT THIS
def update(self, game): VGDLSprite.update(self, game) options = [] for target in self._closestTargets(game): options.extend([self._movesToward(game, target)]) if len(options) == 0: raise Exception("Cannot move!") left = self.rect.left top = self.rect.top self.physics.active_movement(self, options[0]) if self.rect.top == top and self.rect.left == left: raise "Erroneous moves from the chaser"
def update(self, game): action = self._readAction(game) if action is None: action = (0, 0) from pygame.locals import K_SPACE if game.keystate[K_SPACE] and self.orientation[1] == 0: action = (action[0] * sqrt(self.strength), -self.strength) elif self.orientation[1] == 0 or self.airsteering: action = (action[0] * sqrt(self.strength), 0) else: action = (0, 0) self.physics.activeMovement(self, action) VGDLSprite.update(self, game)
def update(self, game): tmp = self.orientation self.orientation = (0, 0) VGDLSprite.update(self, game) action = self._readAction(game) if action: self.physics.activeMovement(self, action) d = self.lastdirection if sum(map(abs, d)) > 0: # only update if the sprite moved. self.orientation = d else: self.orientation = tmp
def update(self, game): actions = self._readMultiActions(game) if UP in actions: self.speed = 1 elif DOWN in actions: self.speed = -1 if LEFT in actions: i = BASEDIRS.index(self.orientation) self.orientation = BASEDIRS[(i + 1) % len(BASEDIRS)] elif RIGHT in actions: i = BASEDIRS.index(self.orientation) self.orientation = BASEDIRS[(i - 1) % len(BASEDIRS)] VGDLSprite.update(self, game) self.speed = 0
def update(self, game): from vgdl.core import VGDLSprite from pygame.locals import K_SPACE VGDLSprite.update(self, game) if game.keystate[K_SPACE]: x = self.rect.x / game.block_size # Jump up to 2 far, but may be less if near end of corridor jump_size = min(2, game.width - x - 1) self.physics.activeMovement(self, RIGHT, jump_size) else: action = self._readAction(game) self.physics.activeMovement(self, action)
def update(self, game): last_orientation = self.orientation self.orientation = Vector2(0, 0) VGDLSprite.update(self, game) action = self._read_action(game) if action: self.physics.active_movement(self, action) if self.lastdirection.length() != 0: # Face the direction you moved self.orientation = self.lastdirection else: # Make sure orientation is kept self.orientation = last_orientation
def update(self, game): VGDLSprite.update(self, game) options = [] for target in self._closestTargets(game): options.extend(self._movesToward(game, target)) if len(options) == 0: options = BASEDIRS #Directions are now deterministic since we want SPIN and elif LEFT in options: self.physics.active_movement(self, LEFT) elif UP in options: self.physics.active_movement(self, UP) elif RIGHT in options: self.physics.active_movement(self, RIGHT) elif DOWN in options: self.physics.active_movement(self, DOWN)
def update(self, game): actions = self._readMultiActions(game) if len(actions) > 0 and self.noiseLevel > 0: # pick a random one instead if random() < self.noiseLevel*4: actions = [choice([UP, LEFT, DOWN, RIGHT])] if UP in actions: self.speed = 1 elif DOWN in actions: i = BASEDIRS.index(self.orientation) self.orientation = BASEDIRS[(i + 2) % len(BASEDIRS)] elif LEFT in actions: i = BASEDIRS.index(self.orientation) self.orientation = BASEDIRS[(i + 1) % len(BASEDIRS)] elif RIGHT in actions: i = BASEDIRS.index(self.orientation) self.orientation = BASEDIRS[(i - 1) % len(BASEDIRS)] VGDLSprite.update(self, game) self.speed = 0
def update(self, game): actions = self._readMultiActions(game) if len(actions) > 0 and self.noiseLevel > 0: # pick a random one instead if random() < self.noiseLevel * 4: actions = [choice([UP, LEFT, DOWN, RIGHT])] if UP in actions: self.speed = 1 elif DOWN in actions: i = BASEDIRS.index(self.orientation) self.orientation = BASEDIRS[(i + 2) % len(BASEDIRS)] elif LEFT in actions: i = BASEDIRS.index(self.orientation) self.orientation = BASEDIRS[(i + 1) % len(BASEDIRS)] elif RIGHT in actions: i = BASEDIRS.index(self.orientation) self.orientation = BASEDIRS[(i - 1) % len(BASEDIRS)] VGDLSprite.update(self, game) self.speed = 0
def __init__(self, limit=1, **kwargs): self.limit = limit self.age = 0 VGDLSprite.__init__(self, **kwargs)
def update(self, game): VGDLSprite.update(self, game) self.physics.activeMovement(self, choice(BASEDIRS))
def _draw(self, screen): """ With a triangle that shows the orientation. """ VGDLSprite._draw(self, screen) if self.draw_arrow: col = (self.color[0], 255 - self.color[1], self.color[2]) pygame.draw.polygon(screen, col, triPoints(self.rect, unitVector(self.orientation)))
def update(self, game): VGDLSprite.update(self, game) action = self._readAction(game) if action: self.physics.activeMovement(self, action)
def update(self, game): VGDLSprite.update(self, game) action = self._read_action(game) if not action == NOOP: self.physics.active_movement(self, action)
def __init__(self, **kwargs): self._age = 0 VGDLSprite.__init__(self, **kwargs)
def update(self, game): VGDLSprite.update(self, game) action = self._read_action(game) if action.as_vector() in [UP, DOWN]: self.physics.active_movement(self, action)
def update(self, game): VGDLSprite.update(self, game) self.physics.active_movement(self, game.random_generator.choice(BASEDIRS))
def update(self, game): VGDLSprite.update(self, game) self._aim(game) self._shoot(game)
def update(self, game): VGDLSprite.update(self, game) if self._age > self.limit: game.kill_sprite(self) self._age += 1
def update(self, game): VGDLSprite.update(self, game) if self.age > self.limit: killSprite(self, None, game) self.age += 1