Exemplo n.º 1
0
Arquivo: main.py Projeto: tbourg/perso
display.flip()
key.set_repeat(50, 55)
# FIN


if joystick.get_count() > 0:
    Joy = joystick.Joystick(0)
    Joy.init()


while True:
    time.Clock().tick(30)
    Window.fill(const.Porange)    

    for event in handle_widgets():
        if event.type == QUIT:
            quit()
            exit()
                    
        elif event.type == JOYAXISMOTION:
            if event.axis == 1:
                if round(event.value) < 0:
                    if not perso.che_jaune:
                        perso.move(const.up)
                if round(event.value) > 0:
                    if not perso.che_jaune:
                        perso.move(const.down)
            if event.axis == 0:
                if round(event.value) < 0:
                    if not perso.che_jaune:
Exemplo n.º 2
0
Window = pygame.display.set_mode((WW, WH))
icone = image.load(const.imagespath + avatars[0] + ".png")
icone.set_colorkey(const.pink)
pygame.display.set_icon(icone)
pygame.display.set_caption("Xilarius")
pygame.mixer.music.load(const.musicpath + "Ultralounge.wav")
pygame.mixer.music.play(-1, 0.0)
img_background = image.load(const.imagespath +
                            "Main_Background.png").convert_alpha()
img_character = image.load(const.imagespath +
                           "Character_boy_Large.png").convert_alpha()
img_bubble = image.load(const.imagespath + "bubble.png").convert_alpha()
'''----------------Main loop starts----------------'''
while running:
    pygame.time.Clock().tick(10)
    for event in handle_widgets():
        if event.type == QUIT:
            quit()
            exit()
    if on_game:
        Window.fill(const.green)
        #Hint images for level 1
        if dificulty_level == 1:
            if numero_hint == 1:
                img = images[0]
            elif numero_hint == 2:
                img = images[1]
            elif numero_hint == 3:
                img = images[2]
            elif numero_hint == 4:
                img = images[3]
Exemplo n.º 3
0
def main(difficulty):
    #---------------------Pygame init--------------------#

    myfont = font.SysFont("monospace", 15)
    #Création de la fenêtre
    WW, WH = 640, 480
    Window = display.set_mode((WW, WH))

    #icone = image.load("Bipo.png")
    #icone.set_colorkey(const.pink)
    #display.set_icon(icone)
    # FIN

    if difficulty == 0:
        time_limit = 40
    elif difficulty == 1:
        time_limit = 30
    elif difficulty == 2:
        time_limit = 20

    #---------------------Some variables--------------------#
    mylaby = laby(5, 5)
    mylaby.generate_laby()
    perso = Perso(mylaby)

    perso_time = 0
    display.flip()
    key.set_repeat(50, 55)
    # FIN

    first_time = time.time()

    while True:
        current_time = time.time()
        Window.fill(const.Porange)

        time_play = int(current_time - first_time)
        label = myfont.render(str(time_limit - time_play), 1, (0, 0, 0))
        Window.blit(label, (200, 0))

        if time_play >= time_limit:
            return -1

        for event in handle_widgets():
            if event.type == QUIT:
                quit()
                exit()

        pygame.time.wait(50)
        keys = key.get_pressed()
        if keys:
            if keys[K_UP]:
                if not perso.che_jaune:
                    perso.move(const.up)
            if keys[K_DOWN]:
                if not perso.che_jaune:
                    perso.move(const.down)
            if keys[K_LEFT]:
                if not perso.che_jaune:
                    perso.move(const.left)
            if keys[K_RIGHT]:
                if not perso.che_jaune:
                    perso.move(const.right)

        perso.show(Window)
        render_widgets()
        display.flip()

        if perso.x == perso.laby.w - 1 and perso.y == perso.laby.h - 1:
            return 0
Exemplo n.º 4
0
def main(difficulty):
    #---------------------Pygame init--------------------#
    init()

    myfont = font.SysFont("monospace", 15)
    #Création de la fenêtre
    WW, WH = 640, 480
    Window = display.set_mode((WW, WH))

    #icone = image.load("Bipo.png")
    #icone.set_colorkey(const.pink)
    #display.set_icon(icone)
    display.set_caption("Bipo Maze")
    # FIN

    if difficulty == 1:
        taille = 10
    elif difficulty == 2:
        taille = 11
    elif difficulty == 3:
        taille = 12


    #---------------------Some variables--------------------#
    mylaby = laby(taille, taille)
    mylaby.generate_laby()
    perso = Perso(mylaby) 
        
    perso_time = 0
    display.flip()
    key.set_repeat(50, 55)
    # FIN


    while True:
        time.Clock().tick(30)
        Window.fill(const.Porange)

        time_play = time.get_ticks()/1000
        label = myfont.render(str(time_play), 1, (0,0,0))
        Window.blit(label, (200, 0))

        for event in handle_widgets():
            if event.type == QUIT:
                quit()
                exit()
            
        keys = key.get_pressed()
        if keys:
            if keys[K_UP]:
                if not perso.che_jaune:
                    perso.move(const.up)
            if keys[K_DOWN]:
                if not perso.che_jaune:
                    perso.move(const.down)
            if keys[K_LEFT]:
                if not perso.che_jaune:
                    perso.move(const.left)
            if keys[K_RIGHT]:
                if not perso.che_jaune:
                    perso.move(const.right)
                   

        perso.show(Window)
        render_widgets()
        display.flip()
        
        if perso.x == perso.laby.w - 1 and perso.y == perso.laby.h - 1:
            quit()
            exit()