pybeamshow/effects/effect.py

46 lines
873 B
Python
Raw Permalink Normal View History

2023-02-23 00:19:20 +01:00
from typing import Optional
2023-02-15 21:08:47 +01:00
import pygame as pg
2023-02-23 00:19:20 +01:00
from util.transform import PositionGenerator, transform_static
2023-02-20 01:59:55 +01:00
2023-02-15 21:08:47 +01:00
class Effect(pg.sprite.Sprite):
def __init__(
self, image: pg.Surface, rect: pg.Rect, *groups: pg.sprite.Group
) -> None:
super().__init__(*groups)
self.rect = rect
self.image = image
def draw(self, surface: pg.Surface):
surface.blit(self.image, self.rect)
2023-02-22 22:55:11 +01:00
class MovingEffect(Effect):
def __init__(
2023-02-23 00:19:20 +01:00
self,
image: pg.Surface,
rect: pg.Rect,
mover: Optional[PositionGenerator] = None,
*groups: pg.sprite.Group
2023-02-22 22:55:11 +01:00
) -> None:
super().__init__(image, rect, *groups)
2023-02-23 00:19:20 +01:00
self.mover = mover or transform_static(rect.center)
2023-02-24 17:20:51 +01:00
next(self.mover)
2023-02-24 18:21:21 +01:00
"""
square
line scan vh
starfield spawn chance
rainbow circle rotate
fix double spot 4 spots
"""