have colored avocados

master
David Raison 2014-08-30 20:53:47 +02:00
parent 657e3a963a
commit fdae2d2c07
2 changed files with 6 additions and 9 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import pygame import pygame, random
import random from support import operations
class Avocado: class Avocado:
@ -13,7 +13,9 @@ class Avocado:
self.y = 0 # change this to start somewhere above the screen self.y = 0 # change this to start somewhere above the screen
self.w = 100 self.w = 100
self.y = 100 self.y = 100
self.i = pygame.image.load(filename).convert_alpha() self.i = pygame.image.load(filename).convert_alpha()
operations.color_surface(self.i, color)
self.image = pygame.transform.scale(self.i, (30, 30)) self.image = pygame.transform.scale(self.i, (30, 30))
self.pycard = self.image.get_rect() self.pycard = self.image.get_rect()

View File

@ -16,11 +16,11 @@ class Lawyer:
# WARNING!! FIXME Absolute sizes FIXME # WARNING!! FIXME Absolute sizes FIXME
self.image = pygame.transform.scale(temp_image, (220, 400)) self.image = pygame.transform.scale(temp_image, (220, 400))
self.rect = self.image.get_rect() self.rect = self.image.get_rect()
operations.color_surface(self.image, WHITE)
self.pos = (screen_width - self.rect.w, screen_height - self.rect.h) self.pos = (screen_width - self.rect.w, screen_height - self.rect.h)
def blitme(self): def blitme(self):
""" Blit this object to the screen """ """ 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.image.blit(self.pane, (self.rect.left, self.rect.bottom / 2))
self.screen.blit(self.image, self.pos) self.screen.blit(self.image, self.pos)
@ -29,8 +29,3 @@ class Lawyer:
and filling it with a color """ and filling it with a color """
self.pane = pygame.Surface((200, 100)) self.pane = pygame.Surface((200, 100))
self.pane.fill(color) 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)