costs
[tabakrolletjie.git] / tabakrolletjie / scenes / help.py
index f9b35e5af35916c3ccac28895aa6e6640531fd7e..4ec31fc5d7e9b083b5940821f150f6fc5eff3bd1 100644 (file)
@@ -15,16 +15,19 @@ from ..transforms import Multiply, NullTransform, ColourWedges
 
 class HelpItem(object):
     FONT = loader.load_font(FONTS['sans'], size=14)
-    
+
     def __init__(self, imgparts, label, transform=NullTransform()):
         self._img_size = int(imgparts[0])
-        self._img = loader.load_image(*imgparts, transform=transform).convert_alpha()
+        self._img = loader.load_image(
+            *imgparts, transform=transform).convert_alpha()
 
         maxwidth = SCREEN_SIZE[0] / 2 - self._img_size
-        
+
         wrap_width = int(2.25 * maxwidth / self.FONT.get_height())
 
-        self._text = [self.FONT.render(text, True, COLOURS["white"]) for text in wrap(label, wrap_width)]
+        self._text = [
+            self.FONT.render(text, True, COLOURS["white"])
+            for text in wrap(label, wrap_width)]
 
     def render(self, surface, height, x_offset=0):
         surface.blit(self._img, (x_offset, height), None)
@@ -37,41 +40,139 @@ class HelpScene(BaseScene):
 
     def enter(self, gamestate):
         self._space = pymunk.Space()
-        
+
         font_title = loader.load_font(FONTS['bold'], size=32)
-        self._title = font_title.render("Help! What's going on?!", True, COLOURS["white"])
-        
+        self._title = font_title.render(
+            "Help! What's going on?!", True, COLOURS["white"])
+
         self._tools = self.create_tools(gamestate)
         self._items = self.create_items(gamestate)
 
     def create_tools(self, gamestate):
         tools = []
         tools.append(ImageButton(
-            '32', 'exit.png', name='exit', pos=(SCREEN_SIZE[0] - 50, SCREEN_SIZE[1] - 40)))
+            '32', 'exit.png', name='exit',
+            pos=(SCREEN_SIZE[0] - 50, SCREEN_SIZE[1] - 40)))
         return tools
 
     def create_items(self, gamestate):
         items = [
-            HelpItem(("48", "turnip3.png"), "This is a space turnip, the most valuable vegetable in the universe. A crucial ingredient of longevity serum, space navigator tonic and a pink sweet that everyone loves."),
-            HelpItem(("64", "mouldA.png"), "This is Boyd the space mould. He loves turnips. You've disinfected your ship a thousand times, but somehow he shows up on every planet at night to devour your crop. He is vulnerable to light, but beware -- he builds up a resistance if you overuse the same colour."),
-            HelpItem(("32", "seed.png"), "This is a turnip seed. You get a limited number of these at the start of a level. You can plant them, and you can use them to buy lights to protect your crop. Turnips which survive to harvest yield more seeds."),
-            HelpItem(("48", "lamp.png"), "This is a lamp. It comes in many colours, and has some other varying properties. It is powered by your farm's battery during the night. The battery recharges during the day.", transform=Multiply(colour=COLOURS["yellow"])),
-            HelpItem(("48", "spotlight.png"), "This is a spotlight. Unlike a lamp, it has a rotating beam. Lights can be multicoloured, like this one. You can toggle lights on and off at night to conserve power, and toggle the colour of multicoloured lights.", transform=ColourWedges(colours=("red", "green"))),
-            HelpItem(("32", "night.png"), "When you have finished planting seeds and placing lights, you can prepare for Boyd's night-time onslaught by clicking this button."),
-            HelpItem(("32", "pause.png"), "You can pause the game during the night if you need to make a more detailed analysis of why you're losing horribly."),
-            #HelpItem(("", ""), ""),
-            #HelpItem(("", ""), ""),
+            HelpItem(("48", "turnip3.png"), (
+                "This is a space turnip, the most valuable vegetable in the"
+                " universe. A crucial ingredient of longevity serum, space"
+                " navigator tonic and a pink sweet that everyone loves.")),
         ]
 
