Example #1
0
def main():
    pygame.init()
    mainScreen = pygame.display.set_mode((pygame.display.Info().current_w, pygame.display.Info().current_h), FULLSCREEN)
    mainScreenBG_image1 = Image("../images/menus/castelo_menu.png", (pygame.display.Info().current_w, pygame.display.Info().current_h), (0,0))
    mainScreenBG_image2 = Image("../images/menus/folhas_menu.png", (pygame.display.Info().current_w, pygame.display.Info().current_h), (0,0))
    play = (Image("../images/menus/play_image.png",(300,105), (900,175)))
    exit = (Image("../images/menus/exit_image.png",(300,105), (900,425)))
    tutorial = (Image("../images/menus/tutorial_image.png", (300,105),(900,300)))
    pygame.mixer.music.load('../sounds/music.mp3')
    pygame.mixer.music.play(-1)



    while True:
        for event in pygame.event.get():
            if event.type == QUIT: break
            if event.type == pygame.MOUSEBUTTONDOWN:
                if play.rect.collidepoint(pygame.mouse.get_pos()):
                    firstScreen.main(None, True)
                if exit.rect.collidepoint(pygame.mouse.get_pos()): sys.exit()
        mainScreen.blit(mainScreenBG_image1.surface, mainScreenBG_image1.position)
        mainScreen.blit(mainScreenBG_image2.surface, mainScreenBG_image2.position)
        mainScreen.blit(play.surface, play.position)
        mainScreen.blit(exit.surface, exit.position)

        pygame.display.update()
Example #2
0
def main():
    pygame.init()
    mainScreen = pygame.display.set_mode(
        (pygame.display.Info().current_w, pygame.display.Info().current_h),
        FULLSCREEN)
    mainScreenBG_image1 = Image(
        "../images/menus/castelo_menu.png",
        (pygame.display.Info().current_w, pygame.display.Info().current_h),
        (0, 0))
    mainScreenBG_image2 = Image(
        "../images/menus/folhas_menu.png",
        (pygame.display.Info().current_w, pygame.display.Info().current_h),
        (0, 0))
    play = (Image("../images/menus/play_image.png", (300, 105), (900, 175)))
    exit = (Image("../images/menus/exit_image.png", (300, 105), (900, 425)))
    tutorial = (Image("../images/menus/tutorial_image.png", (300, 105),
                      (900, 300)))
    pygame.mixer.music.load('../sounds/music.mp3')
    pygame.mixer.music.play(-1)

    while True:
        for event in pygame.event.get():
            if event.type == QUIT: break
            if event.type == pygame.MOUSEBUTTONDOWN:
                if play.rect.collidepoint(pygame.mouse.get_pos()):
                    firstScreen.main(None, True)
                if exit.rect.collidepoint(pygame.mouse.get_pos()): sys.exit()
        mainScreen.blit(mainScreenBG_image1.surface,
                        mainScreenBG_image1.position)
        mainScreen.blit(mainScreenBG_image2.surface,
                        mainScreenBG_image2.position)
        mainScreen.blit(play.surface, play.position)
        mainScreen.blit(exit.surface, exit.position)

        pygame.display.update()
Example #3
0
def main(character, winner = False):
    pygame.init();
    mainScreen = pygame.display.set_mode((800, 600), FULLSCREEN);
    mainScreenBG = Image("../images/maps/house_map.png", (800, 600), (0,0));
    clock = pygame.time.Clock();
    ironMan = Character(CharImage('../images/characters/ferro.png', 0, (400,300), (30, 30)));
    dice = Dice(DiceImage("../images/items/dice.png",0, [700,500], [25,32] ));
    key = Image("../images/items/key.png", (30,30), (420,100));
    if not winner : message = 1;
    else: message = 3;
    printKey, printDice = False, False;
    while True:
        
        pygame.display.update();
        keys = pygame.key.get_pressed();
        if keys[K_DOWN]:character.downMovement();
        elif keys[K_UP]:character.upMovement();
        elif keys[K_LEFT]:character.leftMovement();
        elif keys[K_RIGHT]:character.rightMovement();

        for event in pygame.event.get():
            if event.type == QUIT: break;
            if event.type == KEYDOWN:
                if event.key == K_SPACE:dice.anime = True;
                if event.key == K_RETURN and message <= 4: message += 1;
                if key.rect.collidepoint(character.image.position) and event.key == K_e:
                    character.bag.add_item("key", "slot1");
                    printKey = False;
                    pygame.display.update();
                    character.image.position = [500,350];
                    firstScreen.main(character, False, False, True);
                if(Rect(610,350,300,600).collidepoint(character.image.position) and not printDice): printDice = True;

        mainScreen.blit(mainScreenBG.surface, mainScreenBG.position);
        mainScreen.blit(ironMan.image.surface, ironMan.image.position, ironMan.image.rect);
        mainScreen.blit(character.image.surface, character.image.position, character.image.rect);

        if dice.anime:
            for i in range(300):
                result = dice.diceAnimation();
                mainScreen.blit(dice.diceImage, dice.dicePosition, dice.diceRect);
                pygame.display.update();
            if result == 6: result = None; printKey = True;
            dice.anime = False;
        elif printDice: mainScreen.blit(dice.diceImage, dice.dicePosition, dice.diceRect);

        if printKey: mainScreen.blit(key.surface, key.position); pygame.display.update();

        if message <= 2:
            mainScreen = showMessage(mainScreen, message);
            pygame.display.update();

        if winner and message <= 4:
            mainScreen = showMessage(mainScreen, message)
            pygame.display.update()
        pygame.display.update();
        time_passed = clock.tick(12);
