Changeset 381:56f97d0c6a36


Ignore:
Timestamp:
04/09/11 13:55:18 (12 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
Phase:
public
Rebase:
34386364363939393335313636643665356463623930383036313365353764343238386664316131
Message:

Add flying (max flight time is number of tails in seconds). Set max sprint time to number of tails over 4.0 is seconds.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/sprites/player.py

    r366 r381  
    77from ..sprites.projectiles import Fireball, Lightning
    88from ..physics import Sprite
    9 from ..constants import Layers, FoxHud
     9from ..constants import Layers, FoxHud, DOUBLE_TAP_TIME
    1010from ..data import get_files, load_image
    1111from ..engine import PlayerDied, AddSpriteEvent
     
    2020    block = True
    2121
    22     _max_sprint_time = 2
    2322
    2423    def __init__(self, the_world, soundsystem):
     
    104103                self._animation_frame = old_frame + 1
    105104                self._last_time = time.time()
     105        now = time.time()
    106106        if self.sprinting > 0:
    107             if (time.time() - self._sprint_start_time) > self._max_sprint_time:
     107            if (now - self._sprint_start_time) > self._max_sprint_time:
    108108                self.sprinting = 0
     109        if self.flying > 0:
     110            if (now - self._flight_start_time) > self._max_flight_time:
     111                self.flying = 0
     112            # v_y = 0 # Standard platformer flying
    109113        if abs(v_x) < 80:
    110114            # Clamp when we're not moving at least 5 pixel / s
     
    173177        if hasattr(other, 'collided_player'):
    174178            other.collided_player(self)
    175             print 'Health', self._me.cur_health
    176 
    177179
    178180    def damage(self, damage):
     
    204206    def action_double_left(self):
    205207        # FIXME: Tie this to the tails
    206         if self.sprinting > 0:
     208        if self.sprinting > 0 or self.flying > 0:
    207209            return
    208210        self.sprinting = 2
     
    210212
    211213    def action_double_right(self):
    212         if self.sprinting > 0:
    213             return
    214         self.sprinting =  2
     214        if self.sprinting > 0 or self.flying > 0:
     215            return
     216        self.sprinting = 2
     217        self._max_sprint_time = float(len(self._me.tails)) / 4.0
    215218        self._sprint_start_time = time.time()
    216219
    217220    def action_double_up(self):
    218         pass
     221        if self.flying > 0 or 'flight' not in self._me.tails or \
     222               self.prep_flight - time.time() > 2.5 * DOUBLE_TAP_TIME:
     223            return
     224        self.flying = 1
     225        self._max_flight_time = float(len(self._me.tails))
     226        self._flight_start_time = time.time()
    219227
    220228    def action_transform(self):
     
    252260            self.deltav((450.0, 0.0))
    253261
    254 
    255262    def action_up(self):
    256         if self.on_solid and self.shape == 'fox':
     263        if self.flying:
     264            self.deltav((0.0, -self.terminal_velocity[1] / 5.0))
     265        elif self.on_solid and self.shape == 'fox':
     266            self.prep_flight = time.time()
    257267            self.deltav((0.0, -self.terminal_velocity[1]))
    258268            self.on_solid = False
    259269
    260270    def action_down(self):
    261         print self._touching_actionables
    262         if self._touching_actionables:
     271        if self.flying:
     272            return
     273            #self.deltav((0.0, self.terminal_velocity[1] / 2.0))
     274        elif self._touching_actionables:
    263275            self._touching_actionables[0].player_action(self)
    264276        elif self._me.item is not None and self.on_solid:
     
    266278
    267279    def _bite_attack(self):
    268         print 'ninja bite attack'
    269280        self.attacking = 2
    270281        self._last_time = time.time() # Reset the animation clock
     
    279290
    280291    def _fireball_attack(self):
    281         print 'ninja fireball attack attack attack'
    282292        self.attacking = 2
    283293        self._last_time = time.time() # Reset the animation clock
     
    285295
    286296    def _lightning_attack(self):
    287         print 'thunderbolts and lightning'
    288297        self.attacking = 2
    289298        self._last_time = time.time() # Reset the animation clock
     
    309318        if self.running:
    310319            return 'running'
     320        if self.flying:
     321            return 'running'
    311322        if self.jumping:
    312             return 'jumpin'
     323            return 'jumping'
    313324        return 'standing'
    314325
     
    408419        # We create a scaled version of the image for the inventory display
    409420        item.remove()
    410         print "took", item
    411421
    412422
Note: See TracChangeset for help on using the changeset viewer.