This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
2015-04-16 10:00:39 +01:00
|
|
|
import pygame
|
|
|
|
|
|
|
|
|
|
|
|
class Bullet(pygame.sprite.Sprite):
|
|
|
|
def __init__(self, parent):
|
|
|
|
super().__init__()
|
|
|
|
self.width = 4
|
|
|
|
self.height = 10
|
2015-05-11 22:15:40 +01:00
|
|
|
self.image = pygame.transform.scale(textures.get_texture("BULLET"), (self.width, self.height))
|
2015-04-16 10:00:39 +01:00
|
|
|
self.rect = self.image.get_rect()
|
2015-05-10 13:12:51 +01:00
|
|
|
self.rect.x = parent.rect.x + parent.width/2 - self.width/2
|
|
|
|
self.rect.y = parent.rect.y + parent.height/2
|
2015-04-16 10:00:39 +01:00
|
|
|
self.speed = 5
|
2015-05-08 11:24:33 +01:00
|
|
|
self.type = "PLAYER"
|
|
|
|
self.parent = parent
|
2015-04-16 10:00:39 +01:00
|
|
|
|
|
|
|
def set_position(self,x,y):
|
|
|
|
self.rect.x, self.rect.y = x,y
|
|
|
|
|
|
|
|
def update(self):
|
2015-05-08 11:24:33 +01:00
|
|
|
self.rect.y -= self.speed #direction may need editing?
|