예제 #1
0
def main():
    clock = pg.time.Clock()
    input_box1 = InputBox(350, 150, 140, 32)
    input_box2 = InputBox(350, 250, 140, 32)
    input_box3 = InputBox(350, 350, 140, 32)
    input_box4 = InputBox(350, 450, 140, 32)
    input_boxes = [input_box1, input_box2, input_box3, input_box4]
    done = False
    bg_main = pg.image.load("QImages\\road.jpg")
    icon = pg.image.load('vampire.png')
    pg.display.set_caption("Brain Rush!")
    pg.display.set_icon(icon)

    while not done:

        screen.blit(bg_main, (0, 0))

        for box in input_boxes:
            box.update()

        for box in input_boxes:
            box.draw(screen)

        screen.blit(BFONT.render('Sign up now!', True, (0, 0, 0)), (370, 50))
        screen.blit(FONT.render('Username', True, (0, 0, 0)), (210, 155))
        screen.blit(FONT.render('Password', True, (0, 0, 0)), (210, 255))
        screen.blit(FONT.render('Email', True, (0, 0, 0)), (210, 355))
        screen.blit(FONT.render('Date of birth', True, (0, 0, 0)), (210, 455))
        screen.blit(FONT.render('(YYYY-MM-DD)', True, (0, 0, 0)), (555, 455))

        mouse = pg.mouse.get_pos()
        click = pg.mouse.get_pressed()
        button('Register', 375, 550, 150, 32, screen)

        for event in pg.event.get():
            if event.type == pg.QUIT:
                done = True
                pg.quit()
            for box in input_boxes:
                box.handle_event(event)

        if 525 > mouse[0] > 375 and 582 > mouse[1] > 550 and click[
                0] == 1 and not done:
            username, pwd, email, dob = input_boxes[0].text, input_boxes[
                1].text, input_boxes[2].text, input_boxes[3].text
            if username and pwd and email and dob and validateUsername(
                    username, pwd, email, dob):
                done = True
                homepage.main(username)
            elif not username or not pwd or not dob or not email:
                showError('Please fill all fields', screen, 300)

        try:
            pg.display.update()
        except:
            pass
        clock.tick(30)
def finish_press():
    if (side == "Departure"):
        write_flag()
        root.destroy()
        homepage.main()
    elif (side == "Arrival"):
        write_flag()
        root.destroy()
        homepage.main()
    '''var = IntVar()
예제 #3
0
def main():
    clock = pg.time.Clock()
    input_box1 = InputBox(350, 250, 140, 32)
    input_box2 = InputBox(350, 350, 140, 32)
    input_boxes = [input_box1, input_box2]
    done = False
    bg_main = pg.image.load("QImages\\road.jpg")
    pg.display.set_caption("Brain Rush!")
    playerImg = pg.image.load('vampire.png')
    pg.display.set_icon(playerImg)

    while not done:

        screen.blit(bg_main, (0, 0))

        for box in input_boxes:
            box.update()

        input_box1.draw(screen, True)
        input_box2.draw(screen, False)

        screen.blit(BFONT.render('Brain Rush!', True, (0, 0, 0)), (325, 50))
        screen.blit(playerImg, (375, 100))
        screen.blit(FONT.render('Username', True, (0, 0, 0)), (220, 250))
        screen.blit(FONT.render('Password', True, (0, 0, 0)), (220, 350))
        screen.blit(font.render("Don't have an account? ", True, (0, 0, 0)),
                    (115, 550))

        mouse = pg.mouse.get_pos()
        click = pg.mouse.get_pressed()

        button('Login', 390, 450, 100, 32)
        button('Sign up!', 270, 540, 100, 32)
        button('Forgot password?', 520, 540, 150, 32)

        for event in pg.event.get():
            if event.type == pg.QUIT:
                done = True
                pg.quit()
            for box in input_boxes:
                box.handle_event(event)

        if 490 > mouse[0] > 390 and 482 > mouse[1] > 450 and click[
                0] == 1 and not done:
            username, pwd = input_boxes[0].text, input_boxes[1].text
            if username and pwd and validatePwd(username, pwd):
                done = True
                homepage.main(username)

        if 370 > mouse[0] > 270 and 572 > mouse[1] > 540 and click[
                0] == 1 and not done:
            done = True
            signup.main()

        if 670 > mouse[0] > 520 and 572 > mouse[1] > 540 and click[
                0] == 1 and not done:
            done = True
            forgotpswd.main()

        try:
            pg.display.update()
        except:
            pass
        clock.tick(30)
예제 #4
0
def main(username):
    def getscores():
        con = mysql.connector.connect(host='localhost',
                                      user='******',
                                      passwd=password,
                                      database='brain_rush')
        if con.is_connected():
            try:
                cur = con.cursor(buffered=True)
                cur.execute(
                    'select username,high_score from user_dets order by high_score desc;'
                )
                result = cur.fetchall()
                x = result
            except mysql.connector.Error:
                showError('Database Issue; Please Try Later', screen)
                x = False
            finally:
                con.close()
                return x
        else:
            showError('Error Connecting to Database; Please Try Later', screen)
            return False

    screen = pg.display.set_mode((800, 640), pg.RESIZABLE)

    clock = pg.time.Clock()
    done = False
    loop = 1
    pg.display.set_caption("Brain Rush!")
    icon = pg.image.load('vampire.png')
    bg_main = pg.image.load("QImages\\lbpg.jpg")
    pg.display.set_icon(icon)

    while not done:

        screen.blit(bg_main, (0, 0))

        if loop:
            start_time = time.time()
            show = True
            while show:
                if time.time() - start_time > 0.088:
                    show = False
            loop = 0

        screen.blit(BFONT.render('Leaderboard', True, (0, 0, 0)), (310, 30))
        screen.blit(BFONT.render('Username', True, (0, 0, 0)), (140, 100))
        screen.blit(BFONT.render('High Score', True, (0, 0, 0)), (510, 100))
        a = getscores()
        if a:
            y = 170
            for i in a:
                screen.blit(FONT.render(i[0], True, (0, 0, 0)), (150, y))
                screen.blit(FONT.render(str(i[1]), True, (0, 0, 0)), (530, y))
                y += 50
        mouse = pg.mouse.get_pos()
        click = pg.mouse.get_pressed()

        button('Back', 290, 550, 200, 42, screen)

        for event in pg.event.get():
            if event.type == pg.QUIT:
                done = True
                pg.quit()

        if 520 > mouse[0] > 320 and 592 > mouse[1] > 550 and click[
                0] == 1 and not done:
            done = True
            homepage.main(username)

        try:
            pg.display.update()
        except:
            pass
        clock.tick(30)
예제 #5
0
def main():
    clock = pg.time.Clock()
    input_box1 = InputBox(470, 200, 140, 32)
    input_box2 = InputBox(470, 300, 140, 32)
    input_box3 = InputBox(470, 400, 140, 32)
    input_box4 = InputBox(470, 500, 140, 32)
    input_boxes = [input_box1, input_box2, input_box3, input_box4]
    done = False
    bg_main = pg.image.load("QImages\\road.jpg")
    pg.display.set_caption("Brain Rush!")
    playerImg = pg.image.load('vampire.png')
    pg.display.set_icon(playerImg)

    while not done:

        screen.blit(bg_main, (0, 0))

        for box in input_boxes:
            box.update()

        for box in input_boxes:
            box.draw(screen)

        mouse = pg.mouse.get_pos()
        click = pg.mouse.get_pressed()

        screen.blit(BFONT.render('Brain Rush!', True, (0, 0, 0)), (325, 50))
        screen.blit(playerImg, (375, 100))
        screen.blit(FONT.render("Username", True, (0, 0, 0)), (100, 200))
        screen.blit(FONT.render('Email', True, (0, 0, 0)), (100, 300))
        screen.blit(FONT.render('Date Of Birth', True, (0, 0, 0)), (100, 400))
        screen.blit(FONT.render('New password', True, (0, 0, 0)), (100, 500))

        button('Set password', 300, 580, 175, 32, screen)
        button('Back', 50, 580, 150, 32, screen)

        for event in pg.event.get():
            if event.type == pg.QUIT:
                done = True
                pg.quit()
            for box in input_boxes:
                box.handle_event(event)

        if 475 > mouse[0] > 300 and 612 > mouse[1] > 580 and click[
                0] == 1 and not done:
            Username, Email, DOB, new_pwd = input_boxes[0].text, input_boxes[
                1].text, input_boxes[2].text, input_boxes[3].text
            if Username and Email and DOB and new_pwd and validateUser(
                    Username, Email, DOB, new_pwd) and not done:
                done = True
                showError('Password has been reset', screen)
                homepage.main(Username)

        if 200 > mouse[0] > 50 and 612 > mouse[1] > 580 and click[
                0] == 1 and not done:
            done = True
            loginpage.main()

        try:
            pg.display.update()
        except:
            pass
        clock.tick(30)
예제 #6
0
def main(username):

    def deleteAccount(username, PWD):
        con = mysql.connector.connect(
            host='localhost', user='******', passwd=password, database='brain_rush')
        if con.is_connected():
            try:
                cur = con.cursor(buffered=True)
                cur.execute(
                    'select pwd from user_dets where username="******"'.format(username))
                pwd = cur.fetchone()[0]
                if pwd == PWD:
                    cur.execute(
                        'delete from user_dets where username="******"'.format(username))
                    con.commit()
                    return True
                else:
                    showError('Incorrect password', screen, x=300)
            except mysql.connector.Error:
                showError('Database Issue; Please Try Later', screen)
                return False
            finally:
                con.close()
        else:
            showError('Error Connecting to Database; Please Try Later', screen)
            return False

    def delAcc(username):
        inputbox = change_pwd.InputBox(375, 250, 200, 40)
        over = False
        while not over:
            inputbox.update()
            screen.fill((174, 214, 220))
            bg_main = pg.image.load("QImages\\brain.jpg")
            screen.blit(bg_main, (0, 0))
            inputbox.draw(screen)
            mouse = pg.mouse.get_pos()
            click = pg.mouse.get_pressed()
            screen.blit(FONT.render('Enter Password',
                                    True, (0, 0, 0)), (150, 260))
            button('Submit', 320, 350, 150, 32, screen)
            if 470 > mouse[0] > 320 and 382 > mouse[1] > 350 and click[0] == 1 and not over:
                over = True
            for event in pg.event.get():
                if event.type == pg.QUIT:
                    over = True
                    return 'QUIT'
                inputbox.handle_event(event)
            try:
                pg.display.update()
            except:
                pass
        password = inputbox.text
        if deleteAccount(username, password):
            showError('Account deleted', screen, 300)
            return 'signup'
        else:
            return 'homepage'

    def getEmail(username):
        con = mysql.connector.connect(
            host='localhost', user='******', passwd=password, database='brain_rush')
        if con.is_connected():
            try:
                cur = con.cursor(buffered=True)
                cur.execute(
                    'select email from user_dets where username="******"'.format(username))
                email = cur.fetchone()[0]
                return email
            except mysql.connector.Error:
                showError('Database Issue; Please Try Later', screen)
                return False
            finally:
                con.close()
        else:
            showError('Error Connecting to Database; Please Try Later', screen)
            return False

    screen = pg.display.set_mode((800, 640), pg.RESIZABLE)

    clock = pg.time.Clock()
    done = False
    loop = 1
    bg_main = pg.image.load("QImages\\brain.jpg")
    icon = pg.image.load('vampire.png')
    pg.display.set_caption("Brain Rush!")
    pg.display.set_icon(icon)
    while not done:

        screen.blit(bg_main, (0, 0))

        if loop:
            start_time = time.time()
            show = True
            while show:
                if time.time() - start_time > 0.088:
                    show = False
            loop = 0

        screen.blit(BFONT.render('Username: '******'Email: '+email,
                                     True, (0, 0, 0)), (120, 100))
        else:
            screen.blit(BFONT.render('Email: ', True, (0, 0, 0)), (120, 100))
        mouse = pg.mouse.get_pos()
        click = pg.mouse.get_pressed()

        button('Change password', 115, 250, 200, 42, screen)
        button('Delete account', 520, 250, 200, 42, screen)
        button('Return to homepage', 300, 350, 250, 42, screen)
        button('Logout', 320, 450, 200, 42, screen)

        for event in pg.event.get():
            if event.type == pg.QUIT:
                done = True
                pg.quit()

        if 315 > mouse[0] > 115 and 292 > mouse[1] > 250 and click[0] == 1 and not done:
            done = True
            change_pwd.main(username)

        if 720 > mouse[0] > 520 and 292 > mouse[1] > 250 and click[0] == 1 and not done:
            done = True
            result = delAcc(username)
            if result == 'QUIT':
                pg.quit()
            elif result == 'signup':
                signup.main()
            else:
                homepage.main(username)

        if 520 > mouse[0] > 320 and 492 > mouse[1] > 450 and click[0] == 1 and not done:
            done = True
            loginpage.main()

        if 550 > mouse[0] > 300 and 392 > mouse[1] > 350 and click[0] == 1 and not done:
            done = True
            homepage.main(username)

        try:
            pg.display.update()
        except:
            pass
        clock.tick(30)
def main():
    playsound('into_battle.mp3')
    homepage.main()
예제 #8
0
def homescreen():
    homepage.main()
예제 #9
0
def main(username):
    done = False
    i = 0
    bg_main = pg.image.load("QImages\\road.jpg")
    playerImg = pg.image.load('vampire.png')
    pg.display.set_caption("Brain Rush!")
    pg.display.set_icon(playerImg)
    ImgList = [
        pg.image.load('TutorialImages\\1.png'),
        pg.image.load('TutorialImages\\2.png'),
        pg.image.load('TutorialImages\\3.png'),
        pg.image.load('TutorialImages\\4.png'),
        pg.image.load('TutorialImages\\5.png'),
        pg.image.load('TutorialImages\\6.png'),
        pg.image.load('TutorialImages\\7.png'),
        pg.image.load('TutorialImages\\8.png'),
        pg.image.load('TutorialImages\\9.png'),
        pg.image.load('TutorialImages\\10.png'),
        pg.image.load('TutorialImages\\11.png')
    ]
    while not done:

        screen.blit(bg_main, (0, 0))

        screen.blit(font.render('How To Play', True, (0, 0, 0)), (325, 40))

        mouse = pg.mouse.get_pos()
        click = pg.mouse.get_pressed()

        functions.button('Back', 320, 550, 150, 32, screen)
        functions.button('>', 700, 300, 50, 40, screen)
        functions.button('<', 50, 300, 50, 40, screen)

        screen.blit(ImgList[i], (140, 80))

        for event in pg.event.get():
            if event.type == pg.QUIT:
                done = True
                pg.quit()

        if 470 > mouse[0] > 320 and 582 > mouse[1] > 550 and click[
                0] == 1 and not done:
            done = True
            homepage.main(username)

        if 750 > mouse[0] > 700 and 340 > mouse[1] > 300 and click[
                0] == 1 and not done:
            time.sleep(0.25)
            pg.event.wait()
            try:
                screen.blit(ImgList[i + 1], (140, 80))
                i += 1
            except:
                pass

        if 100 > mouse[0] > 50 and 340 > mouse[1] > 300 and click[
                0] == 1 and not done:
            time.sleep(0.25)
            pg.event.wait()
            try:
                if i == 0:
                    i = 1
                screen.blit(ImgList[i - 1], (140, 80))
                i -= 1
            except:
                pass

        try:
            pg.display.update()
        except:
            pass