From: Simon Cross Date: Sat, 10 Sep 2016 11:44:35 +0000 (+0200) Subject: Merge branch 'master' of ctpug.org.za:tabakrolletjie X-Git-Tag: tabakrolletjie-v1.0.0~118 X-Git-Url: https://git.ctpug.org.za/?p=tabakrolletjie.git;a=commitdiff_plain;h=466429edf04d36e1eeb667e79d55c40f29afbf91;hp=7658f591fa2684700dae130eedd56543a2fcadf0 Merge branch 'master' of ctpug.org.za:tabakrolletjie --- diff --git a/TODO.txt b/TODO.txt index e94fc8d..bfc582a 100644 --- a/TODO.txt +++ b/TODO.txt @@ -6,7 +6,6 @@ TODO * Battery and light power consts * Mould resistances * Mould power increases to prevent farming -* Fitting rotation * Save game * More sounds * Five levels @@ -17,3 +16,4 @@ Done * Light colour selection * All lights multicolour * Light direction configuration +* Fitting rotation diff --git a/data/images/32/spotlight.png b/data/images/32/spotlight.png index 4e55c02..0cf4b79 100644 Binary files a/data/images/32/spotlight.png and b/data/images/32/spotlight.png differ diff --git a/data/images/48/spotlight.png b/data/images/48/spotlight.png index b7231c8..e4bdf3d 100644 Binary files a/data/images/48/spotlight.png and b/data/images/48/spotlight.png differ diff --git a/data/images/cursors/spotlight.png b/data/images/cursors/spotlight.png index 4e55c02..0cf4b79 100644 Binary files a/data/images/cursors/spotlight.png and b/data/images/cursors/spotlight.png differ diff --git a/data/stations/station-alpha.json b/data/stations/station-alpha.json index 07f23e9..4678e6c 100644 --- a/data/stations/station-alpha.json +++ b/data/stations/station-alpha.json @@ -23,6 +23,12 @@ "vertices": [ [200, 350], [250, 350], [250, 400], [200, 400] ] + }, + { + "type": "shrub", + "shrublets": [ + [600, 100, 50], [700, 200, 100] + ] } ], "lights": [ diff --git a/sources/vector/spotlight.svg b/sources/vector/spotlight.svg index 4f0d58b..11c4300 100644 --- a/sources/vector/spotlight.svg +++ b/sources/vector/spotlight.svg @@ -26,8 +26,8 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="1.4" - inkscape:cx="123.25557" - inkscape:cy="182.29837" + inkscape:cx="115.01124" + inkscape:cy="139.81635" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="true" @@ -63,14 +63,14 @@ id="layer1" transform="translate(0,-698.0315)"> 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 diff --git a/tabakrolletjie/obstacles.py b/tabakrolletjie/obstacles.py index bae1c1d..9adb803 100644 --- a/tabakrolletjie/obstacles.py +++ b/tabakrolletjie/obstacles.py @@ -79,3 +79,29 @@ class Wall(BaseObstacle): def render(self, surface): surface.blit(self.get_image(), (0, 0), None, 0) + + +class Shrub(BaseObstacle): + + def __init__(self, shrublets): + super(Shrub, self).__init__() + for [x, y, r] in shrublets: + self.shapes.append(pymunk.Circle(self.body, r, offset=(x, y))) + self._image = None + + def get_image(self): + if self._image is None: + self._image = pygame.surface.Surface(SCREEN_SIZE).convert_alpha() + self._image.fill((0,0,0,0)) + + for shape in self.shapes: + centre = pymunk.pygame_util.to_pygame(shape.offset, self._image) + pygame.draw.circle(self._image, (255, 255, 255), centre, int(shape.radius)) + + shrub_texture = loader.load_image("textures", "shrub.png").convert_alpha() + self._image.blit(shrub_texture, (0, 0), None, pgl.BLEND_RGBA_MULT) + + return self._image + + def render(self, surface): + surface.blit(self.get_image(), (0, 0), None, 0)