Example #1
0
    def __init__(self):
        maze1 = Maze("level1.txt")
        needle = Loot('N')
        ether = Loot('E')
        tube = Loot('T')
        maze1.generate()

        maze1.position_randomly([needle.disp, ether.disp, tube.disp])
        m_g = Mac(maze1)

        self.maze = maze1
        self.macg = m_g
Example #2
0
    def __init__(self):
        pygame.init()
        sprite_number = 15
        self.sprite_size = 50
        win_size = sprite_number * self.sprite_size
        self.screen = pygame.display.set_mode((win_size, win_size))
        self.macpic = pygame.image.load("macgyver.png").convert_alpha()
        self.murdoc = pygame.image.load("murdoc.png").convert_alpha()
        self.floor = pygame.image.load("tile1.png").convert_alpha()
        self.wall = pygame.image.load("wall2.png").convert_alpha()
        self.game_over = pygame.image.load("gameover.png").convert_alpha()
        ether_pic = pygame.image.load("ether.png").convert_alpha()
        needle_pic = pygame.image.load("needle.png").convert_alpha()
        tube_pic = pygame.image.load("tube.png").convert_alpha()
        self.stairs = pygame.image.load("stairs.png").convert_alpha()
        self.well_done = pygame.image.load("welldone.png").convert_alpha()
        self.item_pics = []
        self.item_pics.append(ether_pic)
        self.item_pics.append(tube_pic)
        self.item_pics.append(needle_pic)
        pygame.display.set_caption("MazeGyver")
        pygame.display.set_icon(self.macpic)
        maze1 = Maze("level1.txt")
        needle = Loot('N')
        ether = Loot('E')
        tube = Loot('T')
        maze1.generate()

        maze1.position_randomly([needle.disp, ether.disp, tube.disp])
        m_g = Mac(maze1)

        self.walls = maze1.wall_positions
        self.mac_pos = maze1.mac_position
        self.guard_pos = maze1.guardian_position
        self.item_pos = maze1.item_pos
        self.path = maze1.paths
        self.maze = maze1
        self.macg = m_g

        for (x_a, y_a) in self.path:
            self.screen.blit(self.floor, (y_a * self.sprite_size, x_a * self.sprite_size))

        for (x_a, y_a) in self.walls:
            self.screen.blit(self.wall, (y_a * self.sprite_size, x_a * self.sprite_size))

        (x_a, y_a) = self.guard_pos
        self.screen.blit(self.stairs, (y_a * self.sprite_size, x_a * self.sprite_size))

        (x_a, y_a) = self.guard_pos
        self.screen.blit(self.murdoc, (y_a * self.sprite_size, x_a * self.sprite_size))

        for (x_a, y_a), item_pic in zip(self.item_pos, self.item_pics):
            self.screen.blit(item_pic, (y_a * self.sprite_size, x_a * self.sprite_size))
Example #3
0
 def randomize_object(self):
     self.objects = random.sample(self.way(), 3)
     # take 3 random positions in list created by way function
     self.needle = self.objects[0]
     # needle correspond to first object of random list
     self.tube = self.objects[1]
     # tube correspond to second object of random list
     self.ether = self.objects[2]
     # ether correspond to third object of random list
     self.pos_needle = Loot(self.needle.x * 40, self.needle.y * 40,
                            "needle")  # create needle as Loot object
     self.pos_tube = Loot(self.tube.x * 40, self.tube.y * 40,
                          "tube")  # create tube as Loot object
     self.pos_ether = Loot(self.ether.x * 40, self.ether.y * 40,
                           "ether")  # create ether as Loot object
Example #4
0
def Init():
    """ [Required] Initialize Data (Only called on load) """

    # settings initialization
    global settings
    settings = MySettings(config_file)
    settings.save()

    # database initialization
    global currency, db
    db = InstancedDatabase(database_file)
    currency = Currency(Parent, db, settings.name, settings.frequency * 60,
                        settings.quantity)
    currency.only_subs = settings.only_subs
    currency.exclude_users = settings.exclude_users

    # streamlabs notifies
    global streamlabs_api
    streamlabs_api = SLNotifies(Parent, currency, settings.streamlabs_bits)
    if settings.streamlabs_apikey:
        streamlabs_api.connect(settings.streamlabs_apikey)

    # loot initialization
    global loot
    loot = Loot(Parent, db)

    return
