Example #1
0
 def _swingSword(self):
     self.setSpriteAnimation(SKELETON_ANI_DICT[self.facing][0][1])
     self.Schedule(self._finishSwordSwing, PLAYER_SWING_FOLLOW_THROUGH_TIME)
     if self.facing in {DIRECTION_UP, DIRECTION_DOWN}:
         hitbox_x_left = self.getPos()[0] - PLAYER_SWORD_HITBOX_WIDE / 2
         hitbox_x_right = hitbox_x_left + PLAYER_SWORD_HITBOX_WIDE
         if self.facing == DIRECTION_UP:
             hitbox_y_top = self.getPos()[1] + PLAYER_SWORD_HITBOX_FAR
             hitbox_y_bottom = self.getPos()[1]
         else:
             hitbox_y_top = self.getPos()[1]
             hitbox_y_bottom = self.getPos()[1] - PLAYER_SWORD_HITBOX_FAR
     else:
         hitbox_y_bottom = self.getPos()[1] - PLAYER_SWORD_HITBOX_WIDE / 2
         hitbox_y_top = hitbox_y_bottom + PLAYER_SWORD_HITBOX_WIDE
         if self.facing == DIRECTION_RIGHT:
             hitbox_x_left = self.getPos()[0]
             hitbox_x_right = self.getPos()[0] + PLAYER_SWORD_HITBOX_FAR
         else:
             hitbox_x_left = self.getPos()[0] - PLAYER_SWORD_HITBOX_FAR
             hitbox_x_right = self.getPos()[0]
     for enemy in self.mappe.getEnemyActors():
         if not enemy.isHurt():
             x, y = enemy.getPos()
             if x >= hitbox_x_left and x <= hitbox_x_right and y >= hitbox_y_bottom and y <= hitbox_y_top:
                 enemy.setHurt(60)
                 if enemy.isHurt():  #hack for doors/etc
                     enemy.setVelocity(0, 0)
                     playSound(SOUND_HIT_ENEMY, True)
Example #2
0
 def checkForPlayerToSave(self):
     pactor = self.mappe.getPlayerActor()
     x, y = map(operator.sub, pactor.getPos(), self.getPos())
     if abs(x) + abs(y) <= SAVE_DISTANCE:
         self.Unschedule(self.checkForPlayerToSave)
         playSound(SOUND_SAVE, True)
         customEvent(PUSH_SAVE_EVENT)
         customEvent(PLAYER_MAX_HP_EVENT)
 def lookForPlayer(self):
     pactor = self.mappe.getPlayerActor()
     x, y = map(operator.sub, pactor.getPos(), self.getPos())
     if not self.open and abs(x) + abs(y) <= OPEN_DISTANCE and callQuery(ALL_SQUID_TROPHIES_OBTAINED_QUERY):
         self.setSpriteAlpha(0.0)
         self.updateTileCollision(False)
         self.open = True
         self.setStunned(True)
         playSound(SOUND_SQUID_DOOR, True)
Example #4
0
 def beginCharge(self):
     self.charging = True
     self.charging_windup = True
     self.setVelocity(0, 0)
     ani, flip = ACTOR_MOVEMENT_ANIMATION_DICT[self.facing][True]
     self.setSpriteAnimation(ani)
     self.setSpriteFlip(flip)
     self.setSpriteAnimationSpeed(2.0)
     playSound(SOUND_RUNNING, True)
     self.Schedule(self._startCharge, PLAYER_CHARGE_WINDUP_TIME)
 def stunEnemy(self, *args, **kwargs):
     if not self.open:
         self.setStunned(True)
         self.setSpriteAnimation("OPEN")
         playSound(SOUND_CRASH, True)
         self.updateTileCollision(False)
         if self.event_flag != "" and self.event_flag != None:
             gamestate.setEventFlag(self.event_flag, True)
         return True
     return False
Example #6
0
 def _chargeCollision(self):
     offset = list(
         map(operator.add, self.getPos(),
             PLAYER_CHARGE_COLLISION_DICT[self.facing]))
     if self.checkCollision(*offset):
         playSound(SOUND_CRASH, True)
         self._chargeKnockback()
         self.Unschedule(self._chargeCollision)
     elif self.checkOverPit(*offset):
         self._chargeFinish()
         self.Unschedule(self._chargeCollision)
