Initial Commit
This commit is contained in:
commit
0a8e745432
4 changed files with 57 additions and 0 deletions
2
SPACE INVADERS.py
Normal file
2
SPACE INVADERS.py
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
import pygame
|
||||||
|
import bullet, player, textures # Import other files
|
22
bullet.py
Normal file
22
bullet.py
Normal file
|
@ -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?
|
17
player.py
Normal file
17
player.py
Normal file
|
@ -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
|
16
textures.py
Normal file
16
textures.py
Normal file
|
@ -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()
|
Reference in a new issue