From fdae2d2c07a346080bbb6317f182291601530c02 Mon Sep 17 00:00:00 2001 From: David Raison Date: Sat, 30 Aug 2014 20:53:47 +0200 Subject: [PATCH] have colored avocados --- avocado.py | 8 +++++--- lawyer.py | 7 +------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/avocado.py b/avocado.py index ea5ae8f..7689dd9 100644 --- a/avocado.py +++ b/avocado.py @@ -1,19 +1,21 @@ #!/usr/bin/env python3 -import pygame -import random +import pygame, random +from support import operations class Avocado: def __init__(self, screen, color, filename='img/AvoCado_0.png'): print('New avocado is ' + ','.join(str(color))) - self.screen = screen + self.screen = screen self.screen_width, self.screen_height = screen.get_size() self.x = random.randint(0, self.screen_width) self.y = 0 # change this to start somewhere above the screen self.w = 100 self.y = 100 + self.i = pygame.image.load(filename).convert_alpha() + operations.color_surface(self.i, color) self.image = pygame.transform.scale(self.i, (30, 30)) self.pycard = self.image.get_rect() diff --git a/lawyer.py b/lawyer.py index 5e868f7..6cac86c 100644 --- a/lawyer.py +++ b/lawyer.py @@ -16,11 +16,11 @@ class Lawyer: # 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 """ - operations.color_surface(self.image, WHITE) self.image.blit(self.pane, (self.rect.left, self.rect.bottom / 2)) self.screen.blit(self.image, self.pos) @@ -29,8 +29,3 @@ class Lawyer: and filling it with a color """ self.pane = pygame.Surface((200, 100)) self.pane.fill(color) - - # Add this to self.image?! - - # using surface.fill is faster because it can be hw accel - #pygame.draw.rect(Surface, color, Rect, width=0)