Example #4
0
def main():
	firstScreen.main()
	root.mainloop()
Example #5
0
def main(fighter1, fighter2):
    pygame.init()
    mainScreen = pygame.display.set_mode((800, 600), FULLSCREEN)
    mainScreenBG = Image("../images/maps/cavern_map.png", (800, 600), (0,0))
    clock = pygame.time.Clock()
    dice = Dice(DiceImage("../images/items/dice.png",0, [400,300], [25,32] ))
    message = 1
    turn, result, printDice, dice.anime, gameOver = True, False, False,False, False;
    fighter1.image.position, fighter1.image.rect.x, fighter1.image.rect.y = [700,300],0,33 ;
    fighter2.image.position,fighter2.image.rect.x, fighter2.image.rect.y = [100,300],0, 66;
    dice.dicePosition = [400,300];
    while True:

        pygame.display.update()
        for event in pygame.event.get():
            if event.type == QUIT: break
            if event.type == KEYDOWN:
                if event.key == K_RETURN:
                    message += 1;
                    if message == 3: gameOver = True
                if event.key == K_SPACE:dice.anime = True


        mainScreen.blit(mainScreenBG.surface, mainScreenBG.position);
        if dice.anime:
            for i in range(300):
                dice, mainScreen, fighter1, fighter2, result  = diceAnime(dice, mainScreen, fighter1, fighter2)
                pygame.display.update()
            dice.anime = False;

        elif printDice: mainScreen.blit(dice.diceImage, dice.dicePosition, dice.diceRect);

        if result:
            if turn:
                fighter1.hp -= (fighter2.attack * result) - fighter1.defense
                fighter1.hpRect.x = fighter1.hp / 10
                turn = not turn
                result = None
            else:
                dice.anime = True
                fighter2.hp -= (fighter1.attack * result) - fighter2.defense
                fighter2.hpRect.x = fighter2.hp / 10
                turn = not turn
                result = None

        if message <= 1:
            mainScreen = showMessage(mainScreen, message);
            pygame.display.update();
        else: printDice = True

        if  fighter2.hp <= 0:
            message = 2
            mainScreen = showMessage(mainScreen, message)
            pygame.display.update()
            time.sleep(2)
            firstScreen.main(fighter1, False, False, False, False, True)

        elif fighter1.hp <= 0:
            message = 3
            mainScreen = showMessage(mainScreen, message)
            pygame.display.update()
            time.sleep(3)
            gameOver = True
            if gameOver: sys.exit()

        mainScreen.blit(fighter1.image.surface, fighter1.image.position, fighter1.image.rect)
        mainScreen.blit(fighter1.hpImage.surface, fighter1.hpImage.position, fighter1.hpRect)
        mainScreen.blit(fighter2.image.surface, fighter2.image.position, fighter2.image.rect)
        mainScreen.blit(fighter2.hpImage.surface, fighter2.hpImage.position, fighter2.hpRect)

        pygame.display.update()
        time_passed = clock.tick(12)
Example #6
0
def main(character, winner=False):
    pygame.init()
    mainScreen = pygame.display.set_mode((800, 600), FULLSCREEN)
    mainScreenBG = Image("../images/maps/house_map.png", (800, 600), (0, 0))
    clock = pygame.time.Clock()
    ironMan = Character(
        CharImage('../images/characters/ferro.png', 0, (400, 300), (30, 30)))
    dice = Dice(DiceImage("../images/items/dice.png", 0, [700, 500], [25, 32]))
    key = Image("../images/items/key.png", (30, 30), (420, 100))
    if not winner: message = 1
    else: message = 3
    printKey, printDice = False, False
    while True:

        pygame.display.update()
        keys = pygame.key.get_pressed()
        if keys[K_DOWN]: character.downMovement()
        elif keys[K_UP]: character.upMovement()
        elif keys[K_LEFT]: character.leftMovement()
        elif keys[K_RIGHT]: character.rightMovement()

        for event in pygame.event.get():
            if event.type == QUIT: break
            if event.type == KEYDOWN:
                if event.key == K_SPACE: dice.anime = True
                if event.key == K_RETURN and message <= 4: message += 1
                if key.rect.collidepoint(
                        character.image.position) and event.key == K_e:
                    character.bag.add_item("key", "slot1")
                    printKey = False
                    pygame.display.update()
                    character.image.position = [500, 350]
                    firstScreen.main(character, False, False, True)
                if (Rect(610, 350, 300, 600).collidepoint(
                        character.image.position) and not printDice):
                    printDice = True

        mainScreen.blit(mainScreenBG.surface, mainScreenBG.position)
        mainScreen.blit(ironMan.image.surface, ironMan.image.position,
                        ironMan.image.rect)
        mainScreen.blit(character.image.surface, character.image.position,
                        character.image.rect)

        if dice.anime:
            for i in range(300):
                result = dice.diceAnimation()
                mainScreen.blit(dice.diceImage, dice.dicePosition,
                                dice.diceRect)
                pygame.display.update()
            if result == 6:
                result = None
                printKey = True
            dice.anime = False
        elif printDice:
            mainScreen.blit(dice.diceImage, dice.dicePosition, dice.diceRect)

        if printKey:
            mainScreen.blit(key.surface, key.position)
            pygame.display.update()

        if message <= 2:
            mainScreen = showMessage(mainScreen, message)
            pygame.display.update()

        if winner and message <= 4:
            mainScreen = showMessage(mainScreen, message)
            pygame.display.update()
        pygame.display.update()
        time_passed = clock.tick(12)