Exemplo n.º 1
0
def draw_level(level):
    global rendered_mana_count
    global portal

    # clean up level
    for x in wall_list:
        wall_list.remove(x)
    for x in mana_list:
        mana_list.remove(x)
    for x in enemy_list:
        enemy_list.remove(x)
    for x in fireball_list:
        fireball_list.remove(x)
    for x in bg_list:
        bg_list.remove(x)
    for x in all_sprites_list:
        all_sprites_list.remove(x)

    all_sprites_list.add(player)

    levx = 0
    levy = 0
    for row in levels.set_level(level):
        for col in row:
            bg = sprite_classes.Background(levx, levy, screenx, screeny)
            bg_list.add(bg)
            if col == "W":
                wall = sprite_classes.Wall(levx, levy, screenx, screeny)
                wall_list.add(wall)
                all_sprites_list.add(wall)
            if col == "D":
                dest_wall = sprite_classes.DestWall(levx, levy, screenx, screeny)
                dest_wall_list.add(dest_wall)
                wall_list.add(dest_wall)
                all_sprites_list.add(dest_wall)
            if col == "P":
                platform = sprite_classes.Platform(levx, levy, screenx, screeny)
                wall_list.add(platform)
                all_sprites_list.add(platform)
            if col == "M":
                mana = sprite_classes.Mana(levx + 7, levy + 4)
                mana_list.add(mana)
                all_sprites_list.add(mana)
            if col == "H":
                health = sprite_classes.Health(levx + 7, levy + 4, screenx, screeny)
                health_list.add(health)
                all_sprites_list.add(health)
            if col == "1":
                enemy = sprite_classes.Enemy(levx + 9, levy + 6, 'standard')
                enemy_list.add(enemy)
                all_sprites_list.add(enemy)
            if col == "2":
                enemy = sprite_classes.Enemy(levx + 9, levy + 6, 'flyer')
                enemy_list.add(enemy)
                all_sprites_list.add(enemy)
            if col == "O":
                portal = sprite_classes.Portal(levx, levy, screenx, screeny)
            levx += screenx / 20
        levy += screeny / 20
        levx = 0
Exemplo n.º 2
0
 def spawn_tree(self, side):
     if side == 'left':
         xL = random.randint(5, 70)
         sp_treeL = self.factory.from_image(RESOURCES.get_path('tree.bmp'))
         self.treeL = sprite_classes.Enemy(self.world, sp_treeL, (0, 1), xL,
                                           50, False)
         self.treeL.setDepth(3)
     elif side == 'right':
         xR = random.randint(715, 775)
         sp_treeR = self.factory.from_image(RESOURCES.get_path('tree.bmp'))
         self.treeR = sprite_classes.Enemy(self.world, sp_treeR, (0, 1), xR,
                                           70, False)
         self.treeR.setDepth(3)
Exemplo n.º 3
0
 def spawn_rock(self):
     x = random.randint(90, 610)
     sp_rock = self.factory.from_image(RESOURCES.get_path('small_rock.bmp'))
     self.rock = sprite_classes.Enemy(self.world, sp_rock, (0, 1), x, 50,
                                      False)
     self.rock.setDepth(3)
     self.rock.size.size = 99
Exemplo n.º 4
0
 def spawn_whirlpool(self):
     x = random.randint(90, 610)
     sp_whirlpool = self.factory.from_image(
         RESOURCES.get_path('whirlpool.bmp'))
     self.whirlpool = sprite_classes.Enemy(self.world, sp_whirlpool, (0, 1),
                                           x, 50, False)
     self.whirlpool.setDepth(3)
     self.whirlpool.size.size = 50
Exemplo n.º 5
0
 def spawn(self, path, size, depth, ai_flag):
     v = random.randint(1, 10)
     x = random.randint(90, 610)
     sp_enemy = self.factory.from_image(RESOURCES.get_path(path))
     self.enemy = sprite_classes.Enemy(self.world, sp_enemy, (0, v), x, 0,
                                       ai_flag)
     self.enemy.size.size = size
     self.enemy.setDepth(depth)
Exemplo n.º 6
0
 def add_image_sprite(self, filename, s_type, x, y, depth):
     self.sp_new_sprite = self.factory.from_image(
         RESOURCES.get_path(filename))
     if s_type == 'inert':
         self.new_sprite = sprite_classes.Inert(self.world,
                                                self.sp_new_sprite, x, y)
     elif s_type == 'player':
         self.new_sprite = sprite_classes.Player(self.world,
                                                 self.sp_new_sprite, x, y)
     elif s_type == 'enemy':
         self.new_sprite = sprite_classes.Enemy(self.world,
                                                self.sp_new_sprite, x, y)
     self.new_sprite.setDepth(depth)
Exemplo n.º 7
0
 def render_play(self):
     music.play_music('Chiptune.wav', -1)  # Play background music
     music.play_sample('Bubbles.wav', True)
     self.init_salmon(450, 550)
     self.init_energy_bar()
     # Init river & riverbanks then bring up the HUD:
     self.sp_river = self.factory.from_image(
         RESOURCES.get_path('river.bmp'))
     self.river = sprite_classes.Inert(self.world, self.sp_river, 0, 50)
     self.river.setDepth(1)
     self.sp_river_top = self.factory.from_image(
         RESOURCES.get_path('top.bmp'))
     self.sp_river_bottom = self.factory.from_image(
         RESOURCES.get_path('bottom.bmp'))
     self.river_top = sprite_classes.Enemy(self.world, self.sp_river_top,
                                           (0, 1), 0, -550, False)
     self.river_bottom = sprite_classes.Enemy(self.world,
                                              self.sp_river_bottom, (0, 1),
                                              0, 50, False)
     self.river_top.setDepth(2)
     self.river_bottom.setDepth(2)
     self.dashboard.setDepth(4)
     self.world.process()
Exemplo n.º 8
0
 def manage_spawn(self, delta_t):
     num = random.randint(1, 3)
     ai_flag = True if num == 1 else False  # Give 1/3 of enemies ai
     esize_lbound = self.salmon.size.size - 2 if self.salmon.size.size - 2 > 0 else 0
     esize_ubound = self.salmon.size.size + 3 if self.salmon.size.size + 3 <= 14 else 14
     if self.salmon.energy.energy < 52:  # If energy in red zone, spawn smaller enemies
         esize_index = random.randint(esize_lbound, esize_ubound - 1)
     else:
         esize_index = random.randint(esize_lbound, esize_ubound)
     esize = self.esizes[esize_index]
     if esize < self.salmon.size.size:
         ai_flag = False
     enemy_str = 'enemy' + str(esize) + '.bmp'
     self.spawn(enemy_str, esize, 3, ai_flag)
     # End game easter egg:
     if self.salmon.size.size == 16 and globals.evil_fish == False:
         sp_evil_fish = self.factory.from_image(
             RESOURCES.get_path('evil_fish.bmp'))
         self.evil_fish = sprite_classes.Enemy(self.world, sp_evil_fish,
                                               (0, 1), 100, -720, False)
         self.evil_fish.size.size = 101
         self.evil_fish.setDepth(3)
         globals.evil_fish = True