Merge branch 'master' of ctpug.org.za:tabakrolletjie
authorSimon Cross <hodgestar@gmail.com>
Sat, 10 Sep 2016 11:44:35 +0000 (13:44 +0200)
committerSimon Cross <hodgestar@gmail.com>
Sat, 10 Sep 2016 11:44:35 +0000 (13:44 +0200)
TODO.txt
data/images/32/spotlight.png
data/images/48/spotlight.png
data/images/cursors/spotlight.png
data/stations/station-alpha.json
sources/vector/spotlight.svg
tabakrolletjie/lights.py
tabakrolletjie/obstacles.py

index e94fc8d883283c9d4f5600e4e5b7522b60ad7016..bfc582a8a0a79f87a7fcf7447607abfa3128e218 100644 (file)
--- 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
index 4e55c022e23c4665dbb2ca7bef6df1481cf7f6c0..0cf4b791e25a405309b35d0c5ca16bcc53a425fb 100644 (file)
Binary files a/data/images/32/spotlight.png and b/data/images/32/spotlight.png differ
index b7231c866d80264957aafcdfd9736724d9571a75..e4bdf3d313407cdf5adbeb21b6c27ef743ac0e6b 100644 (file)
Binary files a/data/images/48/spotlight.png and b/data/images/48/spotlight.png differ
index 4e55c022e23c4665dbb2ca7bef6df1481cf7f6c0..0cf4b791e25a405309b35d0c5ca16bcc53a425fb 100644 (file)
Binary files a/data/images/cursors/spotlight.png and b/data/images/cursors/spotlight.png differ
index 07f23e98b7cf1b134c6c6148341be9efb5a2fa97..4678e6c56e80cb67124589739f0e979312f5cb4e 100644 (file)
       "vertices": [
         [200, 350], [250, 350], [250, 400], [200, 400]
       ]
+    },
+    {
+      "type": "shrub",
+      "shrublets": [
+        [600, 100, 50], [700, 200, 100]
+      ]
     }
   ],
   "lights": [
index 4f0d58b3b4cdadba2d5602781d59ae25752d5936..11c4300ebf1ff224028bd4acaf5909d3d78490ab 100644 (file)
@@ -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"
      id="layer1"
      transform="translate(0,-698.0315)">
     <path
-       style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:5;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
-       d="m 35.433071,733.46457 c 88.582679,-17.71653 194.881889,-17.71653 283.464569,0 0,124.01575 -35.43307,248.0315 -141.73229,248.0315 -106.299208,0 -141.732279,-124.01575 -141.732279,-248.0315 z"
+       style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:5;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       d="m 35.433069,770.01093 c 88.582681,-17.71653 194.881891,-17.71653 283.464571,0 0,124.01575 -35.43307,223.66726 -141.73229,223.66726 -106.299206,0 -141.732281,-99.65151 -141.732281,-223.66726 z"
        id="path4529"
        inkscape:connector-curvature="0"
        sodipodi:nodetypes="cccc" />
     <path
-       style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
-       d="m 17.716535,822.04725 c 0,-17.71654 35.433071,-17.71654 35.433071,0 0,141.73228 35.433071,177.16535 124.015744,177.16535 88.58268,0 124.01575,-35.43307 124.01575,-177.16535 0,-17.71654 35.43307,-17.71654 35.43307,0 0,141.73228 -35.43307,212.59845 -159.44882,212.59845 -124.015744,0 -159.448815,-70.86617 -159.448815,-212.59845 z"
+       style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       d="m 17.716535,822.04725 c 0,-17.7166 35.433071,-17.7166 35.433071,0 0,141.7323 35.433071,177.1653 124.015744,177.1653 88.58268,0 124.01575,-35.433 124.01575,-177.1653 0,-17.7166 35.43307,-17.7166 35.43307,0 0,141.7323 -35.43307,212.59835 -159.44882,212.59835 -124.01574,0 -159.448815,-70.86605 -159.448815,-212.59835 z"
        id="path4533"
        inkscape:connector-curvature="0"
        sodipodi:nodetypes="ccsccsc" />
index fef2b44d2133e32c2f43d2e1366ad00101e8559e..7b2c26380c9800ded9540fcb281766d87903b679 100644 (file)
@@ -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
index bae1c1dac23c0d7da1f6710d81c856a0c1b30c30..9adb80308180f40a76accc528492d7fe9026c35c 100644 (file)
@@ -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)