# HG changeset patch # User Jeremy Thurgood # Date 1304693963 -7200 # Node ID 6cc0d54df531bcdd4ae4ba4e289397444f73dca0 # Parent 4ffa9d15958836dfc8c79fd6a05b007f33cd0cb9 Some light cleanup. diff -r 4ffa9d159588 -r 6cc0d54df531 skaapsteker/sprites/player.py --- a/skaapsteker/sprites/player.py Fri May 06 16:37:43 2011 +0200 +++ b/skaapsteker/sprites/player.py Fri May 06 16:59:23 2011 +0200 @@ -1,18 +1,21 @@ """Class for dealing with the player""" -import pygame.transform import time -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 +import pygame.transform +from pygame.constants import BLEND_RGBA_MULT + from ..physics import Sprite from ..constants import Layers, FoxHud, DOUBLE_TAP_TIME from ..data import get_files, load_image from ..engine import PlayerDied, AddSpriteEvent, OpenNotification -from pygame.constants import BLEND_RGBA_MULT +from .base import (find_sprite, Monster, NPC, Item, Doorway, TILE_SIZE, + PC_LAYER, MONSTER_LAYER, PROJECTILE_LAYER) +from .projectiles import Fireball, Lightning +from .items import BreakableItem + + class Player(Sprite): @@ -56,7 +59,7 @@ self.the_world = the_world self.shape = the_world.fox.shape self._me = the_world.fox - self.set_facing('left') + self.facing = 'left' self.set_image() self.set_pos((0, 0)) self._collisions_seen = 0 @@ -214,7 +217,9 @@ self._collisions_seen = 0 def set_facing(self, new_facing): - self.facing = new_facing + if self.facing != new_facing: + self.facing = new_facing + self.set_image() def collided(self, other): if self.attacking and hasattr(other, 'damage'): @@ -256,9 +261,7 @@ self.collide_rect.midbottom = pos[0] * TILE_SIZE[0], (pos[1] + 1) * TILE_SIZE[1] def action_left(self): - if self.facing != 'left': - self.facing = 'left' - self.set_image() + self.set_facing('left') if self.shape != 'fox': self.deltav((-300.0, 0.0)) elif self.sprinting > 0: @@ -320,9 +323,7 @@ self.shape = self._me.shape def action_right(self): - if self.facing != 'right': - self.facing = 'right' - self.set_image() + self.set_facing('right') if self.shape != 'fox': self.deltav((300.0, 0.0)) elif self.sprinting > 0: