Finished Laser
This commit is contained in:
parent
8ac6529106
commit
1df05915a0
1 changed files with 22 additions and 4 deletions
|
@ -3,10 +3,28 @@ import pygame
|
|||
|
||||
class Laser(pygame.sprite.Sprite):
|
||||
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):
|
||||
pass
|
||||
def destroy_conditionally(self):
|
||||
"""
|
||||
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):
|
||||
pass
|
||||
self.rect.y += self.speed
|
||||
self.destroy_conditionally()
|
||||
|
|
Loading…
Reference in a new issue