Beispiel #1
0
    def check_key_pressed(self):
        if self.is_standstill() == True:
            if self.stun != True:
                self.stop()

            #--if pressing right
        elif self.is_pressing(
                0
        ) and self.colliding_hori != True and camera.camera_transitioning(
        ) != True:
            self.move_r()

        #--if pressing left
        elif self.is_pressing(
                2
        ) and self.colliding_hori != True and camera.camera_transitioning(
        ) != True:
            self.move_L()

        #--if you shoot
        if self.is_pressing(4) and camera.camera_transitioning() != True:
            self.shoot()
        else:
            self.all_timers.replenish_timer(
                'can_shoot'
            )  #the player can shoot after he lets go of the shoot button

        if camera.camera_transitioning() != True:
            self.jump()
Beispiel #2
0
def check_game_pause():
    k = pygame.key.get_pressed()
    if k[pygame.K_p] and game_has_started == True and megaman.is_alive(
    ) and not (camera.camera_transitioning()):  #pause game
        if universal_var.game_pause == False:
            play_sound('pause',
                       universal_var.megaman_sounds,
                       channel=2,
                       volume=universal_var.sfx_volume + 0.1)
            universal_var.songs.toggle()
        universal_var.game_pause = True

    elif k[pygame.K_o] and megaman.is_alive() and not (
            camera.camera_transitioning()):  #unpause
        if universal_var.game_pause == True:
            play_sound('pause',
                       universal_var.megaman_sounds,
                       channel=2,
                       volume=universal_var.sfx_volume + 0.1)
            universal_var.songs.toggle()
        universal_var.game_pause = False

    if k[pygame.K_v] and k[pygame.K_b]:  #debug
        universal_var.debug = True
    elif k[pygame.K_c]:
        universal_var.debug = False
Beispiel #3
0
    def display(self, surf):
        self.update_sprite(universal_var.main_sprite, auto_reset=False)
        if camera.Transition_box.current_box == self.transition_collbox and camera.camera_transitioning(
        ):
            if camera.transition_start():
                self.display_animation(universal_var.main_sprite, surf,
                                       "gate_open")
                if self.play_gate_sound:
                    misc_function.play_sound('gate',
                                             universal_var.megaman_sounds,
                                             channel=1,
                                             volume=universal_var.sfx_volume)
                    self.play_gate_sound = False

            elif camera.transition_end():
                self.display_animation(universal_var.main_sprite, surf,
                                       "gate_close")
                if self.play_gate_sound:
                    misc_function.play_sound('gate',
                                             universal_var.megaman_sounds,
                                             channel=1,
                                             volume=universal_var.sfx_volume)
                    self.play_gate_sound = False

            else:
                self.play_gate_sound = True
        else:
            self.display_animation(universal_var.main_sprite, surf,
                                   "gate_idle")
            self.play_gate_sound = True
Beispiel #4
0
 def check_all_collisions(self):
     #This will check all the sprite surfaces and there relation with self and act accordingly
     if camera.camera_transitioning() != True:
         self.check_ground_collision(universal_var.feet)
         self.check_ceiling_collision(universal_var.head)
         self.check_wall_collision(universal_var.hitbox)
         self.check_hazard_collision()
Beispiel #5
0
    def update(self):
        if len(Megaman.all_sprite_surfaces) != 0:
            m = Megaman.all_sprite_surfaces[0]
            if self.check_player_collision():
                if self.battle_has_init != True and camera.camera_transitioning(
                ) != True:
                    m.disable_keys()
                    self.spawn_boss()
                elif self.battle_has_init and self.battle_has_end != True:
                    m.enable_keys()

                if self.battle_has_end:
                    m.disable_keys()
                    self.end_level()

                if (self.battle_has_init and
                        self.battle_has_end != True) and self.boss.is_alive(
                        ) != True and self.boss.is_active != True:
                    self.battle_has_end = True
                    universal_var.songs.stop()

            if universal_var.game_reset:
                self.battle_has_init = False
                self.battle_has_end = False
                self.boss.health_bar.points = 0
                m.enable_keys()
                for ID in self.all_timers:
                    self.all_timers.replenish_timer(ID)
        Sprite_surface.update(self)
Beispiel #6
0
 def knock_back(self, speed):
     if camera.camera_transitioning(
     ) != True and universal_var.game_pause != True:
         self.x_vel = speed
         if self.direction == True:
             self.x -= self.x_vel
         else:
             self.x += self.x_vel
Beispiel #7
0
    def display_megaman(self, surf, s=''):
        if self.startup_check() is True:
            self.all_timers.replenish_timer('startup_animation', 8)

        if self.no_display is False or camera.camera_transitioning() is True:
            if self.stun is True:
                self.stun_animation(surf)

            elif self.is_grounded is True:
                self.ground_animation(surf, s)
            else:
                self.jump_animation(surf, s)
Beispiel #8
0
   def update(self):
      if camera.camera_transitioning() == True or universal_var.game_pause == True or universal_var.debug == True:
         pass
      else:
         if (self.y + self.height > 0) and (self.y < universal_var.screen_height):
            self.all_timers.countdown('start_offset')

         if self.all_timers.is_finished('start_offset'):
            self.is_active = True
            if (self.x_vel >= 0 and self.x + self.width <= universal_var.screen_width) or (self.x_vel < 0 and self.x > 0):
               self.move(self.x_vel)
            if self.lasor_sound == True:
               play_sound('lasor', universal_var.megaman_sounds, channel=3, volume=universal_var.sfx_volume)
               self.lasor_sound = False

      Sprite_surface.update(self)
Beispiel #9
0
    def jump(self):
        if self.is_grounded is True and self.can_jump is True:
            self.all_timers.replenish_timer('rise_flag')
            self.y_vel = 10
            if self.is_pressing(5) and camera.camera_transitioning() != True:
                self.y_vel = self.jump_speed

        if self.gravity is False and self.is_pressing(5):
            self.rise()
        else:
            if self.y_vel > 0:
                self.y_vel = 0
            self.gravity = True

        if self.is_pressing(5) != True and self.is_grounded is True:
            self.can_jump = True
        else:
            self.can_jump = False
Beispiel #10
0
   def update(self):
      if self.is_active:
         megaman_collision = self.check_collision_lst(Megaman.all_sprite_surfaces, universal_var.hitbox, universal_var.hitbox)
         if megaman_collision.is_empty() != True and camera_transitioning() != True:
            m = megaman_collision.pop()

            if self.current_added_points != self.threshold and m.health_bar.refill(1):
               self.current_added_points += 1
               m.health_points += 1
               universal_var.game_pause = True

            elif self.current_added_points == self.threshold or m.health_bar.is_full():
               self.is_active = False
               self.current_added_points = 0
               universal_var.game_pause = False

            if self.all_timers.is_finished('increment'):
               self.all_timers.replenish_timer('increment')
            else:
               self.all_timers.countdown('increment')

      Item.update(self)
Beispiel #11
0
   def update(self):
      if camera.camera_transitioning() == True or universal_var.game_reset:
         self.is_active = False
         self.health_points = 0
         self.can_spawn = True
      elif universal_var.game_pause == True:
         pass
      else:
         if (self.is_on_screen(self.x_clip_offset, self.y_clip_offset) 
            and universal_var.game_reset != True):
            if self.is_alive():
               self.is_active = True
         else:
            self.is_active = False #respawn if offscreen
            self.health_points = 0


         if self.is_alive() != True:
            x, y = self.spawn_point[0], self.spawn_point[1]
            if self.can_spawn == True and self.is_active != True:
               self.respawn()

            elif (x < 0 or x > universal_var.screen_width) or (y < 0 or y > universal_var.screen_height): #if spawn point is off screen
               self.can_spawn = True
Beispiel #12
0
   def display(self, surf):
      if universal_var.game_pause != True:
            self.update_sprite(universal_var.main_sprite)

      if self.is_active and universal_var.game_reset == False and camera_transitioning() == False and self.current_added_points == 0:
         self.display_animation(universal_var.main_sprite, surf, 'health_capsule')
Beispiel #13
0
 def display(self, surf):
    if self.is_active and universal_var.game_reset == False and camera_transitioning() == False:
       self.display_animation(universal_var.main_sprite, surf, 'extra_life_img')
Beispiel #14
0
    def update(self):
        if self.is_alive() and self.is_active:
            if camera.camera_transitioning(
            ) != True and universal_var.game_pause != True and self.get_keys:
                self.keys_pressed = pygame.key.get_pressed(
                )  #if the camera is not transitioning the I can catch input
            elif self.get_keys == False:
                self.keys_pressed = None

            self.set_direction()
            if universal_var.game_pause == False:
                self.all_timers.countdown('shooting_flag', 20)
            self.check_all_collisions()
            self.health_bar.points = self.health_points

            if self.stun is True:
                self.check_stun()

            if self.invincibility is True:
                self.check_invincibility()

            if universal_var.game_pause != True:
                self.check_key_pressed()

            if self.gravity is True and camera.camera_transitioning() != True:
                self.apply_gravity()

            Sprite_surface.update(self)
            self.colliding_hori = False
            self.colliding_vert = False

            if self.y > universal_var.screen_height + 550 and universal_var.debug != True:
                self.health_points -= self.health_points  #death
                self.health_bar.points -= self.health_bar.points

        elif self.is_alive() != True:
            self.keys_pressed = None
            if self.all_timers.is_finished('death'):
                universal_var.game_pause = False
                self.is_active = False
                if self.all_timers.is_finished('death_sound') is not True:
                    start_times = [0, 15, 35]
                    angles = [
                        0, 90, 180, 270, 45, 135, 225, 315, 0, 90, 180, 270
                    ]
                    i = 0
                    for time in start_times:
                        Death_orb.set_orb_active(self.x + 20, self.y + 20,
                                                 time, angles[i], 15)
                        Death_orb.set_orb_active(self.x + 20, self.y + 20,
                                                 time, angles[i + 1], 15)
                        Death_orb.set_orb_active(self.x + 20, self.y + 20,
                                                 time, angles[i + 2], 15)
                        Death_orb.set_orb_active(self.x + 20, self.y + 20,
                                                 time, angles[i + 3], 15)
                        i += 4
                    play_sound('death',
                               universal_var.megaman_sounds,
                               channel=5,
                               volume=universal_var.sfx_volume + 0.1)
                    self.all_timers.countdown('death_sound')

            else:
                self.all_timers.countdown('death')
                universal_var.game_pause = True

            if universal_var.game_reset:
                Death_orb.reset()