Finished Laser

This commit is contained in:
ben 2022-08-02 14:37:34 -05:00
parent 8ac6529106
commit 1df05915a0

View file

@ -3,10 +3,28 @@ import pygame
class Laser(pygame.sprite.Sprite): class Laser(pygame.sprite.Sprite):
def __init__(self, pos, speed, screen_height, color='white'): def __init__(self, pos, speed, screen_height, color='white'):
pass """
Initializes the Laser class
:param pos: Position
:param speed: Speed
:param screen_height: Screen Height
:param color: Color
"""
super().__init__()
self.image = pygame.Surface((4, 20))
self.image.fill(color)
self.rect = self.image.get_rect(center=pos)
self.speed = speed
self.y_constraint = screen_height
def destroy(self): def destroy_conditionally(self):
pass """
Destroys Laser when out of bounds in the y dimension
:return: None
"""
if self.rect.y <= -50 or self.rect.y >= self.y_constraint + 50:
self.kill()
def update(self): def update(self):
pass self.rect.y += self.speed
self.destroy_conditionally()