junglejourney

changeset 169:a4f794f4a710

Updated the instructions.
author David Boddie <david@boddie.org.uk>
date Wed Sep 21 00:05:47 2011 +0200
parents 43f7143d39a1
children 4abd543af48a
files materials/make_packaging.py
diffstat 1 files changed, 127 insertions(+), 25 deletions(-) [+]
line diff
     1.1 --- a/materials/make_packaging.py	Mon Sep 19 22:59:50 2011 +0200
     1.2 +++ b/materials/make_packaging.py	Wed Sep 21 00:05:47 2011 +0200
     1.3 @@ -18,27 +18,29 @@
     1.4              image = QImage(QSize(*self.size), QImage.Format_RGB32)
     1.5              image.fill(qRgb(255,255,255))
     1.6          
     1.7 -        x, y = 0, 0
     1.8 +        positions = [(0, 0)]
     1.9          for obj in self.objects:
    1.10          
    1.11 -            x, y = obj.render(image, x, y)
    1.12 +            x, y = obj.render(image, positions)
    1.13 +            positions.append((x, y))
    1.14          
    1.15          return image
    1.16  
    1.17  class TextBox:
    1.18  
    1.19 -    def __init__(self, bbox, text_items, follow = False):
    1.20 +    def __init__(self, bbox, text_items, follow = False, index = -1):
    1.21      
    1.22          self.bbox = bbox
    1.23          self.text_items = text_items
    1.24          self.follow = follow
    1.25 +        self.index = index
    1.26      
    1.27 -    def render(self, image, previous_x, previous_y):
    1.28 +    def render(self, image, positions):
    1.29      
    1.30          x, y, width, height = self.bbox
    1.31          
    1.32          if self.follow:
    1.33 -            y += previous_y
    1.34 +            y = y + positions[self.index][1]
    1.35          
    1.36          p = QPainter()
    1.37          p.begin(image)
    1.38 @@ -129,6 +131,7 @@
    1.39      def format(self, words, width, last = False):
    1.40      
    1.41          output = []
    1.42 +        x = 0
    1.43          
    1.44          if len(words) == 0:
    1.45              spacing = 0
    1.46 @@ -136,10 +139,15 @@
    1.47              # Full justify the text.
    1.48              total_width = sum(map(lambda word: word.width(), words))
    1.49              spacing = (width - total_width)/float(len(words))
    1.50 +        elif self.font.get("align", "left") == "centre":
    1.51 +            # Centre the text.
    1.52 +            total_width = sum(map(lambda word: word.width(), words))
    1.53 +            total_space = sum(map(lambda word: word.space(), words)[:-1])
    1.54 +            x = width/2.0 - total_width/2.0 - total_space/2.0
    1.55 +            spacing = None
    1.56          else:
    1.57              spacing = None
    1.58          
    1.59 -        x = 0
    1.60          for word in words:
    1.61          
    1.62              output.append((word.font(), x, word.text))
    1.63 @@ -200,6 +208,37 @@
    1.64          return metrics.width(" ")
    1.65  
    1.66  
    1.67 +class Image:
    1.68 +
    1.69 +    def __init__(self, bbox, path, scale = None, follow = False, index = -1):
    1.70 +    
    1.71 +        self.bbox = bbox
    1.72 +        self.path = path
    1.73 +        self.follow = follow
    1.74 +        self.index = index
    1.75 +        self.scale = scale
    1.76 +    
    1.77 +    def render(self, image, positions):
    1.78 +    
    1.79 +        x, y, width, height = self.bbox
    1.80 +        
    1.81 +        if self.follow:
    1.82 +            y = y + positions[self.index][1]
    1.83 +        
    1.84 +        p = QPainter()
    1.85 +        p.begin(image)
    1.86 +        p.setRenderHint(QPainter.TextAntialiasing)
    1.87 +        
    1.88 +        im = QImage(self.path)
    1.89 +        if self.scale:
    1.90 +            im = im.scaled(self.scale * im.width(), self.scale * im.height())
    1.91 +        p.drawImage(x, y, im)
    1.92 +        
    1.93 +        p.end()
    1.94 +        
    1.95 +        return x + im.size().width(), y + im.size().height()
    1.96 +
    1.97 +
    1.98  if __name__ == "__main__":
    1.99  
   1.100      app = QApplication(sys.argv)
   1.101 @@ -248,6 +287,12 @@
   1.102                                "left indent": 160,
   1.103                                "right indent": 40}
   1.104      
   1.105 +    exclamation = {"family": "FreeSerif",
   1.106 +                   "size": 28,
   1.107 +                   "style": "italic",
   1.108 +                   "weight": "bold",
   1.109 +                   "align": "centre"}
   1.110 +    
   1.111      pages = [
   1.112          Page((750, 1000),
   1.113               [TextBox((50, 40, 650, 0), 
   1.114 @@ -259,7 +304,7 @@
   1.115                              "sweep the cold face of the moon and I perceive the clicks, whistles and "
   1.116                              "cries of creatures in the hot air that cloaks this place. Desperately, I "
   1.117                              "try to stay my panic and remember those fragments of wilderness craft "
   1.118 -                            "learned and unlearned many years ago.\n"),
   1.119 +                            "learned and unlearned many years ago.\n\n"),
   1.120                         Text(italic_quote,
   1.121                              "Choose your weapon carefully,\n"
   1.122                              "Get ready for a fight.\n"
   1.123 @@ -274,7 +319,7 @@
   1.124                              "Struggling through the dense undergrowth, I search for signs of a track or "
   1.125                              "trail. At first glance, paths that seemed to lead to safety turn out to be "
   1.126                              "impassable, overgrown by tangled and twisted vines. I remember the words of "
   1.127 -                            "an old teacher:\n"),
   1.128 +                            "an old teacher:\n\n"),
   1.129                         Text(quote,
   1.130                              u'\u201cDo not be tempted to use fire to make your way. '
   1.131                              'Many a traveller has strayed from the path, using fire to blaze a trail, '
   1.132 @@ -295,45 +340,102 @@
   1.133                         Text(monospace_quote, "*RUN JUNGLE\n"),
   1.134                         Text(regular,
   1.135                              "then press Return. If you are loading the game from cassette, press play on the "
   1.136 -                            "cassette recorder. The game should now load.\n\n"),
   1.137 +                            "cassette recorder. The game should now load.\n\n\n"),
   1.138                         Text(title, "Playing the Game\n"),
   1.139                         Text(regular,
   1.140 -                            "Your character can be moved around the screen by using four control keys:\n"),
   1.141 -                       Text(keys_quote,
   1.142 +                            "The player must help the character reach the exit for each level. However, the "
   1.143 +                            "player must first find a key to unlock the exit. On the final level, the exit "
   1.144 +                            "does not require a key but it may be obstructed. Enemies will appear in each "
   1.145 +                            "location and attack the player's character. These can be destroyed by "
   1.146 +                            "projectiles fired by the current weapon.\n\n"
   1.147 +                            "Your character can be moved around the screen by using four control keys:\n")]),
   1.148 +              TextBox((50, 0, 650, 0),
   1.149 +                      [Text(keys_quote,
   1.150                              "Z\n"
   1.151                              "X\n"
   1.152                              ":\n"
   1.153 -                            "/")
   1.154 -                      ]),
   1.155 -              TextBox((50, -keys_quote["size"]*4*1.125, 650, 0),
   1.156 +                            "/")], follow = True),
   1.157 +              TextBox((50, 0, 650, 0),
   1.158                        [Text(key_descriptions_quote,
   1.159                              "left\n"
   1.160                              "right\n"
   1.161                              "up\n"
   1.162                              "down\n"),
   1.163                         Text(regular,
   1.164 -                            "Enemies can be destroying by the projectiles fired by the player's weapon. "
   1.165                              "To fire a weapon, press the Return key. There are four different types of "
   1.166                              "weapon available in the game.\n\n"
   1.167 -                            "The player must help the character reach the exit for each level. However, the "
   1.168 -                            "player must first find a key to unlock the exit. On the final level, the exit "
   1.169 -                            "does not require a key but it may be obstructed.\n\n"
   1.170 -                            "Other keys can be used to control the game:\n"),
   1.171 -                       Text(keys_quote,
   1.172 +                            "Alternatively, you may may using an analogue joystick connected to a Plus 1 "
   1.173 +                            "expansion interface. Select joystick controls by pressing the J key on the "
   1.174 +                            "title page. Press K to select keyboard controls again.\n\n"
   1.175 +                            "Other keys can be used to control the game:\n")],
   1.176 +                      follow = True, index = -2),
   1.177 +              TextBox((50, 0, 650, 0),
   1.178 +                      [Text(keys_quote,
   1.179                              "S\n"
   1.180                              "Q\n"
   1.181                              "P\n"
   1.182                              "O\n"
   1.183 -                            "Escape")
   1.184 -                      ], follow = True),
   1.185 -              TextBox((50, -keys_quote["size"]*5*1.125, 650, 0),
   1.186 +                            "Escape")], follow = True),
   1.187 +              TextBox((50, 0, 650, 0),
   1.188                        [Text(key_descriptions_quote,
   1.189                              "enable sound effects\n"
   1.190                              "disable sound effects\n"
   1.191                              "pause the game\n"
   1.192                              "resume the game\n"
   1.193 -                            "quit the game, returning to the title screen\n")
   1.194 -                      ], follow = True)
   1.195 +                            "quit the game, returning to the title screen\n")],
   1.196 +                      follow = True, index = -2)
   1.197 +             ]),
   1.198 +        Page((750, 1000),
   1.199 +             [TextBox((50, 40, 650, 0),
   1.200 +                      [Text(title, "Treasure\n"),
   1.201 +                       Text(regular, "Items of treasure can be found throughout the jungle. "
   1.202 +                                     "Pick these up to increase your score.\n")]),
   1.203 +              Image((80, -8, 620, 0), "../images/key.xpm", scale = 4,
   1.204 +                    follow = True),
   1.205 +              TextBox((170, 20, 480, 0),
   1.206 +                      [Text(regular, "Find the key to open the door on all levels except the last. "
   1.207 +                                     "Each key is worth 50 points.")],
   1.208 +                      follow = True, index = -2),
   1.209 +              Image((80, 8, 620, 0), "../images/chest.xpm", scale = 4,
   1.210 +                    follow = True, index = -2),
   1.211 +              TextBox((170, 48, 480, 0),
   1.212 +                      [Text(regular, "Treasure chests are worth 20 points.")],
   1.213 +                      follow = True, index = -3),
   1.214 +              Image((80, 8, 620, 0), "../images/jewel.xpm", scale = 4,
   1.215 +                    follow = True, index = -2),
   1.216 +              TextBox((170, 48, 480, 0),
   1.217 +                      [Text(regular, "Jewels are worth 5 points.")],
   1.218 +                      follow = True, index = -3),
   1.219 +              Image((80, 8, 620, 0), "../images/statue.xpm", scale = 4,
   1.220 +                    follow = True, index = -2),
   1.221 +              TextBox((170, 48, 480, 0),
   1.222 +                      [Text(regular, "Statues are worth 10 points.")],
   1.223 +                      follow = True, index = -3),
   1.224 +              Image((80, 8, 620, 0), "../images/health.xpm", scale = 4,
   1.225 +                    follow = True, index = -2),
   1.226 +              TextBox((170, 36, 480, 0),
   1.227 +                      [Text(regular, "Presents are worth 40 points and boost your strength by 20 units.")],
   1.228 +                      follow = True, index = -3),
   1.229 +              TextBox((50, 48, 650, 0),
   1.230 +                      [Text(title, "Exits\n"),
   1.231 +                       Text(regular, "Each level has an exit that can be opened using a key. "
   1.232 +                                     "On the last level you will find a gate that leads to safety. "
   1.233 +                                     "This does not require a key, but it is well hidden.\n")],
   1.234 +                      follow = True),
   1.235 +              Image((112, -4, 620, 0), "../images/exit1.xpm", scale = 4,
   1.236 +                    follow = True),
   1.237 +              TextBox((240, 36, 410, 0),
   1.238 +                      [Text(regular, "The exit is initially locked. Find the key to unlock it.")],
   1.239 +                      follow = True, index = -2),
   1.240 +              Image((80, 8, 620, 0), "../images/finalexitl.xpm", scale = 4,
   1.241 +                    follow = True, index = -2),
   1.242 +              Image((144, 8, 620, 0), "../images/finalexitr.xpm", scale = 4,
   1.243 +                    follow = True, index = -3),
   1.244 +              TextBox((240, 48, 410, 0),
   1.245 +                      [Text(regular, "The final exit is hidden somewhere on the final level.")],
   1.246 +                      follow = True, index = -4),
   1.247 +              TextBox((50, 950, 650, 0),
   1.248 +                      [Text(exclamation, "Have a safe journey!")])
   1.249               ])
   1.250          ]
   1.251