Fixed merge conflict
commit
b7748361ca
|
@ -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))
|
17
game.py
17
game.py
|
@ -5,7 +5,7 @@ Avocados and stuff
|
||||||
|
|
||||||
import os, random, sys
|
import os, random, sys
|
||||||
import pygame
|
import pygame
|
||||||
import avocado, lawyer
|
import avocado, crystal
|
||||||
from pygame.locals import *
|
from pygame.locals import *
|
||||||
from support.colors import *
|
from support.colors import *
|
||||||
from interface import hud
|
from interface import hud
|
||||||
|
@ -27,6 +27,12 @@ class TheGame:
|
||||||
# fonts
|
# fonts
|
||||||
self.bigFont = pygame.font.Font(None, 90)
|
self.bigFont = pygame.font.Font(None, 90)
|
||||||
|
|
||||||
|
# Set splashscreen
|
||||||
|
splashScreen = pygame.image.load("img/splashScreen.png")
|
||||||
|
self.screen.blit(pygame.transform.scale(splashScreen, self.size), (0, 0))
|
||||||
|
pygame.display.flip()
|
||||||
|
pygame.time.wait(3000)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pygame.mixer.init()
|
pygame.mixer.init()
|
||||||
pygame.mixer.music.set_volume(0.5)
|
pygame.mixer.music.set_volume(0.5)
|
||||||
|
@ -103,11 +109,10 @@ 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)
|
||||||
fullegast = lawyer.Lawyer(self.screen)
|
crystalBall = crystal.Crystal(self.screen)
|
||||||
|
|
||||||
# Initial color indication
|
# Initial color indication
|
||||||
color = self.chooseRandomColor()
|
color = self.chooseRandomColor()
|
||||||
fullegast.setColor(color)
|
|
||||||
|
|
||||||
# We could use this list for redrawing only this part
|
# We could use this list for redrawing only this part
|
||||||
# of the screen install of all of it
|
# of the screen install of all of it
|
||||||
|
@ -121,16 +126,14 @@ class TheGame:
|
||||||
|
|
||||||
# Redraw the background and put our lawyer back on top
|
# Redraw the background and put our lawyer back on top
|
||||||
self.drawBackground()
|
self.drawBackground()
|
||||||
fullegast.blitme()
|
|
||||||
|
|
||||||
# Next level?
|
# Next level?
|
||||||
if score >= targetScore:
|
if score >= targetScore:
|
||||||
self.score = 0
|
self.score = 0
|
||||||
level += 1
|
level += 1
|
||||||
pauseFor = 35
|
levelChange = 35
|
||||||
timeleft = time
|
timeleft = time
|
||||||
avocados = []
|
avocados = []
|
||||||
# self.pinned = []
|
|
||||||
print('DEBUG :: Level ' + str(level))
|
print('DEBUG :: Level ' + str(level))
|
||||||
self.playLevel(level)
|
self.playLevel(level)
|
||||||
|
|
||||||
|
@ -183,7 +186,7 @@ class TheGame:
|
||||||
if hit:
|
if hit:
|
||||||
score += 100
|
score += 100
|
||||||
color = self.chooseRandomColor()
|
color = self.chooseRandomColor()
|
||||||
fullegast.setColor(color)
|
crystalBall.setColor(color)
|
||||||
elif hit == False:
|
elif hit == False:
|
||||||
score -= 50
|
score -= 50
|
||||||
|
|
||||||
|
|
31
lawyer.py
31
lawyer.py
|
@ -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)
|
|
Loading…
Reference in New Issue