From 0a8e7454326eb6e8e911006fc5119271cf3893dd Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 16 Apr 2015 10:00:39 +0100 Subject: [PATCH] Initial Commit --- SPACE INVADERS.py | 2 ++ bullet.py | 22 ++++++++++++++++++++++ player.py | 17 +++++++++++++++++ textures.py | 16 ++++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 SPACE INVADERS.py create mode 100644 bullet.py create mode 100644 player.py create mode 100644 textures.py diff --git a/SPACE INVADERS.py b/SPACE INVADERS.py new file mode 100644 index 0000000..319a71c --- /dev/null +++ b/SPACE INVADERS.py @@ -0,0 +1,2 @@ +import pygame +import bullet, player, textures # Import other files diff --git a/bullet.py b/bullet.py new file mode 100644 index 0000000..574ebe4 --- /dev/null +++ b/bullet.py @@ -0,0 +1,22 @@ +import pygame + +IMAGE_LOCATION = "bullet.png" + + +class Bullet(pygame.sprite.Sprite): + def __init__(self, parent): + super().__init__() + self.width = 4 + self.height = 10 + self.image = pygame.Surface((self.width, self.height)) + self.image.fill((255,255,255)) + self.rect = self.image.get_rect() + self.rect.x = parent.rect.x + 32 + self.rect.y = parent.rect.y + self.speed = 5 + + def set_position(self,x,y): + self.rect.x, self.rect.y = x,y + + def update(self): + self.rect.y += self.speed #direction may need editing? \ No newline at end of file diff --git a/player.py b/player.py new file mode 100644 index 0000000..b66ec9c --- /dev/null +++ b/player.py @@ -0,0 +1,17 @@ +import pygame + +IMAGE_LOCATION = "player.png" + + +class Shooter(pygame.sprite.Sprite): + def __init__(self, color=(30,0,150), width=64, height=64): + super().__init__() + self.image = pygame.Surface((width, height)) + self.image.fill(color) + self.rect = self.image.get_rect() + self.speed = 4 + + def set_position(self,x,y): + self.rect.x, self.rect.y = x,y + + def move(self, value): self.rect.x += value \ No newline at end of file diff --git a/textures.py b/textures.py new file mode 100644 index 0000000..30f875e --- /dev/null +++ b/textures.py @@ -0,0 +1,16 @@ +import os +class Textures(): + def __init__(self): + self.images = { + "PLAYER":"player.png", + "BULLET":"bullet.png", + "TARGET":[] + } + self.path=os.path.dirname(os.path.realpath(__file__)) + "\\resources\\texture_packs" + self.pac + def loadTexturePack(self, filename): + pass + def getTexture(self, object): + directory = + +tex = Textures()