* Maybe configure lights in separate json file, to allow reuse of consistent models in multiple levels?
* Allow going down to zero seeds by buying lights if a turnip is planted
* Maybe make the mould weaker at the start
-* Different prices for different lights
-* Different power usage for different lights
-* Calculate both from # of colours, speed, beam width, etc.?
* Display power usage when lights are bought? Also other properties.
* Maybe also display information next to existing lights (on click?)
* Generally balance the levels better and add more levels
* Bug: Crash when removing a rotating light
* Turnip / light spacing bug: a light can be placed right below a turnip, but must be much further away if above the turnip. This happens whether the turnip or the light is placed first. I assume it has to do with how the turnip image is positioned relative to its body.
* Allow denser turnip spacing
+* Different power usage for different lights (this was already done)
+* Different prices for different lights
+* Calculate both from # of colours, speed, beam width, etc.?
"available_lights": [
{
"type": "lamp",
- "cost": 3,
"available_colours": ["blue", "red", "blue/red"],
"intensity": 0.5
}
"available_lights": [
{
"type": "spotlight",
- "cost": 3,
"available_colours": ["blue", "red"],
"intensity": 0.6,
"spread": 35,
"available_lights": [
{
"type": "spotlight",
- "cost": 3,
"available_colours": ["yellow", "magenta"],
"intensity": 0.5,
"radius_limits": [20, 400],
"available_lights": [
{
"type": "lamp",
- "cost": 3,
"available_colours": ["blue", "red"],
"intensity": 0.8
}
"available_lights": [
{
"type": "pulsatinglamp",
- "cost": 3,
"available_colours": ["red/blue", "blue/green"],
"intensity": 0.5,
"radius_limits": [20, 400]
"available_lights": [
{
"type": "spotlight",
- "cost": 5,
"available_colours": ["red"],
"radius_limits": [20, 400],
"direction": 135,
},
{
"type": "lamp",
- "cost": 3,
"available_colours": ["blue", "yellow/red/green", "cyan/magenta"],
"intensity": 0.5
},
{
"type": "pulsatinglamp",
- "cost": 3,
"available_colours": ["cyan", "blue/green"],
"intensity": 0.5
}
return BaseLight.find_cls(light_type).FITTING_IMG
+def seed_cost(light_config, num_colours):
+ """Calculate a seed cost for a light from its configuration. """
+ cls = BaseLight.find_cls(light_config["type"])
+ return cls.BASE_COST + int(cls.find_cost(light_config) / 10) + num_colours
+
+
class BaseLight(object):
""" Common light functionality. """
RAY_MANAGER = RayPolyManager
FITTING_IMG = None
FITTING_RADIUS = 24.0
+ BASE_COST = 0
# cached surfaces
_surface_cache = {}
if c.__name__.lower() == light_type]
return light_class
+ @classmethod
+ def find_cost(cls, config):
+ cost = 5 * config["intensity"]
+ return cost
+
def add(self, space):
if self.body.space is not None:
space.remove(self.body, *self.body.shapes)
class Lamp(BaseLight):
FITTING_IMG = "lamp.png"
+ BASE_COST = 1
class PulsatingLamp(BaseLight):
DEFAULT_PULSE_VELOCITY = 2
DEFAULT_INTENSITY_RANGE = (0.0, 0.9)
DEFAULT_INTENSITY_VELOCITY = 0.1
+ BASE_COST = 3
def __init__(self, **kw):
self.pulse_range = kw.pop("pulse_range", self.DEFAULT_PULSE_RANGE)
self.intensity, self.intensity_velocity = self._update_range(
self.intensity, self.intensity_velocity, self.intensity_range)
+ @classmethod
+ def find_cost(cls, config):
+ cost = super(PulsatingLamp, cls).find_cost(config)
+ cost += config.get("pulse_velocity", cls.DEFAULT_PULSE_VELOCITY)
+ pr = config.get("pulse_range", cls.DEFAULT_PULSE_RANGE)
+ cost += (pr[1] - pr[0]) / 10
+ cost += 5 * config.get("intensity_velocity", cls.DEFAULT_INTENSITY_VELOCITY)
+ ir = config.get("intensity_range", cls.DEFAULT_INTENSITY_RANGE)
+ cost += 5 * (ir[1] - ir[0])
+ return cost
+
class SpotLight(BaseLight):
FITTING_IMG = "spotlight.png"
+ BASE_COST = 5
def __init__(self, **kw):
self.angular_velocity = kw.pop("angular_velocity", None)
if self.angular_velocity:
self.ray_manager.direction -= self.angular_velocity
self.ray_manager.update_shapes()
+
+ @classmethod
+ def find_cost(cls, config):
+ cost = super(SpotLight, cls).find_cost(config)
+ cost += config.get("angular_velocity", 0)
+ return cost
from .base import BaseScene
from ..battery import BatteryManager
-from ..lights import LightManager, light_fitting_by_type, check_space_for_light
+from ..lights import LightManager, light_fitting_by_type, check_space_for_light, seed_cost
from ..infobar import InfoBar
from ..obstacles import ObstacleManager
from ..events import SceneChangeEvent
tool = ImageButton(
'32', '%s.png' % light_config["type"], name='light',
pos=(x, y))
- font = loader.load_font(FONTS["sans"], size=12)
- tool_cost = font.render("%d" % light_config["cost"], True, (0, 0, 0))
- tool._img.blit(tool_cost, (16, 12), None)
tool.light_config = light_config
tools.append(tool)
x += step
colour_combos = light_config["available_colours"]
for combo in colour_combos:
colours = combo.split("/")
+ cost = seed_cost(light_config, len(colours))
+
light_fitting = light_fitting_by_type(light_config["type"])
light_tool = ImageButton(
"32", light_fitting, transform=ColourWedges(colours=colours),
pos=(x, height), name=combo)
+ font = loader.load_font(FONTS["sans"], size=12)
+ tool_cost = font.render("%d" % cost, True, (0, 0, 0))
+ light_tool._img.blit(tool_cost, (16, 12), None)
+
light_tool.colours = colours
+ light_tool.cost = cost
self._light_toolbar.append(light_tool)
x += 40
light_cfg["direction"] = math.degrees(angle)
break
- def _place_light(self, gamestate, cfg, colours, ev):
+ def _place_light(self, gamestate, cfg, cost, colours, ev):
cfg = cfg.copy()
- cost = cfg.pop("cost")
cfg.pop("available_colours")
if gamestate.seeds > cost:
pos = pymunk.pygame_util.from_pygame(
transform=ColourWedges(colours=light_tool.colours))
# colour=COLOURS[0] + (172,)))
self._light_colors = light_tool.colours
+ self._light_cost = light_tool.cost
return
if self._tool:
if self._tool.name == "seed":
elif self._tool.name == "light" and self._light_colors:
self._place_light(
gamestate, self._tool.light_config,
- self._light_colors, ev)
+ self._light_cost, self._light_colors, ev)
else:
# Not tool, so check lights
self._lights.toggle_nearest(ev.pos, surfpos=True)