blob: 9d12428f5037542997bce8897ce4b94d244d6c15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import pygame
class Laser(pygame.sprite.Sprite):
def __init__(self, position: tuple, geschwindigkeit: float):
super().__init__()
self.image = pygame.Surface((3,10))
self.image.fill((255,255,255)) # Farbe
self.rect = self.image.get_rect()
self.rect.center = position
self.__pos_y = float(self.rect.y)
self.__geschwindigkeit = float(geschwindigkeit)
def getRect(self):
return self.rect
def bewegen(self, dt: float):
self.__pos_y += self.__geschwindigkeit * dt
self.rect.y = int(round(self.__pos_y))
def einschraenken(self, screenHoehe: int):
if self.rect.bottom < 0 or self.rect.top > screenHoehe:
self.kill()
|