-        # Special mould assembly
-        items[1]._img.blit(loader.load_image("32", "mouldB.png").convert_alpha(), (30, 30), None)
-        items[1]._img.blit(loader.load_image("32", "eyeballA.png").convert_alpha(), (10, 10), None)
+        mould = HelpItem(("64", "mouldA.png"), (
+            "This is Boyd the space mould. He loves turnips. You've"
+            " disinfected your ship a thousand times, but somehow he shows"
+            " up on every planet at night to devour your crop. He is"
+            " vulnerable to light, but beware -- he builds up a resistance"
+            " if you overuse the same colour."))
+
+        mould._img.blit(
+            loader.load_image("32", "mouldB.png").convert_alpha(),
+            (30, 30), None)
+        mould._img.blit(
+            loader.load_image("32", "eyeballA.png").convert_alpha(),
+            (10, 10), None)
+        mould._img.blit(
+            loader.load_image("32", "eyelid.png").convert_alpha(),
+            (10, 10), None)
+
+        items.append(mould)
+
+        items.extend([
+            HelpItem(("32", "seed.png"), (
+                "This is a turnip seed. You get a limited number of these at"
+                " the start of a level. You can plant them, and you can use"
+                " them to buy lights to protect your crop. Turnips which"
+                " survive to harvest yield more seeds. Click on the icon that"
+                " looks like this to start planting seeds. It takes three nights"
+                " for a turnip to mature.")),
+            HelpItem(("48", "lamp.png"), (
+                "This is a lamp. It comes in many colours, and has some other"
+                " varying properties. It is powered by your farm's battery"
+                " during the night. The battery recharges during the day."),
+                transform=Multiply(colour=COLOURS["yellow"])),
+            HelpItem(("48", "pulsatinglamp.png"), (
+                "This is a pulsating lamp. Its light radius increases and"
+                " decreases."),
+                transform=Multiply(colour=COLOURS["cyan"])),
+            HelpItem(("48", "spotlight.png"), (
+                "This is a spotlight. Unlike a lamp, it has a beam which is"
+                " pointed in a particular direction. To change the direction of"
+                " a beam, right-click near the spotlight and drag. You can only"
+                " do this during the day. Some spotlights rotate."),
+                transform=Multiply(colour=COLOURS["red"])),
+            HelpItem(("48", "lamp.png"), (
+                " Lights can be multicoloured, like this one. You can toggle"
+                " lights on and off at night to conserve power, and toggle the"
+                " colour of multicoloured lights."),
+                transform=ColourWedges(colours=("red", "green"))),
+        ])   
+
+        soil = HelpItem(("48", "square.png"), (
+            "This is soil. You can plant seeds in it and position lights on"
+            " it. Lights and plants can't overlap with each other."))
+        soil._img.blit(
+            loader.load_image("textures", "soil.png").convert_alpha(),
+            (0, 0), None, pgl.BLEND_RGBA_MULT)
+        items.append(soil)   
+
+        stone = HelpItem(("48", "square.png"), (
+            "This is a stone wall. It gets in your way. On the other hand, it"
+            " also gets in Boyd's way."))
+        stone._img.blit(
+            loader.load_image("textures", "stone.png").convert_alpha(),
+            (0, 0), None, pgl.BLEND_RGBA_MULT)
+        items.append(stone)  
+
+        shrub = HelpItem(("48", "circle.png"), (
+            "This is a shrub. It works exactly like a wall, except that it's"
+            " round."))
+        shrub._img.blit(
+            loader.load_image("textures", "shrub.png").convert_alpha(),
+            (0, 0), None, pgl.BLEND_RGBA_MULT)
+        items.append(shrub)
+
+        items.extend([
+            HelpItem(("32", "spotlight.png"), (
+                "Click on a light icon like this to get a menu of colour options"
+                " available on your level.")),
+            HelpItem(("32", "spotlight.png"), (
+                "Once you have selected a colour option, you will be able to"
+                " place the light, as long as this does not reduce your seed"
+                " count to zero. The cost will be deducted from your seed"
+                " total."),
+                transform=Multiply(colour=COLOURS["magenta"])),
+            HelpItem(("32", "remove.png"), (
+                "Buyer's remorse? Use this icon to blow up unwanted lights. You"
+                " don't get your money back. Sorry.")),
+            HelpItem(("32", "default_cursor.png"), (
+                "You can use this to change your cursor back to an arrow.")),
+            HelpItem(("32", "night.png"), (
+                "When you have finished planting seeds and placing lights, you"
+                " can prepare for Boyd's night-time onslaught by clicking this"
+                " button.")),
+            HelpItem(("32", "pause.png"), (
+                "You can pause the game during the night if you need to make a"
+                " more detailed analysis of why you're losing horribly.")),
+            HelpItem(("32", "day.png"), (
+                "If you have run out of turnips, you can click this button to"
+                " skip to the next day. Or you can keep playing with your lights."
+                " If you have no power left either, or you are completely"
+                " bankrupt, the night will end automatically.")),
+            HelpItem(("32", "exit.png"), (
+                "Click this icon to quit the level in disgust and return to the"
+                " menu.")),
+        ])
 
         return items
 
     def render(self, surface, gamestate):
         surface.fill(COLOURS["blue"])
-        
+
         pos = ((surface.get_width() - self._title.get_width()) / 2, 5)
         surface.blit(self._title, pos, None)
 
@@ -80,12 +181,16 @@ class HelpScene(BaseScene):
 
         for item in self._items:
             item.render(surface, height, x_offset)
-            height += max(item._img_size, item.FONT.get_height() * len(item._text))
+            height += max(
+                item._img_size, item.FONT.get_height() * len(item._text))
             height += 5
-            if height > SCREEN_SIZE[1]:
+            if height > SCREEN_SIZE[1] - 50:
                 height = 50
                 x_offset = SCREEN_SIZE[0] / 2
 
+        for tool in self._tools:
+            tool.render(surface)
+
     def event(self, ev, gamestate):
         if ev.type == pgl.KEYDOWN:
             if ev.key in (pgl.K_q, pgl.K_ESCAPE):