Example #7
0
 def hurtPlayer(self, x, y):
     if not self.hurt:
         self._chargeFinish()  #just in case
         self._finishSwordSwing()
         self.setHurt(90)
         self.setKnockbackVel(x, y, HURT_KNOCKBACK_VEL)
         self.hurt_control_loss = True
         playSound(SOUND_HIT_PLAYER, True)
         customEvent(PLAYER_REDUCE_HP_EVENT)
         if callQuery(CHECK_PLAYER_DEAD_QUERY):
             self.setVelocity(0, 0)
             self.Schedule(self._vanishForever, 91)
             self.Unschedule(self._endHurt)
         else:
             self.Schedule(self._regainHurtControl, HURT_CONTROL_LOSS_TIME)
 def updateHitSomething(self):
     if not self.hit_something:
         for enemy in self.mappe.getEnemyActors():
             distance = reduce(
                 lambda x, y: abs(x) + abs(y),
                 map(operator.sub, self.getPos(), enemy.getPos()))
             if distance <= COLLISION_DISTANCE:
                 enemy_index = enemy.getEnemyIndex()
                 if enemy_index:
                     customEvent(PLAYER_FORM_CHANGE_EVENT,
                                 enemy.getEnemyIndex())
                     playSound(SOUND_POWERUP, True)
                     self._hitSomething()
                     return
         if self.checkCollision():
             playSound(SOUND_POP, True)
             self._hitSomething()
             return
         if self.checkSpriteOffscreen():
             playSound(SOUND_POP, True)
             self._hitSomething()
             return
Example #9
0
 def _chargeCollision(self):
     for enemy in self.mappe.getEnemyActors():
         if not enemy.isStunned() and not enemy.isHurt():
             x, y = map(operator.sub, enemy.getPos(), self.getPos())
             if abs(x) + abs(y) <= PLAYER_CHARGING_ENEMY_COLLISION:
                 if enemy.stunEnemy(*self.getPos()):
                     self._chargeKnockback()
                     playSound(SOUND_CRASH, True)
                     self.Unschedule(self._chargeCollision)
                     return  #hit a minotaur that was charging; skip everything after this
                 else:
                     if enemy.isStunned():  #hack for bushes
                         playSound(SOUND_HIT_ENEMY, True)
     offset = list(
         map(operator.add, self.getPos(),
             PLAYER_CHARGE_COLLISION_DICT[self.facing]))
     if self.checkCollision(*offset):
         playSound(SOUND_CRASH, True)
         self._chargeKnockback()
         self.Unschedule(self._chargeCollision)
     elif self.checkOverPit(*offset):
         self._chargeFinish()
         self.Unschedule(self._chargeCollision)
Example #10
0
 def keyPressed(self, symbol, modifiers):
     if not self.mappe.getScreenTransitioning(
     ) and not self.hurt_control_loss and not self.swinging_sword and not self.charging and not self.paused:
         if keyMatches(CANCEL, symbol):
             if self.form != PLAYER_FORM_INDEX:
                 if not self.checkOverPit(
                 ):  #don't allow this if flying over a pit
                     self.setPlayerForm(PLAYER_FORM_INDEX)
                     playSound(SOUND_BLOORP, True)
             else:
                 if not self.bubble_exists:
                     self.setBubbleExists(True)
                     bubble = self.mappe.getActor(
                         self.mappe.addActor(RainbowBubble))
                     bubble.setPos(*map(
                         operator.add, self.getPos(),
                         PROJECTILE_OFFSET_DICT.get(self.facing, (0, 0))))
                     bubble.setBubbleDirection(self.facing)
                     playSound(SOUND_SHOOT, True)
         elif keyMatches(CONFIRM, symbol):
             if self.form == ENEMY_SKELETON_INDEX and not self.swinging_sword:
                 self.setVelocity(0, 0)
                 self.swinging_sword = True
                 self.setSpriteAnimation(
                     SKELETON_ANI_DICT[self.facing][0][0])
                 self.setSpriteFlip(SKELETON_ANI_DICT[self.facing][1])
                 self.Schedule(self._swingSword,
                               PLAYER_SKELETON_BACKSWING_TIME)
             elif self.form == ENEMY_MINOTAUR_INDEX and not self.charging:
                 self.charging = True
                 self.charging_windup = True
                 self.setVelocity(0, 0)
                 self.setSpriteAnimation(
                     ACTOR_MOVEMENT_ANIMATION_DICT[self.facing][True][0])
                 self.setSpriteAnimationSpeed(2.0)
                 playSound(SOUND_RUNNING, True)
                 self.Schedule(self._startCharge, PLAYER_CHARGE_WINDUP_TIME)
 def collectSquid(self):
     playSound(SOUND_COLLECT_SQUID, True)
     customEvent(SQUID_TROPHY_OBTAINED_EVENT, self.getSquidTrophyIndex())
     self.cleanupSelf()
Example #12
0
 def collectSquid(self):
     playSound(SOUND_COLLECT_SQUID, True)
     customEvent(FINAL_SQUID_OBTAINED_EVENT)
     self.cleanupSelf()