Psychomode appears to be working

master
David Raison 2014-08-31 12:46:07 +02:00
parent 6d142808e2
commit 96117c3871
3 changed files with 26 additions and 8 deletions

View File

@ -3,19 +3,29 @@
A class that represents a lawyer A class that represents a lawyer
""" """
import os, pygame import os, pygame, random
from support import operations from support import operations
from support.colors import * from support.colors import *
class Crystal: class Crystal:
def __init__(self, screen): def __init__(self, screen, level, font, psychomode):
self.psychomode = psychomode
self.screen = screen self.screen = screen
screen_width, screen_height = screen.get_size() screen_width, screen_height = screen.get_size()
screen_rect = self.screen.get_rect() screen_rect = self.screen.get_rect()
self.imageCenterX = screen_rect.centerx self.imageCenterX = screen_rect.centerx
self.imageCenterY = screen_rect.centery self.imageCenterY = screen_rect.centery
self.pos = (self.imageCenterX-100,self.imageCenterY-5,200,183) 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): def getBoundaries(self):
@ -23,9 +33,16 @@ class Crystal:
def blitme(self): 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): def setColor(self, color):
self.color = 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)]

View File

@ -23,16 +23,17 @@ class TheGame:
# initialize the game canvas # initialize the game canvas
self.timeout = 30 self.timeout = 30
self.level = 1 self.level = 1
self.psychomode = 3
self.targetScore = 400 self.targetScore = 400
############################## ##############################
# Never set below 4, else we have a high # Never set below 4, else we have a high
# probability of losing the game due to a missing color # probability of losing the game due to a missing color
# Alternatively, you could edit chooseRandomColor() # Alternatively, you could edit chooseRandomColor()
# to only work on the first multiplier colors # to only work on the first multiplier colors
self.multiplier = 4
self.desired_fps = 60 self.desired_fps = 60
self.screen = pygame.display.set_mode((self.WIDTH, self.HEIGHT)) self.screen = pygame.display.set_mode((self.WIDTH, self.HEIGHT))
self.colors = [RED, GREEN, BLUE, YELLOW, PINK] 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 = pygame.image.load(os.path.join('img', 'lawyerCrystalBall.png'))
self.bg.set_colorkey((255,255,255)) self.bg.set_colorkey((255,255,255))
self.bg.set_alpha(75) self.bg.set_alpha(75)
@ -101,7 +102,7 @@ class TheGame:
def chooseRandomColor(self): def chooseRandomColor(self):
selected = random.randint(0, 3) selected = random.randint(0, len(self.colors) - 1)
if len(self.last_colors) > 5: if len(self.last_colors) > 5:
self.last_colors.pop(0) self.last_colors.pop(0)
for i in range(0, 5): for i in range(0, 5):
@ -115,7 +116,7 @@ class TheGame:
def gameOver(self): def gameOver(self):
screen_width, screen_height = self.screen.get_size() screen_width, screen_height = self.screen.get_size()
gameOverImage = pygame.image.load(os.path.join('img', 'gameOver.png')) 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)) gameOverImage.blit(gameOverText, (screen_width/8, screen_height/7))
self.screen.blit(pygame.transform.scale(gameOverImage, self.screen.blit(pygame.transform.scale(gameOverImage,
self.screen.get_size()), (0, 0)) self.screen.get_size()), (0, 0))
@ -159,7 +160,7 @@ class TheGame:
# initialize the HUD class and the lawyer # initialize the HUD class and the lawyer
the_hud = hud.Hud(self.screen) 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()) boundaries.append(crystalBall.getBoundaries())
# Initial color indication # Initial color indication

View File

@ -10,7 +10,7 @@ class Text:
self.clock = container['clock'] self.clock = container['clock']
self.duration = duration self.duration = duration
self.totalTime = 0 self.totalTime = 0
self.text = container['font'].render(text, 0 , WHITE) self.text = container['font'].render(text, 0, WHITE)
self.screen = container['screen'] self.screen = container['screen']
self.pos = pos self.pos = pos