forked from sd17fall/InteractiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScoring.py
More file actions
34 lines (27 loc) · 1.33 KB
/
Scoring.py
File metadata and controls
34 lines (27 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import random, pygame, sys, pygame.font
from pygame.locals import *
navyblue = (60,60,100)
white = (255,255,255)
class Scoreboard(pygame.sprite.Sprite):
def __init__(self, screen):
pygame.sprite.Sprite.__init__(self)
self.fruit_sliced = 0
self.fruit_missed = 0
self.screen = screen
self.sb_height, self.sb_width = 50, self.screen.get_width()
self.rect = pygame.Rect(0,0, self.sb_width, self.sb_height)
self.bg_color = navyblue
self.text_color = white
self.font = pygame.font.SysFont('Arial', 18)
self.x_sliced_position, self.y_sliced_position = 20.0, 10.0
self.x_missed_position, self.y_missed_position = self.screen.get_width()-100, 10.0
def prep_scores(self):
self.sliced_string = "Sliced: " + str(self.fruit_sliced)
self.sliced_image = self.font.render(self.sliced_string, True, self.text_color)
self.missed_string = "Missed: " + str(self.fruit_missed)
self.missed_image = self.font.render(self.missed_string, True, self.text_color)
def show(self):
self.prep_scores()
self.screen.fill(self.bg_color, self.rect)
self.screen.blit(self.sliced_image, (self.x_sliced_position, self.y_sliced_position))
self.screen.blit(self.missed_image, (self.x_missed_position, self.y_missed_position))