コード例 #1
0
def endScreen():
    global score, best

    win.fill(bg)
    pygame.display.update()
    if best == -1:
        best = 'None'
    text = startfont1.render('Score: ' + str(round(score, 2)), 1,
                             (255, 255, 255))
    win.blit(text, (w_width / 2 - text.get_width() / 2,
                    w_height / 2 - text.get_height() / 2 - 30))
    text = startfont.render('Previous Best: ' + str(best), 1, (255, 255, 255))
    win.blit(text, (w_width / 2 - text.get_width() / 2,
                    w_height / 2 - text.get_height() / 2 + 45))
    text = displayFont.render('Press any Key To Continue', 1, (255, 255, 255))
    win.blit(text, (w_width / 2 - text.get_width() / 2, w_height - 40))
    pygame.display.update()
    loop = True
    leaderboard.addTimePlayed(curUsr, 'integerrecall', round(totalTime, 2))
    leaderboard.addGamesPlayed(curUsr, 'integerrecall')
    if score > best:
        leaderboard.addHighscore(curUsr, 'integerrecall', score)
        best = score
    while loop:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                loop = False
                pygame.quit()
            if event.type == pygame.KEYDOWN:
                loop = False
コード例 #2
0
def endScreen():
    global totalTime, best
    totalTime += 2.5 * wrong

    if tries == 26:
        win.fill(bg)
        pygame.display.update()
        text = startfont1.render('Time: ' + str(round(totalTime, 2)), 1,
                                 (255, 255, 255))
        win.blit(text, (w_width / 2 - text.get_width() / 2,
                        w_height / 2 - text.get_height() / 2 - 30))
        text = startfont.render('Previous Best: ' + str(best), 1,
                                (255, 255, 255))
        win.blit(text, (w_width / 2 - text.get_width() / 2,
                        w_height / 2 - text.get_height() / 2 + 45))
        text = displayFont.render('Press any Key To Continue', 1,
                                  (255, 255, 255))
        win.blit(text, (w_width / 2 - text.get_width() / 2, w_height - 40))
        pygame.display.update()
        loop = True
        leaderboard.addTimePlayed(curUsr, 'quicktype', round(totalTime, 2))
        leaderboard.addGamesPlayed(curUsr, 'quicktype')
        if best == 0:
            best = 1000000

        if totalTime < best:
            leaderboard.addHighscore(curUsr, 'quicktype', round(totalTime, 2))
            best = round(totalTime, 2)
        while loop:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    loop = False
                    pygame.quit()
                if event.type == pygame.KEYDOWN:
                    loop = False
コード例 #3
0
def endScreen():  # Display this screen when the user completes trhe course
    global Start, starting, level, sheet, coins, user
    starting = True
    Start = True

    # Draw all text to display on screen
    win.blit(background, (0, 0))
    text = myFont.render('Course Completed!', 1, (64, 64, 64))
    win.blit(text, (winwidth / 2 - text.get_width() / 2, 210))
    text = parFont.render('Par: ' + str(sheet.getPar()), 1, (64, 64, 64))
    win.blit(text, ((winwidth / 2 - text.get_width() / 2, 320)))
    text = parFont.render('Strokes: ' + str(sheet.getStrokes()), 1,
                          (64, 64, 64))
    win.blit(text, ((winwidth / 2 - text.get_width() / 2, 280)))
    blit = parFont.render('Press the mouse to continue...', 1, (64, 64, 64))
    win.blit(blit, (winwidth / 2 - blit.get_width() / 2, 510))
    text = parFont.render('Score: ' + str(sheet.getScore()), 1, (64, 64, 64))
    win.blit(text, ((winwidth / 2 - text.get_width() / 2, 360)))
    pygame.display.update()

    # Change highscore if applicable
    session = boto3.resource(
        'dynamodb',
        aws_access_key_id='AKIAIOPUXE2QS7QN2MMQ',
        aws_secret_access_key='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',
        region_name="ca-central-1")
    table = session.Table('highscores')
    response = table.query(KeyConditionExpression=Key('peopleid').eq(user))

    for i in response['Items']:
        score = i['golf']

    if sheet.getScore() < score or score == 0:
        if sheet.getScore() == 0:
            leaderboard.addHighscore(user, 'golf', 'Par')
        else:
            leaderboard.addHighscore(user, 'golf', sheet.getScore())

    leaderboard.addGamesPlayed(user, 'golf')
    leaderboard.addTimePlayed(user, 'golf', t.time() - timePlayed)

    # Wait
    loop = True
    while loop:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
            if event.type == pygame.MOUSEBUTTONDOWN:
                loop = False
                break
    level = 1
    setup(level)
    list = courses.getPar(1)
    par = list[level - 1]
    sheet = scoreSheet(list)
    starting = True
    hover = False
    while starting:
        pygame.time.delay(10)
        startScreen.mainScreen(user, hover)
        for event in pygame.event.get():
            if event.type == pygame.MOUSEMOTION:
                pos = pygame.mouse.get_pos()
                hover = startScreen.shopClick(pos)
                course = startScreen.click(pos)
                startScreen.mouseOver(course != None)
            if event.type == pygame.MOUSEBUTTONDOWN:
                pos = pygame.mouse.get_pos()
                if startScreen.click(pos) != None:
                    starting = False
                    break
                if startScreen.shopClick(pos) == True:
                    surface = startScreen.drawShop()
                    win.blit(surface, (0, 0))
                    pygame.display.update()
                    shop = True
                    while shop:
                        for event in pygame.event.get():
                            pygame.time.delay(10)
                            if event.type == pygame.QUIT:
                                pygame.quit()
                            if event.type == pygame.MOUSEBUTTONDOWN:
                                pos = pygame.mouse.get_pos()
                                if pos[0] > 10 and pos[0] < 100 and pos[
                                        1] > 560:
                                    shop = False
                                    break
                                surface = startScreen.drawShop(pos, True)
                                win.blit(surface, (0, 0))
                                pygame.display.update()

            if event.type == pygame.QUIT:
                pygame.quit()
                break