Changeset 269:c24588c7ba09


Ignore:
Timestamp:
04/08/11 13:56:37 (12 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Phase:
public
Message:

Make sprinting single use after double tap

File:
1 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/sprites/player.py

    r266 r269  
    3131        self.attacking = 0
    3232        self.running = False
    33         self.sprinting = False
     33        self.sprinting = 0
    3434        self.jumping = False
    3535        self.flying = False
     
    9595                self._animation_frame = old_frame + 1
    9696                self._last_time = time.time()
    97         if self.sprinting:
     97        if self.sprinting > 0:
    9898            if (time.time() - self._sprint_start_time) > self._max_sprint_time:
    99                 self.sprinting = False
     99                self.sprinting = 0
    100100        if abs(v_x) < 80:
    101101            # Clamp when we're not moving at least 5 pixel / s
    102102            self.velocity = (0, v_y)
     103            if self.sprinting == 1:
     104                self.sprinting = 0
    103105            self.running = not self.on_solid # if you're not on something you can't stand
    104106        else:
    105107            self.velocity = (0, v_y) # Standard platformer physics
     108            if self.sprinting > 0:
     109                self.sprinting = 1
    106110            self.running = True
    107111        self.set_image()
     
    181185            self.facing = 'left'
    182186            self.set_image()
    183         if self.sprinting:
     187        if self.sprinting > 0:
     188            self.sprinting = 1
    184189            self.deltav((-900.0, 0.0))
    185190        else:
     
    188193    def action_double_left(self):
    189194        # FIXME: Tie this to the tails
    190         if self.sprinting:
    191             return
    192         self.sprinting = True
     195        if self.sprinting > 0:
     196            return
     197        self.sprinting = 2
    193198        self._sprint_start_time = time.time()
    194199
     
    197202
    198203    def action_double_right(self):
    199         if self.sprinting:
    200             return
    201         self.sprinting = True
     204        if self.sprinting > 0:
     205            return
     206        self.sprinting =  2
    202207        self._sprint_start_time = time.time()
    203208
     
    206211            self.facing = 'right'
    207212            self.set_image()
    208         if self.sprinting:
     213        if self.sprinting > 0:
     214            self.sprinting = 1  # Flag so stopping works
    209215            self.deltav((900.0, 0.0))
    210216        else:
     
    234240        if self.attacking:
    235241            return 'attacking'
    236         if self.sprinting and self.running:
     242        if (self.sprinting > 0) and self.running:
    237243            return 'sprinting'
    238244        if self.running:
Note: See TracChangeset for help on using the changeset viewer.