Advertisement
Guest User

Untitled

a guest
Oct 28th, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 5.05 KB | None | 0 0
  1. diff --git a/src/main.py b/src/main.py
  2. index dda0737..856e0ee 100644
  3. --- a/src/main.py
  4. +++ b/src/main.py
  5. @@ -269,7 +269,6 @@ def win_menu(score, menuselected=0):
  6.  
  7.  def write_score(finallevel, score):
  8.      """Writes the score from the current game to scoreboard.txt"""
  9. -    
  10.      name = ''
  11.      ext = False
  12.      while not ext and len(name) <= 24:
  13. @@ -289,6 +288,7 @@ def write_score(finallevel, score):
  14.                      name = name[:-1]
  15.                  elif event.key == K_RETURN:
  16.                      ext = True
  17. +    name = name.replace(' ', '_')
  18.      
  19.      scoreboardfile = open('src/scoreboard.txt', 'a')
  20.      scoreboardfile.write(f'{score} {name} {difficulty} {finallevel}\n')
  21. @@ -301,16 +301,13 @@ def scoreboard():
  22.      with open('src/scoreboard.txt', 'r') as f:
  23.          scores = [x for x in f.read().split('\n')]
  24.      scores = scores[:-1]
  25. -    
  26. -    print(scores)
  27. +
  28.      for i in range(len(scores)):
  29. -        print(scores[i].split(' '))
  30.          scores[i] = scores[i].split(' ')
  31.          scores[i][0] = int(scores[i][0])
  32. -    scores.sort(key=lambda x: x[0])
  33. -    print(scores, len(scores))
  34. +    scores.sort(key=lambda x: x[0], reverse=True)
  35.      
  36. -    if len(scores) < 10:
  37. +    if len(scores) > 10:
  38.          scores = scores[:10]
  39.      
  40.      S.fill((0, 0, 0))
  41. @@ -325,8 +322,8 @@ def scoreboard():
  42.      
  43.      for i in range(len(scores)):
  44.          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)))
  45. -        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)))
  46. -        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)))
  47. +        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)))
  48. +        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)))
  49.          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)))
  50.          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)))
  51.      
  52. @@ -505,9 +502,9 @@ def game():
  53.              if theplayer.position[1] > (size - 6) * 64:
  54.                  # Punish naughty players
  55.                  if len(targets):
  56. -                    missed = targets_needed(level) - got
  57. +                    missed = people - got
  58.                      score -= missed * 1000
  59. -                    playerhealth.damage(missed)
  60. +                    playerhealth.damage(kill=False, damage=missed)
  61.                      if not playerhealth.health:
  62.                          deadcos = 'You abandoned everyone.'
  63.                          dead = True
  64. @@ -563,7 +560,7 @@ def game():
  65.              for target in targets:
  66.                  # Targets themselves
  67.                  drawloc = target.position - (theplayer.position - vectors.Vector(x=WIDTH / 2, y=HEIGHT / 2)) - vectors.Vector(16, 16)
  68. -                if -16 < drawloc.x < WIDTH and -16 < drawloc.y < HEIGHT:
  69. +                if -32 < drawloc.x < WIDTH and -32 < drawloc.y < HEIGHT:
  70.                      S.blit(TARGET, drawloc.to_tuple())
  71.  
  72.                  # Target Dots
  73. @@ -662,11 +659,21 @@ def menu(title, titlefont, optionstext, optionsfont, smalltext=None, smalltextfo
  74.      ext = False
  75.      menuselected = selected
  76.      while not ext:
  77. +        if background is None:
  78. +            S.fill((0, 0, 0))
  79. +        else:
  80. +            S.blit(background, (0, 0))
  81. +        S.blit(title, (titlex, titley))
  82.          for i in range(0, len(optionstext)):
  83.              if i != menuselected:
  84.                  S.blit(options[i], (optionsx, optionsy + i * (optionsfont.get_height() + optionsfont.get_height() // 5)))
  85.              else:
  86.                  S.blit(optionsselected[i], (optionsx, optionsy + i * (optionsfont.get_height() + optionsfont.get_height() // 5)))
  87. +        if smalltext is not None:
  88. +            for i in range(len(smalltextimages)):
  89. +                print('Drawing')
  90. +                S.blit(smalltextimages[i], (smalltextx, smalltexty + i * (smalltextfont.get_height() + smalltextfont.get_height() // 5)))
  91. +        
  92.  
  93.          pygame.display.update()
  94.          for event in pygame.event.get():
  95. diff --git a/src/scoreboard.txt b/src/scoreboard.txt
  96. index e05179f..c296dfb 100644
  97. --- a/src/scoreboard.txt
  98. +++ b/src/scoreboard.txt
  99. @@ -1 +1 @@
  100. -29061 QuantumPotato Normal 6
  101. +0 Dummy Easy 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement