# # Parachute.py # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # Copyright # Author: Salvatore S. Gionfriddo # Contributors: # Created: 2007.08.04 # Last Modified: 2007.08.04 # from GameObject import TimedGameObject from Animation import Animation class Parachute(TimedGameObject): ############## # ANIMATIONS # ############## NUM_ANIMATIONS = 1 (FALLING) = 0# = range(NUM_ANIMATIONS) LEFT = NUM_ANIMATIONS FALLING_FRAME_TICKS = 30 ################### # ANIMATION TABLE # ################### ANIMATION_TABLE = [ (FALLING, 'Parachute', FALLING_FRAME_TICKS, Animation.NO_KEY_FRAME), ] DEFAULT_ANIMATION = FALLING ############# # MOVEMENTS # ############# MOVEMENTS = [ (0, 1) ] ######## # MISC # ######## RECT_SIZE = (80, 80) TICKS_TO_LIVE = 30*10 #10 seconds def __init__(self, kid): TimedGameObject.__init__(self, self.onKill) kid.PARACHUTING = True self.rect.top = kid.rect.top - 50 self.rect.left = kid.rect.left - 25 self.kid = kid self.update() def getType(self): return self.getAnimationType() def update(self): #MAJOR HAXXX if self.animations[self.currentAnimation].currentFrame == 0: self.rect.top += 2 kmvmt = 2 else: self.rect.top += 1 kmvmt = 1 (x,y) = (self.kid.rect.left, self.kid.rect.top + kmvmt) self.kid.setPosition((x,y)) TimedGameObject.update(self) def onKill(self): self.kid.PARACHUTING = False self.kid.removeAttachedByType(type(self)) class Hole(TimedGameObject): ############## # ANIMATIONS # ############## NUM_ANIMATIONS = 1 (HOLE) = 0# = range(NUM_ANIMATIONS) LEFT = NUM_ANIMATIONS ################### # ANIMATION TABLE # ################### ANIMATION_TABLE = [ (HOLE, 'Hole', 10, 3), ] DEFAULT_ANIMATION = HOLE ############# # MOVEMENTS # ############# MOVEMENTS = [ (0, 0) ] ######## # MISC # ######## RECT_SIZE = (70, 30) TICKS_TO_LIVE = 6*10 #10 x 6 frames def __init__(self, kid): TimedGameObject.__init__(self) self.readyToPop = False self.kid = kid self.popped = False self.update() def getType(self): return self.getAnimationType() def update(self): #MAJOR HAXXX if self.animations[self.currentAnimation].isKeyFrame(): self.readyToPop = True TimedGameObject.update(self)