Example #5
0
def init_game():
    pygame.init()
    clock = pygame.time.Clock()
    game_set = Settings()

    animation = Animation()
    bullets = Group()

    screen = pygame.display.set_mode(
        (game_set.screen_width, game_set.screen_height))
    main_ch = Main_character(game_set, screen, animation)
    teleport = Teleport(screen, main_ch, game_set)
    loot = Loot(screen, game_set)
    while True:
        pygame.display.set_caption(game_set.title + " FPS: " +
                                   str(round(clock.get_fps(), 1)))

        clock.tick(game_set.fps)
        g_f.update_bullets(bullets)
        g_f.check_events(main_ch, game_set, screen, bullets, teleport)
        g_f.update_screen(game_set, screen, main_ch, bullets, teleport, loot)
        mousex, mousey = pygame.mouse.get_pos()
        print(mousex, mousey)
        #print(game_set.cam_x,game_set.cam_y)
        obstacle = pygame.draw.rect(game_set.bg_image_third, (255, 0, 0),
                                    (0, 2160, 3450, 2))
        print(main_ch.main_ch_rect.y, main_ch.main_ch_rect.x)
Example #6
0
 def __init__(self):
     self.sprite = Sprite()
     self.macgyver = Macgyver(40, 520, "m")  # create Macgyver object
     self.murdock = Murdock(520, 560, "murdock")  # create Murdock object
     self.win = False
     self.end = False
     self.objects = random.sample(self.way(), 3)
     # 3 random positions in list from way function
     self.needle = self.objects[0]
     # needle correspond to first object in random list
     self.tube = self.objects[1]
     # tube correspond to second object in random list
     self.ether = self.objects[2]
     # ether correspond to third object in random list
     self.pos_needle = Loot(self.needle.x * 40, self.needle.y * 40,
                            "needle")  # create needle as Loot object
     self.pos_tube = Loot(self.tube.x * 40, self.tube.y * 40,
                          "tube")  # create tube as Loot object
     self.pos_ether = Loot(self.ether.x * 40, self.ether.y * 40,
                           "ether")  # create ether as Loot object
Example #7
0
def load(file_name):
    try:
        load = open(file_name)
        # read the player name
        name = load.readline()
        # read the player class
        character_class = load.readline()
        # make the player
        hero = Hero(name, character_class)
        # Load  the level
        level = int(load.readline())
        for i in range(level):
            hero.giveXP(10000)
        # load the current xp
        xp = int(load.readline())
        hero.giveXP(xp)
        # load the food
        food = int(load.readline())
        hero.giveFood(food)
        # load the gold
        gold = int(load.readline())
        hero.giveGold(gold)

        # Initialize a loot list
        loot = Loot()

        # Get a list of items add them to the player's inventory
        item_string = ""
        load.readline()
        if (load.hasNextLine()):
            item_string = load.readline()
        """
        Scanner items = new Scanner(itemString)
        while(items.hasNextInt()):
            uniqueID = items.nextInt()
            hero.inventory.add(loot.getItem(uniqueID))
        
        # equip items
        String equippedString = ""
        if(input.hasNextLine()):
            equippedString = input.nextLine()
        
        Scanner equipped = new Scanner(equippedString)
        while(equipped.hasNextInt()):
            uniqueID = equipped.nextInt()
            hero.inventory.equip(uniqueID, hero)
        
        hero.inventory.list()
        
        return hero
        """
    except FileNotFoundError:
        print("File Not Found")
