Mercurial > skaapsteker
changeset 450:e2b43fe37ac4
Sort actionables with items first, then npcs then doorways. Fix flight prep_time bug.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Sat, 09 Apr 2011 20:14:19 +0200 |
parents | d6b7f87e8a93 |
children | 7f198761a7be |
files | skaapsteker/sprites/player.py |
diffstat | 1 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/skaapsteker/sprites/player.py Sat Apr 09 20:11:56 2011 +0200 +++ b/skaapsteker/sprites/player.py Sat Apr 09 20:14:19 2011 +0200 @@ -3,7 +3,8 @@ import pygame.transform import time -from ..sprites.base import find_sprite, Monster, TILE_SIZE, PC_LAYER, MONSTER_LAYER, PROJECTILE_LAYER +from ..sprites.base import (find_sprite, Monster, NPC, Item, Doorway, TILE_SIZE, + PC_LAYER, MONSTER_LAYER, PROJECTILE_LAYER) from ..sprites.projectiles import Fireball, Lightning from ..sprites.items import BreakableItem from ..physics import Sprite @@ -283,7 +284,7 @@ def action_double_up(self): if self.flying > 0 or 'flight' not in self._me.tails or \ - self.prep_flight - time.time() > 2.5 * DOUBLE_TAP_TIME \ + time.time() - self.prep_flight > 2.5 * DOUBLE_TAP_TIME \ or self._me.shape != 'fox': return self.flying = 1 @@ -339,6 +340,14 @@ self.deltav((0.0, -self.terminal_velocity[1])) self.on_solid = False + def _action_key(self, sprite): + # sort action items so Items are first, then NPCs, then others, then Doorways + # This prevents problems if players drop items on NPCs or Doorways + return ( + not isinstance(sprite, Item), + not isinstance(sprite, NPC), + not isinstance(sprite, Doorway)) + def action_down(self): if self.flying: if self.on_solid: @@ -346,6 +355,7 @@ return elif self._touching_actionables: self.invisible = 0 + self._touching_actionables.sort(key=self._action_key) self._touching_actionables[0].player_action(self) elif self._me.item is not None and self.on_solid: self.drop_item()