X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=tabakrolletjie%2Flights.py;h=7b2c26380c9800ded9540fcb281766d87903b679;hb=8406c478924d4364b9a017f655e6757863341ff9;hp=fef2b44d2133e32c2f43d2e1366ad00101e8559e;hpb=9f15c2338900ce9f615c9b06adac6a1341fcbf1c;p=tabakrolletjie.git diff --git a/tabakrolletjie/lights.py b/tabakrolletjie/lights.py index fef2b44..7b2c263 100644 --- a/tabakrolletjie/lights.py +++ b/tabakrolletjie/lights.py @@ -9,6 +9,7 @@ import pygame.display import pygame.draw import pygame.locals as pgl import pygame.rect +import pygame.transform from .constants import LIGHT_CATEGORY, FITTINGS_CATEGORY, COLOURS from .rays import RayPolyManager @@ -258,7 +259,6 @@ class BaseLight(object): else: self.colour = self.colour_cycle[self.colour_pos] self.on = True - self.invalidate_fitting_image() def tick(self): pass @@ -312,6 +312,17 @@ class SpotLight(BaseLight): self.angular_velocity = kw.pop("angular_velocity", None) super(SpotLight, self).__init__(**kw) + def fitting_image(self): + fitting_image = super(SpotLight, self).fitting_image() + rot_fitting_image = pygame.transform.rotozoom(fitting_image, self.ray_manager.direction - 90, 1) + + rot_rect = fitting_image.get_rect().copy() + rot_rect.center = rot_fitting_image.get_rect().center + rot_fitting_image = rot_fitting_image.subsurface(rot_rect).copy() + + return rot_fitting_image + + def tick(self): if self.angular_velocity: self.ray_manager.direction -= self.angular_velocity