Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/main.py b/src/main.py
- index dda0737..856e0ee 100644
- --- a/src/main.py
- +++ b/src/main.py
- @@ -269,7 +269,6 @@ def win_menu(score, menuselected=0):
- def write_score(finallevel, score):
- """Writes the score from the current game to scoreboard.txt"""
- -
- name = ''
- ext = False
- while not ext and len(name) <= 24:
- @@ -289,6 +288,7 @@ def write_score(finallevel, score):
- name = name[:-1]
- elif event.key == K_RETURN:
- ext = True
- + name = name.replace(' ', '_')
- scoreboardfile = open('src/scoreboard.txt', 'a')
- scoreboardfile.write(f'{score} {name} {difficulty} {finallevel}\n')
- @@ -301,16 +301,13 @@ def scoreboard():
- with open('src/scoreboard.txt', 'r') as f:
- scores = [x for x in f.read().split('\n')]
- scores = scores[:-1]
- -
- - print(scores)
- +
- for i in range(len(scores)):
- - print(scores[i].split(' '))
- scores[i] = scores[i].split(' ')
- scores[i][0] = int(scores[i][0])
- - scores.sort(key=lambda x: x[0])
- - print(scores, len(scores))
- + scores.sort(key=lambda x: x[0], reverse=True)
- - if len(scores) < 10:
- + if len(scores) > 10:
- scores = scores[:10]
- S.fill((0, 0, 0))
- @@ -325,8 +322,8 @@ def scoreboard():
- for i in range(len(scores)):
- S.blit(SMALLMENUFONT.render(f'{i}', 1, (255, 255, 255)), (10, round(TITLEFONT.get_height() * 5 / 4 + OPTIONSFONT.get_height() * 5 / 4 + SMALLMENUFONT.get_height() * i * 6 / 5)))
- - S.blit(SMALLMENUFONT.render(f'{scores[i][1]}', 1, (255, 255, 255)), (40, round(TITLEFONT.get_height() * 5 / 4 + OPTIONSFONT.get_height() * 5 / 4 + SMALLMENUFONT.get_height() * i * 6 / 5)))
- - S.blit(SMALLMENUFONT.render(f'{scores[i][0]}', 1, (255, 255, 255)), (WIDTH / 2 - 175, round(TITLEFONT.get_height() * 5 / 4 + OPTIONSFONT.get_height() * 5 / 4 + SMALLMENUFONT.get_height() * i * 6 / 5)))
- + S.blit(SMALLMENUFONT.render(f'{scores[i][1].replace("_", " ")}', 1, (255, 255, 255)), (40, round(TITLEFONT.get_height() * 5 / 4 + OPTIONSFONT.get_height() * 5 / 4 + SMALLMENUFONT.get_height() * i * 6 / 5)))
- + S.blit(SMALLMENUFONT.render(f'{scores[i][0] + 1}', 1, (255, 255, 255)), (WIDTH / 2 - 175, round(TITLEFONT.get_height() * 5 / 4 + OPTIONSFONT.get_height() * 5 / 4 + SMALLMENUFONT.get_height() * i * 6 / 5)))
- S.blit(SMALLMENUFONT.render(f'{scores[i][2]}', 1, (255, 255, 255)), (WIDTH / 2 - 50, round(TITLEFONT.get_height() * 5 / 4 + OPTIONSFONT.get_height() * 5 / 4 + SMALLMENUFONT.get_height() * i * 6 / 5)))
- S.blit(SMALLMENUFONT.render(f'{scores[i][3]}', 1, (255, 255, 255)), (WIDTH / 2 + 125, round(TITLEFONT.get_height() * 5 / 4 + OPTIONSFONT.get_height() * 5 / 4 + SMALLMENUFONT.get_height() * i * 6 / 5)))
- @@ -505,9 +502,9 @@ def game():
- if theplayer.position[1] > (size - 6) * 64:
- # Punish naughty players
- if len(targets):
- - missed = targets_needed(level) - got
- + missed = people - got
- score -= missed * 1000
- - playerhealth.damage(missed)
- + playerhealth.damage(kill=False, damage=missed)
- if not playerhealth.health:
- deadcos = 'You abandoned everyone.'
- dead = True
- @@ -563,7 +560,7 @@ def game():
- for target in targets:
- # Targets themselves
- drawloc = target.position - (theplayer.position - vectors.Vector(x=WIDTH / 2, y=HEIGHT / 2)) - vectors.Vector(16, 16)
- - if -16 < drawloc.x < WIDTH and -16 < drawloc.y < HEIGHT:
- + if -32 < drawloc.x < WIDTH and -32 < drawloc.y < HEIGHT:
- S.blit(TARGET, drawloc.to_tuple())
- # Target Dots
- @@ -662,11 +659,21 @@ def menu(title, titlefont, optionstext, optionsfont, smalltext=None, smalltextfo
- ext = False
- menuselected = selected
- while not ext:
- + if background is None:
- + S.fill((0, 0, 0))
- + else:
- + S.blit(background, (0, 0))
- + S.blit(title, (titlex, titley))
- for i in range(0, len(optionstext)):
- if i != menuselected:
- S.blit(options[i], (optionsx, optionsy + i * (optionsfont.get_height() + optionsfont.get_height() // 5)))
- else:
- S.blit(optionsselected[i], (optionsx, optionsy + i * (optionsfont.get_height() + optionsfont.get_height() // 5)))
- + if smalltext is not None:
- + for i in range(len(smalltextimages)):
- + print('Drawing')
- + S.blit(smalltextimages[i], (smalltextx, smalltexty + i * (smalltextfont.get_height() + smalltextfont.get_height() // 5)))
- +
- pygame.display.update()
- for event in pygame.event.get():
- diff --git a/src/scoreboard.txt b/src/scoreboard.txt
- index e05179f..c296dfb 100644
- --- a/src/scoreboard.txt
- +++ b/src/scoreboard.txt
- @@ -1 +1 @@
- -29061 QuantumPotato Normal 6
- +0 Dummy Easy 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement