1
Fork 0

added colour changing

This commit is contained in:
Jake Howard 2015-05-10 13:13:28 +01:00
parent 64eb14bed8
commit a4a3541fcb

View file

@ -2,11 +2,11 @@ import pygame
class Shooter(pygame.sprite.Sprite): class Shooter(pygame.sprite.Sprite):
def __init__(self, window, color=(255,255,255), width=45, height=20): def __init__(self, window, colour=(255,255,255), width=45, height=20):
super().__init__() super().__init__()
self.width = width self.width = width
self.height = height self.height = height
self.colour = color self.colour = colour
self.image = pygame.Surface((width, height)) self.image = pygame.Surface((width, height))
self.image.fill(self.colour) self.image.fill(self.colour)
self.rect = self.image.get_rect() self.rect = self.image.get_rect()
@ -17,7 +17,8 @@ class Shooter(pygame.sprite.Sprite):
self.OP = False self.OP = False
self.level = 0 self.level = 0
self.lives = 3 self.lives = 3
self.powerup = "" self.powerup = ""
self.colours = [(255,0,0), (255,255,0), (0,255,0)]
def set_position(self,x,y): def set_position(self,x,y):
self.rect.x, self.rect.y = x,y self.rect.x, self.rect.y = x,y
@ -28,4 +29,10 @@ class Shooter(pygame.sprite.Sprite):
def update(self): def update(self):
self.image.fill(self.colour) self.image.fill(self.colour)
self.rect = self.image.get_rect() self.rect = self.image.get_rect()
def change_colour(self, colour):
x,y = self.rect.x, self.rect.y
self.image.fill(colour)
self.rect = self.image.get_rect()
self.set_position(x,y)