Commit 33b86c1c authored by gem2578's avatar gem2578 Committed by Marcus M. Scheunemann

Tidy the code

parent 050c1821
......@@ -7,15 +7,13 @@ class Goal(pygame.sprite.Sprite):
def __init__(self, side):
super().__init__()
self.side = side
self.image = pygame.image.load("resource/goal.png").convert_alpha()
self.rect = self.image.get_rect()
if side == Side.LEFT:
self.image = pygame.image.load("resource/goal.png").convert_alpha()
self.rect = self.image.get_rect()
self.rect.midright = [40, 250]
else:
self.image = pygame.image.load("resource/goal.png").convert_alpha()
self.rect = self.image.get_rect()
self.rect.midleft = [761, 250]
self.mask = pygame.mask.from_surface(self.image)
......
......@@ -10,22 +10,18 @@ class Score(pygame.sprite.Sprite):
self.side = side
self.font = pygame.font.Font(None, 40)
self.score = 0
self.image = self.font.render(str(self.score), 0, (0,0,0))
self.rect = self.image.get_rect()
if side == Side.LEFT:
self.rect.topright = (395,25)
else:
self.rect.topleft = (405,25)
self.render()
def update(self):
self.render()
def render(self):
self.image = self.font.render(str(self.score), 0, (0,0,0))
self.rect = self.image.get_rect()
if self.side == Side.LEFT:
self.image = self.font.render(str(self.score), 0, (0,0,0))
self.rect = self.image.get_rect()
self.rect.topright = (390,25)
self.rect.topright = (399,25)
else:
self.image = self.font.render(str(self.score), 0, (0,0,0))
self.rect = self.image.get_rect()
self.rect.topleft = (410,25)
self.rect.topleft = (405,25)
def increase(self):
self.score = 1 + self.score
self.score += 1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment