def __init__( self, props, charmanager, type="df" ): AbstractCharacter.__init__( self ) self.manager = charmanager self.type = type self.properties = props self.sprite_sheet, sheet_rect = load_image_alpha( props['sprite sheet'] ) width, height = int(props['sprite width']), int(props['sprite height']) num_frames = int( props['num frames'] ) ###BEGIN CLUNKY IF STATEMENTS CHECKING ENEMY TYPE### if type == "df": combo_map = [("pullback", "dfpullback.png", (width-1, height-1, 2)),\ ("attack", "dfattack.png",(width-1, height-1, 3))] elif type == "dm": combo_map = [("pullback", "dmpullback.png", (width, height, 2)),\ ("attack", "dmattack.png", (width, height, 4))] elif type == "hip": combo_map = [("pullback", "hippullback.png", (width-1, height-1, 3)),\ ("attack", "hipattack.png", (width-1, height-1, 5))] else: combo_map = None ###END CLUNKY IF STATEMENTS### self.combo_state = ComboMachine( (props['sprite sheet'], (width-1, height-1, num_frames)),\ combo_map) #self.frames = extract_frames_from_spritesheet( sheet_rect, int( props['sprite width'] ), int( props['sprite height'] ), int( props['num frames'] ) ) self.attackPower = int( props['attack power'] ) self.defenseBoost = int( props['defense boost'] ) self.stabbing = 0 self.maxVelocity = int( props['velocity'] ) self.velocity = [0.0,0.0] self._update_image( random.randrange(self.combo_state.get_num_frames()) ) self.rect = self.image.get_rect() self.rect.topleft = random.randrange(640, 750), random.randrange(60,500) self.maxBefore = int( props['max before'] ) self.maxBetween = int( props['max between'] ) self.health = 100 #Mode 0 is 'tracking mode' in which the enemy attempts to close the distance between itself and Lerelei #Mode 1 is 'combat mode' in which the enemy maintains distance from Lorelei attempts to attack her self.mode = 0 self.recovering = 1 self.recoverytimer = random.randrange(0,self.maxBefore) self.preparedToAttack = 0 self.continueAttack = True # This changes when the health of this Enemy goes down to nothing # They then float up the screen and "kill()" themself off screen self.dying = False
def __init__( self, props ): AbstractCharacter.__init__( self ) self.properties = props #combo_map stores combo states. pass it a combo string with values from #the COMBO_BTNS strings above. You can add more control keys/string equivs #to the dictionary (COMBO_BTNS) if you like. Make sure the strings are one char long. #Recommend combo_map be loaded from a CSV file at some point. combo_map = [("^_^", "dervish.png", (180,180,18)),\ ("^/^", "ctrlaltctrl.png", (180,180,15)),\ ("^^^", "triplectrlattack.png", (180,180,10))] dodging = ("dodge.png", (180,180,6)) self.combo_state = ComboMachine(( props['sprite sheet'], (int(props['sprite width']),\ int( props['sprite height']), int( props['num frames'])) ), combo_map, dodging ) self.velocity = [0,0] self.stabbing = 0 #Dale Added These self.angle = 0 self.inited = False self.max_speed = 15 self.decay = 3 #end adds self.facing_right = True self._update_image() self.rect = self.image.get_rect() self.rect.top = int( props['start y'] ) self.rect.left = int( props['start x'] ) self.attackPower = self.base_attack = int( props['attack power'] ) self.inited = True #self.changeDifficulties = 0 self.health = 100 self.dead = 0 #tempvars self.dodgeStatus = False