From a688c555eb64584b6a493e4432103327b72cd947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Sun, 31 Aug 2014 00:54:33 +0200 Subject: [PATCH 1/2] add splash screen --- game.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/game.py b/game.py index 011deea..eb8bb6d 100755 --- a/game.py +++ b/game.py @@ -28,6 +28,12 @@ class TheGame: self.pinned = [] + # 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: pygame.mixer.init() pygame.mixer.music.set_volume(0.5) From ac5f76815708ae9f2a72379bc2bfd0fc2f0339b1 Mon Sep 17 00:00:00 2001 From: Steve Clement Date: Sun, 31 Aug 2014 01:03:39 +0200 Subject: [PATCH 2/2] - rename lawyer class to crystal class --- crystal.py | 22 ++++++++++++++++++++++ game.py | 13 +++++-------- lawyer.py | 31 ------------------------------- 3 files changed, 27 insertions(+), 39 deletions(-) create mode 100644 crystal.py delete mode 100644 lawyer.py diff --git a/crystal.py b/crystal.py new file mode 100644 index 0000000..d7c0aaf --- /dev/null +++ b/crystal.py @@ -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)) diff --git a/game.py b/game.py index 011deea..d06a385 100755 --- a/game.py +++ b/game.py @@ -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 diff --git a/lawyer.py b/lawyer.py deleted file mode 100644 index 6cac86c..0000000 --- a/lawyer.py +++ /dev/null @@ -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)