MONSTER_CHANCE = 0
#60 % chance of fighting a monster
#public static final int DARK_ROOM_CHANCE = 60
#(10 % chance) we come to a dark room..
#public static final int TRAP_ROOM_CHANCE = 80
#(5 % chance) we come to a dark room..
BASIC_TREASURE_CHANCE = 85
#(5 % chance) 1-2 basic items
ADVANCED_TREASURE_CHANCE = 90
#(3 % chance) 1-2 advanced items
EPIC_TREASURE_CHANCE = 93
#(6 % chance)1-2 epic treasure chest
EXIT_CHANCE = 99
# 1 percent of the time we reach exit
hero = None
loot = Loot()


def intro():
    #Display for Intro
    print(
        fg.green, bg.black + """
    ******----******----******
    Welcome to Dungeon Heroes!
    ******----******----******""" + fg.red + """
    \^~~~~\\   )  (   /~~~~^/  
     ) *** \\  {**}  / *** (   
      ) *** \\_ ^^ _/ *** (    
      ) ****   vv   **** (    
       )_****      ****_(     
         )*** m  m ***(      """ + fg.rs, bg.rs)
Example #9
0
    def __init__(self):
        """Constructor of the class"""
        pygame.init()
        # inivible cursor
        pygame.mouse.set_cursor((8, 8), (0, 0), (0, 0, 0, 0, 0, 0, 0, 0),
                                (0, 0, 0, 0, 0, 0, 0, 0))
        # set size of window
        WINDOW = pygame.display.set_mode((450, 450))
        # set icon of window
        ICO = pygame.image.load(IMG_ICO)
        # load the level
        LEVEL = Maze(MAZE)
        # generate the level
        LEVEL.generate()
        # load BACKGROUND
        BACKGROUND = pygame.image.load(IMG_BACKGROUND).convert()
        # load BAG and IN_BAG
        BAG = pygame.image.load(IMG_BAG).convert_alpha()
        IN_BAG = pygame.image.load(IMG_IN_BAG).convert_alpha()
        # display BACKGROUND
        WINDOW.blit(BACKGROUND, (0, 0))
        # display maze
        LEVEL.display(WINDOW)
        # display BAG and IN_BAG
        WINDOW.blit(BAG, (0, 418))
        WINDOW.blit(IN_BAG, (37, 418))
        # load MAZE_SONG
        MAZE_SONG = pygame.mixer.Sound("maze_song.ogg")
        # play song
        MAZE_SONG.play(loops=-1, maxtime=0, fade_ms=0)
        # load Macgyver sprites according to the axis
        MG = Macgyver("images/macgyver_right.png", "images/macgyver_left.png",
                      "images/macgyver_up.png", "images/macgyver_down.png",
                      LEVEL)
        # Load loot
        TUBE_IMG = pygame.image.load(C_TUBE).convert_alpha()
        NEEDLE_IMG = pygame.image.load(C_NEEDLE).convert_alpha()
        ETHER_IMG = pygame.image.load(C_ETHER).convert_alpha()

        # Sprite of loot
        TUBE = Loot(TUBE_IMG, LEVEL)
        TUBE.display(TUBE_IMG, WINDOW)
        NEEDLE = Loot(NEEDLE_IMG, LEVEL)
        NEEDLE.display(NEEDLE_IMG, WINDOW)
        ETHER = Loot(ETHER_IMG, LEVEL)
        ETHER.display(ETHER_IMG, WINDOW)
        # Var
        game = True
        Tube_Picked = False
        Ether_Picked = False
        Needle_Picked = False
        YOU_WIN = False
        YOU_LOSE = False
        # Load win and lose img
        WIN = pygame.image.load(IMG_WIN).convert()
        LOSE = pygame.image.load(IMG_LOSE).convert()
        THREE = pygame.image.load(IMG_3).convert_alpha()
        TWO = pygame.image.load(IMG_2).convert_alpha()
        ONE = pygame.image.load(IMG_1).convert_alpha()
        END = pygame.image.load(IMG_END).convert_alpha()

        while game:

            pygame.time.Clock().tick(30)
            pygame.display.set_icon(ICO)
            pygame.display.set_caption(TITLE_WINDOW)

            for event in pygame.event.get():
                if event.type == KEYDOWN:
                    # display BACKGROUND
                    WINDOW.blit(BACKGROUND, (0, 0))
                    # display maze
                    LEVEL.display(WINDOW)
                    # display BAG and IN_BAG
                    WINDOW.blit(BAG, (0, 418))
                    WINDOW.blit(IN_BAG, (37, 418))
                    if Tube_Picked is False:
                        TUBE.display(TUBE_IMG, WINDOW)
                    if Tube_Picked is True:
                        WINDOW.blit(TUBE_IMG, (40, 418))
                    if Ether_Picked is False:
                        ETHER.display(ETHER_IMG, WINDOW)
                    if Ether_Picked is True:
                        WINDOW.blit(ETHER_IMG, (75, 418))
                    if Needle_Picked is False:
                        NEEDLE.display(NEEDLE_IMG, WINDOW)
                    if Needle_Picked is True:
                        WINDOW.blit(NEEDLE_IMG, (110, 418))
                    if event.key == K_RIGHT:
                        MG.move('right')
                    elif event.key == K_LEFT:
                        MG.move('left')
                    elif event.key == K_UP:
                        MG.move('up')
                    elif event.key == K_DOWN:
                        MG.move('down')
            # Display MacGyver
            WINDOW.blit(MG.axe, (MG.var_x, MG.var_y))
            # Refresh the display
            pygame.display.flip()
            # take the TUBE if Macgyver is on the TUBE
            if (MG.var_x, MG.var_y) == (TUBE.var_x, TUBE.var_y):
                Tube_Picked = True
            # take ETHER if Macgyver is on the ETHER
            if (MG.var_x, MG.var_y) == (ETHER.var_x, ETHER.var_y):
                Ether_Picked = True
            # take NEEDLE if Macgyver is on the NEEDLE
            if (MG.var_x, MG.var_y) == (NEEDLE.var_x, NEEDLE.var_y):
                Needle_Picked = True

            if (event.type == QUIT
                    or event.type == KEYDOWN and event.key == K_ESCAPE):
                game = False

            # EndGame Victory or lose
            # if macgyver arrives in front of the guard
            if LEVEL.is_end(MG.square_y, MG.square_x):
                # loot check
                if (Tube_Picked is True and Needle_Picked is True
                        and Ether_Picked is True):
                    YOU_WIN = True
                else:
                    YOU_LOSE = True

                if YOU_WIN is True:
                    WINDOW.blit(WIN, (0, 0))
                    WINDOW.blit(THREE, (200, 280))
                    pygame.display.flip()
                    time.sleep(1)
                    WINDOW.blit(WIN, (0, 0))
                    pygame.display.flip()
                    WINDOW.blit(TWO, (200, 280))
                    pygame.display.flip()
                    time.sleep(1)
                    WINDOW.blit(WIN, (0, 0))
                    pygame.display.flip()
                    WINDOW.blit(ONE, (200, 280))
                    pygame.display.flip()
                    time.sleep(1)
                    WINDOW.blit(WIN, (0, 0))
                    pygame.display.flip()
                    WINDOW.blit(END, (10, 300))
                    pygame.display.flip()
                    game = False

                if YOU_LOSE is True:
                    WINDOW.blit(LOSE, (0, 0))
                    WINDOW.blit(THREE, (200, 280))
                    pygame.display.flip()
                    time.sleep(1)
                    WINDOW.blit(LOSE, (0, 0))
                    pygame.display.flip()
                    WINDOW.blit(TWO, (200, 280))
                    pygame.display.flip()
                    time.sleep(1)
                    WINDOW.blit(LOSE, (0, 0))
                    pygame.display.flip()
                    WINDOW.blit(ONE, (200, 280))
                    pygame.display.flip()
                    time.sleep(1)
                    WINDOW.blit(LOSE, (0, 0))
                    pygame.display.flip()
                    WINDOW.blit(END, (10, 300))
                    pygame.display.flip()
                    game = False