VPATH=../../sources/vector
-TURNIP=seed turnip1 turnip2 turnip3
+TURNIP=turnip1 turnip2 turnip3
MOULD_BODY=mouldA mouldB mouldC
MOULD=eyeballA eyeballB eyeballC
LIGHT=spotlight lamp laser
IMG16=$(MOULD_BODY)
-IMG32=$(TURNIP) $(MOULD_BODY) $(MOULD) $(LIGHT)
-IMG64=$(MOULD_BODY) $(LIGHT)
+IMG32=$(MOULD_BODY) $(MOULD) $(LIGHT) seed
+IMG48=$(LIGHT) $(TURNIP)
+IMG64=$(MOULD_BODY)
CURSORS=seed $(LIGHT)
PNG16=$(patsubst %, 16/%.png, $(IMG16))
PNG32=$(patsubst %, 32/%.png, $(IMG32))
+PNG48=$(patsubst %, 48/%.png, $(IMG48))
PNG64=$(patsubst %, 64/%.png, $(IMG64))
PNG_CURSORS=$(patsubst %, cursors/%.png, $(CURSORS))
-all: $(PNG16) $(PNG32) $(PNG64) $(PNG_CURSORS)
+all: $(PNG16) $(PNG32) $(PNG48) $(PNG64) $(PNG_CURSORS)
16/%.png: %.svg
@mkdir -p `dirname $@`
@inkscape -z -e $@ -w 16 -h 16 $<
-
+
32/%.png: %.svg
@mkdir -p `dirname $@`
@inkscape -z -e $@ -w 32 -h 32 $<
-
+
+48/%.png: %.svg
+ @mkdir -p `dirname $@`
+ @inkscape -z -e $@ -w 48 -h 48 $<
+
64/%.png: %.svg
@mkdir -p `dirname $@`
@inkscape -z -e $@ -w 64 -h 64 $<
for light in self._lights:
light.add(self._space)
+ def add_light(self, cfg):
+ light = BaseLight.load(cfg)
+ self._lights.append(light)
+ light.add(self._space)
+
def toggle_nearest(self, *args, **kw):
light = self.nearest(*args, **kw)
if light:
# defaults
RAY_MANAGER = RayPolyManager
FITTING_IMG = None
- FITTING_RADIUS = 10.0
+ FITTING_RADIUS = 24.0
# cached surfaces
_surface_cache = {}
if self._image is None:
fitting_colour = self.COLOURS[self.colour]
self._image = loader.load_image(
- "64", self.FITTING_IMG,
+ "48", self.FITTING_IMG,
transform=Multiply(colour=fitting_colour))
return self._image
def render_fitting(self, surface):
rx, ry = self.ray_manager.pygame_position(surface)
- surface.blit(self.get_image(), (rx - 32, ry - 32), None, 0)
+ surface.blit(self.get_image(), (rx - 24, ry - 24), None, 0)
def tick(self):
pass
""" Be prepared. """
+import pygame.display
import pygame.locals as pgl
import pymunk
from ..events import SceneChangeEvent
from ..utils import debug_timer
from ..loader import loader
-from ..transforms import Overlay, Multiply
+from ..transforms import Overlay, Multiply, Alpha
from ..constants import SCREEN_SIZE, FONTS
from ..widgets import ImageButton
tool.render(surface)
self._draw_cursor(surface)
+ def _place_seed(self, gamestate, ev):
+ if self._seeds > 0:
+ # plant seed
+ # We don't want top-left to equal the mouse position,
+ # since that looks weird, but we don't want to center
+ # the turnip under the mouse either, since that
+ # causes issues as well, so we compromise
+ pos = (ev.pos[0] - 8, ev.pos[1] - 8)
+ try:
+ turnip = Turnip(age=0, pos=pos, space=self._space)
+ self._turnips.append(turnip)
+ self._seeds -= 1
+ self._update_toolbar(gamestate)
+ except TurnipInvalidPosition as e:
+ # TODO: Add error sound or something
+ pass
+
+ def _place_spotlight(self, gamestate, colour, ev):
+ if self._seeds > 5:
+ self._seeds -= 5
+ self._update_toolbar(gamestate)
+ pos = pymunk.pygame_util.from_pygame(ev.pos,
+ pygame.display.get_surface())
+ cfg = {
+ "type": "spotlight",
+ "colour": colour,
+ "position": pos,
+ "direction": 45,
+ "angle_limits": [0, 90],
+ "intensity": 0.5,
+ "radius_limits": [0, 100],
+ }
+ gamestate.station["lights"].append(cfg)
+ self._lights.add_light(cfg)
+
def event(self, ev, gamestate):
if ev.type == pgl.KEYDOWN:
if ev.key in (pgl.K_q, pgl.K_ESCAPE):
else:
self._tool = tool.name
if self._tool == 'seed':
- self._set_cursor(tool.name)
+ self._set_cursor('seed', transform=Alpha(alpha=172))
elif self._tool == 'red_spotlight':
self._set_cursor(
'spotlight',
colour=(0, 0, 255, 172)))
return
if self._tool == "seed":
- if self._seeds > 0:
- # plant seed
- # We don't want top-left to equal the mouse position,
- # since that looks weird, but we don't want to center
- # the turnip under the mouse either, since that
- # causes issues as well, so we compromise
- pos = (ev.pos[0] - 8, ev.pos[1] - 8)
- try:
- turnip = Turnip(age=0, pos=pos, space=self._space)
- self._turnips.append(turnip)
- self._seeds -= 1
- self._update_toolbar(gamestate)
- except TurnipInvalidPosition as e:
- # TODO: Add error sound or something
- pass
+ self._place_seed(gamestate, ev)
+ elif self._tool == 'red_spotlight':
+ self._place_spotlight(gamestate, 'red', ev)
+ elif self._tool == 'blue_spotlight':
+ self._place_spotlight(gamestate, 'blue', ev)
else:
# Not tool, so check lights
self._lights.toggle_nearest(ev.pos, surfpos=True)
mult.fill(self.colour)
surface.blit(mult, (0, 0), None, pgl.BLEND_RGBA_MULT)
return surface
+
+
+class Alpha(Transform):
+ """ Make translucent. """
+
+ ARGS = ["alpha"]
+
+ def apply(self, surface):
+ surface.fill((255, 255, 255, self.alpha), None, pgl.BLEND_RGBA_MULT)
+ return surface
self._update_image()
self.eaten = False # Flag for boyd
self._body = pymunk.Body(0, 0, pymunk.Body.STATIC)
- self._shape = pymunk.Circle(self._body, 16)
+ self._shape = pymunk.Circle(self._body, 24)
self._shape.filter = TURNIP_FILTER
self._body.position = pymunk.pygame_util.from_pygame(
self._pos, pygame.display.get_surface())
space.add(self._body, self._shape)
def _update_image(self):
- self._image = loader.load_image('32', 'turnip%d.png' % (self._age + 1))
+ self._image = loader.load_image('48', 'turnip%d.png' % (self._age + 1))
self._image = pygame.transform.rotate(self._image, self._rotation)
def render(self, surface):