Changeset 348:7d4738347a9c


Ignore:
Timestamp:
04/09/11 11:30:44 (12 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Phase:
public
Rebase:
31626363346265323535313434363062303666333038656361333064356333613235323838386333
Message:

Hook up transformation

Location:
skaapsteker
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/levelscene.py

    r340 r348  
    22
    33from pygame.locals import (KEYDOWN, KEYUP, K_DOWN, K_ESCAPE, K_LEFT, K_RIGHT,
    4                            K_SEMICOLON, K_UP, K_p, K_q, K_x, K_z, K_RETURN)
     4                           K_SEMICOLON, K_UP, K_p, K_q, K_x, K_z, K_RETURN, K_c, K_j)
    55
    66import pygame
     
    8686            self._slow_key_map[K_SEMICOLON] = action('fire1')
    8787            self._slow_key_map[K_q] = action('fire2')
     88            self._slow_key_map[K_j] = action('transform')
    8889        else:
    8990            self._slow_key_map[K_x] = action('fire1')
    9091            self._slow_key_map[K_z] = action('fire2')
     92            self._slow_key_map[K_c] = action('transform')
    9193            self._slow_key_map[K_q] = self._quit
    9294
  • skaapsteker/sprites/player.py

    r346 r348  
    3737        self.jumping = False
    3838        self.flying = False
     39        self.shape = 'fox'  # Needed so load image does the right thing
    3940        self._load_images()
    4041        self.inventory_image = None
    4142        # We muck with these in load for convience, so ensure they're right
    4243        self.the_world = the_world
     44        self.shape = the_world.fox.shape
    4345        self._me = the_world.fox
    4446        self.set_facing('left')
     
    191193            self.facing = 'left'
    192194            self.set_image()
    193         if self.sprinting > 0:
     195        if self.shape != 'fox':
     196            self.deltav((-300.0, 0.0))
     197        elif self.sprinting > 0:
    194198            self.sprinting = 1
    195199            self.deltav((-900.0, 0.0))
     
    212216    def action_double_up(self):
    213217        pass
     218
     219    def action_transform(self):
     220        """Transform the fox"""
     221        if not self.on_solid:
     222            return
     223        if 'shapeshift' not in self.the_world.fox.tails:
     224            return
     225        if self.shape == 'fox':
     226            # Become human
     227            if self.the_world.fox.has_fan:
     228                self.the_world.fox.shape = 'human_with_fan'
     229            else:
     230                self.the_world.fox.shape = 'human'
     231        else:
     232            self.the_world.fox.shape = 'fox'
     233        self.shape = self.the_world.fox.shape
    214234
    215235    def action_right(self):
     
    217237            self.facing = 'right'
    218238            self.set_image()
    219         if self.sprinting > 0:
     239        if self.shape != 'fox':
     240            self.deltav((300.0, 0.0))
     241        elif self.sprinting > 0:
    220242            self.sprinting = 1  # Flag so stopping works
    221243            self.deltav((900.0, 0.0))
     
    225247
    226248    def action_up(self):
    227         if self.on_solid:
     249        if self.on_solid and self.shape == 'fox':
    228250            self.deltav((0.0, -self.terminal_velocity[1]))
    229251            self.on_solid = False
     
    278300
    279301    def _make_key(self, tails, action=None):
     302        if self.shape != 'fox':
     303            # special logic for human shapes
     304            if self.running:
     305                return '%s_running_%s' % (self.shape, self.facing)
     306            else:
     307                return '%s_standing_%s' % (self.shape, self.facing)
    280308        if action is None:
    281309            action = self._get_action()
     
    313341                            sprint_image.blit(shockwave, (0, 0))
    314342                            self._image_dict[sprint_key].append(sprint_image)
    315 
    316 
     343        for shape, name in [('human', 'disguise_'), ('human_with_fan', 'disguise-fan_')]:
     344            directory = 'sprites/kitsune_disguise'
     345            for facing in ['left', 'right']:
     346                key = '%s_running_%s' % (shape, facing)
     347                standing_key = '%s_standing_%s' % (shape, facing)
     348                self._image_dict[key] = []
     349                for image_file in get_files(directory):
     350                    if name not in image_file:
     351                        continue
     352                    image = load_image('%s/%s' % (directory, image_file))
     353                    if facing == 'right':
     354                        image = pygame.transform.flip(image, True, False)
     355                    self._image_dict[key].append(image)
     356                self._image_dict[standing_key] = [self._image_dict[key][0]]
    317357
    318358    def discard_item(self):
Note: See TracChangeset for help on using the changeset viewer.