- rename lawyer class to crystal class

master
Steve Clement 2014-08-31 01:03:39 +02:00
parent 025f2e7e66
commit ac5f768157
3 changed files with 27 additions and 39 deletions

22
crystal.py Normal file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env python3
"""
A class that represents a lawyer
"""
import os, pygame
from support import operations
from support.colors import *
class Crystal:
def __init__(self, screen):
self.screen = screen
screen_width, screen_height = screen.get_size()
self.imageCenterX = self.screen.get_rect().centerx
self.imageCenterY = self.screen.get_rect().centery
def setColor(self, color):
""" Announces the color to pin by drawing a rectangle
and filling it with a color """
pygame.draw.ellipse(self.screen, (color), (self.imageCenterX-158,self.imageCenterY-5,277,217), 0)
print("Drawing {} ellipse".format(color))

13
game.py
View File

@ -5,7 +5,7 @@ Avocados and stuff
import os, random, sys
import pygame
import avocado, lawyer
import avocado, crystal
from pygame.locals import *
from support.colors import *
from interface import hud
@ -100,13 +100,12 @@ class TheGame:
reachScore = 200
avoClick = self.loadClick()
# initialize the HUD class and the lawyer
# initialize the HUD class and the lawyers crystal ball
the_hud = hud.Hud(self.screen)
fullegast = lawyer.Lawyer(self.screen)
crystalBall = crystal.Crystal(self.screen)
# Initial color indication
color = self.chooseRandomColor()
fullegast.setColor(color)
avocados = [] # We could use this for redrawing only this part
running = True
@ -132,9 +131,6 @@ class TheGame:
print('DEBUG :: Level ' + str(level))
game.playLevel(level)
# Let's add the lawyer
fullegast.blitme()
if levelChange > 0:
levelText = self.big.render('Level ' + str(level), 0, WHITE)
self.screen.blit(levelText, (screen_width / 3, screen_height / 2))
@ -149,6 +145,7 @@ class TheGame:
# Redraw the HUD
the_hud.draw_hud(score, displaytime, round(fps, 2))
crystalBall.setColor(color)
# Initialize a number of avocados, depending on the level
if levelChange == 0:
@ -182,7 +179,7 @@ class TheGame:
if hit:
score += 100
color = self.chooseRandomColor()
fullegast.setColor(color)
crystalBall.setColor(color)
elif hit == False:
score -= 50

View File

@ -1,31 +0,0 @@
#!/usr/bin/env python3
"""
A class that represents a lawyer
"""
import os, pygame
from support import operations
from support.colors import *
class Lawyer:
def __init__(self, screen):
self.screen = screen
screen_width, screen_height = screen.get_size()
temp_image = pygame.image.load(os.path.join('img', 'lawyer.png'))
# WARNING!! FIXME Absolute sizes FIXME
self.image = pygame.transform.scale(temp_image, (220, 400))
self.rect = self.image.get_rect()
operations.color_surface(self.image, WHITE)
self.pos = (screen_width - self.rect.w, screen_height - self.rect.h)
def blitme(self):
""" Blit this object to the screen """
self.image.blit(self.pane, (self.rect.left, self.rect.bottom / 2))
self.screen.blit(self.image, self.pos)
def setColor(self, color):
""" Announces the color to pin by drawing a rectangle
and filling it with a color """
self.pane = pygame.Surface((200, 100))
self.pane.fill(color)