avocados/crystal.py

51 lines
1.4 KiB
Python
Raw Normal View History

2014-08-31 01:03:39 +02:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*- #
2014-08-31 01:03:39 +02:00
"""
A class that represents a lawyer
"""
2014-08-31 12:46:07 +02:00
import os, pygame, random
2014-08-31 01:03:39 +02:00
from support import operations
from support.colors import *
class Crystal:
2014-08-31 12:46:07 +02:00
def __init__(self, screen, level, font, psychomode):
self.psychomode = psychomode
2014-08-31 01:03:39 +02:00
self.screen = screen
screen_width, screen_height = screen.get_size()
2014-08-31 12:08:00 +02:00
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)
2014-08-31 12:46:07 +02:00
self.level = level
self.font = font
self.colorTexts = {
RED: 'RED',
GREEN: 'GREEN',
BLUE: 'BLUE',
YELLOW: 'YELLOW',
PINK: 'PINK'
}
2014-08-31 12:08:00 +02:00
def getBoundaries(self):
return self.pos
2014-08-31 01:03:39 +02:00
2014-08-31 01:38:26 +02:00
def blitme(self):
2014-08-31 12:46:07 +02:00
myrect = pygame.draw.ellipse(self.screen, self.thecolor, self.pos, 0)
if self.level >= self.psychomode:
2014-08-31 12:46:07 +02:00
self.text = self.font.render(self.colorTexts[self.color], 0, WHITE)
self.screen.blit(self.text, myrect)
2014-08-31 01:38:26 +02:00
2014-08-31 01:03:39 +02:00
def setColor(self, color):
2014-08-31 01:38:26 +02:00
self.color = color
2014-08-31 12:46:07 +02:00
self.thecolor = self.color
if self.level >= self.psychomode:
2014-08-31 12:46:07 +02:00
colors = [RED, GREEN, BLUE, YELLOW, PINK]
self.thecolor = colors[random.randint(0,len(colors) - 1)]
2014-08-31 01:38:26 +02:00