added colour changing
This commit is contained in:
parent
64eb14bed8
commit
a4a3541fcb
1 changed files with 11 additions and 4 deletions
11
player.py
11
player.py
|
@ -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()
|
||||||
|
@ -18,6 +18,7 @@ class Shooter(pygame.sprite.Sprite):
|
||||||
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
|
||||||
|
@ -29,3 +30,9 @@ 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)
|
Reference in a new issue