diff --git a/crystal.py b/crystal.py index 2b36588..01d6494 100644 --- a/crystal.py +++ b/crystal.py @@ -3,19 +3,29 @@ A class that represents a lawyer """ -import os, pygame +import os, pygame, random from support import operations from support.colors import * class Crystal: - def __init__(self, screen): + def __init__(self, screen, level, font, psychomode): + self.psychomode = psychomode self.screen = screen screen_width, screen_height = screen.get_size() screen_rect = self.screen.get_rect() self.imageCenterX = screen_rect.centerx self.imageCenterY = screen_rect.centery self.pos = (self.imageCenterX-100,self.imageCenterY-5,200,183) + self.level = level + self.font = font + self.colorTexts = { + RED: 'RED', + GREEN: 'GREEN', + BLUE: 'BLUE', + YELLOW: 'YELLOW', + PINK: 'PINK' + } def getBoundaries(self): @@ -23,9 +33,16 @@ class Crystal: def blitme(self): - pygame.draw.ellipse(self.screen, self.color, self.pos, 0) + myrect = pygame.draw.ellipse(self.screen, self.thecolor, self.pos, 0) + if self.level > self.psychomode: + self.text = self.font.render(self.colorTexts[self.color], 0, WHITE) + self.screen.blit(self.text, myrect) def setColor(self, color): self.color = color + self.thecolor = self.color + if self.level > self.psychomode: + colors = [RED, GREEN, BLUE, YELLOW, PINK] + self.thecolor = colors[random.randint(0,len(colors) - 1)] diff --git a/game.py b/game.py index 3884a2e..6db8313 100755 --- a/game.py +++ b/game.py @@ -23,16 +23,17 @@ class TheGame: # initialize the game canvas self.timeout = 30 self.level = 1 + self.psychomode = 3 self.targetScore = 400 ############################## # Never set below 4, else we have a high # probability of losing the game due to a missing color # Alternatively, you could edit chooseRandomColor() # to only work on the first multiplier colors - self.multiplier = 4 self.desired_fps = 60 self.screen = pygame.display.set_mode((self.WIDTH, self.HEIGHT)) self.colors = [RED, GREEN, BLUE, YELLOW, PINK] + self.multiplier = len(self.colors) self.bg = pygame.image.load(os.path.join('img', 'lawyerCrystalBall.png')) self.bg.set_colorkey((255,255,255)) self.bg.set_alpha(75) @@ -101,7 +102,7 @@ class TheGame: def chooseRandomColor(self): - selected = random.randint(0, 3) + selected = random.randint(0, len(self.colors) - 1) if len(self.last_colors) > 5: self.last_colors.pop(0) for i in range(0, 5): @@ -115,7 +116,7 @@ class TheGame: def gameOver(self): screen_width, screen_height = self.screen.get_size() gameOverImage = pygame.image.load(os.path.join('img', 'gameOver.png')) - gameOverText = self.bigFont.render('GAME OVER', 0, YELLOW) + gameOverText = self.bigFont.render('GAME OVER', False, YELLOW) gameOverImage.blit(gameOverText, (screen_width/8, screen_height/7)) self.screen.blit(pygame.transform.scale(gameOverImage, self.screen.get_size()), (0, 0)) @@ -159,7 +160,7 @@ class TheGame: # initialize the HUD class and the lawyer the_hud = hud.Hud(self.screen) - crystalBall = crystal.Crystal(self.screen) + crystalBall = crystal.Crystal(self.screen, self.level, self.bigFont, self.psychomode) boundaries.append(crystalBall.getBoundaries()) # Initial color indication diff --git a/itext.py b/itext.py index eeb9b06..2bc68c5 100644 --- a/itext.py +++ b/itext.py @@ -10,7 +10,7 @@ class Text: self.clock = container['clock'] self.duration = duration self.totalTime = 0 - self.text = container['font'].render(text, 0 , WHITE) + self.text = container['font'].render(text, 0, WHITE) self.screen = container['screen'] self.pos = pos