junglejourney

changeset 231:e24e7d33b5e7

Added license headers. Scaled each room image horizontally to create more authentic graphics.
author David Boddie <david@boddie.org.uk>
date Sun Feb 05 02:09:50 2012 +0100
parents f7b16fb00dda
children d2d03d54402c
files tools/maps/make_maps.py tools/maps/series.py tools/maps/tileimages.py
diffstat 3 files changed, 94 insertions(+), 28 deletions(-) [+]
line diff
     1.1 --- a/tools/maps/make_maps.py	Sun Feb 05 00:28:07 2012 +0100
     1.2 +++ b/tools/maps/make_maps.py	Sun Feb 05 02:09:50 2012 +0100
     1.3 @@ -1,5 +1,22 @@
     1.4  #!/usr/bin/env python
     1.5  
     1.6 +"""
     1.7 +Copyright (C) 2011 David Boddie <david@boddie.org.uk>
     1.8 +
     1.9 +This program is free software: you can redistribute it and/or modify
    1.10 +it under the terms of the GNU General Public License as published by
    1.11 +the Free Software Foundation, either version 3 of the License, or
    1.12 +(at your option) any later version.
    1.13 +
    1.14 +This program is distributed in the hope that it will be useful,
    1.15 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.16 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.17 +GNU General Public License for more details.
    1.18 +
    1.19 +You should have received a copy of the GNU General Public License
    1.20 +along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1.21 +"""
    1.22 +
    1.23  import os, sys
    1.24  import Image
    1.25  import series
    1.26 @@ -32,7 +49,7 @@
    1.27                     183: (10, 6), 239: (5, 2)}
    1.28      extra_life_rooms = {17: (2, 0), 26: (9, 4)}
    1.29      
    1.30 -    levels = {100: 0, 183: 1, 239: 2, 144: 3}
    1.31 +    levels = {100: 0, 239: 1, 183: 2, 144: 3}
    1.32      
    1.33      treasure_table = [6, 5, 7, 1, 1, 5, 2, 7, 6, 2, 1, 7, 1, 7, 8, 7,
    1.34                        0, 7, 6, 7, 7, 7, 5, 0, 6, 3, 7, 7, 5, 7, 5, 0]
    1.35 @@ -353,9 +370,16 @@
    1.36  
    1.37      images, wall_tile, floor_tiles = select_images(seed)
    1.38      
    1.39 -    im = Image.new("P", (width * room_width * tile_size[0] + (width - 1),
    1.40 -                         height * room_height * tile_size[1] + (height - 1)), 7)
    1.41 -    #im.putpalette((0,0,0, 255,0,0, 0,255,0, 255,255,0, 0,0,255, 255,0,255, 0,255,255, 255,255,255))
    1.42 +    xf = 2
    1.43 +    yf = 1
    1.44 +    
    1.45 +    scaled_tile_size = (int(tile_size[0] * xf), int(tile_size[1] * yf))
    1.46 +    
    1.47 +    scaled_room_size = (int(room_width * scaled_tile_size[0]),
    1.48 +                        int(room_height * scaled_tile_size[1]))
    1.49 +    
    1.50 +    im = Image.new("P", (width * scaled_room_size[0] + (width - 1),
    1.51 +                         height * scaled_room_size[1] + (height - 1)), 0xffffff)
    1.52      black = (0,0,0)
    1.53      red = (255,0,0)
    1.54      green = (0,255,0)
    1.55 @@ -365,11 +389,14 @@
    1.56      cyan = (0,255,255)
    1.57      white = (255,255,255)
    1.58      im.putpalette(black + red + green + yellow + blue + magenta + cyan + white)
    1.59 +    
    1.60      room_palettes = [1, 6, 5, 7]
    1.61      
    1.62      mapper = Mapper(width, height, room_width, room_height, seed, im, images,
    1.63                      wall_tile, floor_tiles)
    1.64      
    1.65 +    start_room = mapper.start_rooms.get(seed)
    1.66 +    
    1.67      for i in range(height):
    1.68          for j in range(width):
    1.69          
    1.70 @@ -386,56 +413,61 @@
    1.71              room_image = Image.fromstring("P", (room_width * tile_size[0],
    1.72                                                  room_height * tile_size[1]),
    1.73                                            room_string)
    1.74 +            room_image.putpalette(black + red + green + yellow + blue + magenta + cyan + white)
    1.75              
    1.76 -            im.paste(room_image, (j * room_width * tile_size[0] + j,
    1.77 -                                  i * room_height * tile_size[1] + i))
    1.78 -    
    1.79 -    start_room = mapper.start_rooms.get(seed)
    1.80 +            if (j, i) == start_room:
    1.81 +                room_image.paste(player,
    1.82 +                    ((tile_size[0] * room_width/2) - tile_size[0]/4,
    1.83 +                     (tile_size[1] * room_height/2) - tile_size[1]/2))
    1.84 +            
    1.85 +            room_image = room_image.resize(scaled_room_size, Image.BILINEAR)
    1.86 +            
    1.87 +            im.paste(room_image, (j * scaled_room_size[0] + j,
    1.88 +                                  i * scaled_room_size[1] + i))
    1.89      
    1.90      if start_room:
    1.91      
    1.92          mapper.find_map_extent(start_room)
    1.93          
    1.94 -        mapper.image.paste(player,
    1.95 -            (int((start_room[0] + 0.5) * mapper.room_width * tile_size[0]) + start_room[0] - tile_size[0]/4,
    1.96 -             int((start_room[1] + 0.5) * mapper.room_height * tile_size[1]) + start_room[1] - tile_size[1]/2))
    1.97 -        
    1.98          for i in range(height):
    1.99              for j in range(width):
   1.100              
   1.101                  if (j,i) not in mapper.visited:
   1.102                  
   1.103 -                    fade(im, j * room_width * tile_size[0] + j,
   1.104 -                             i * room_height * tile_size[1] + i,
   1.105 -                             room_width * tile_size[0],
   1.106 -                             room_height * tile_size[1])
   1.107 +                    fade(im, j * scaled_room_size[0] + j,
   1.108 +                             i * scaled_room_size[1] + i,
   1.109 +                             scaled_room_size[0],
   1.110 +                             scaled_room_size[1])
   1.111      
   1.112      im.save(name)
   1.113  
   1.114  
   1.115  if __name__ == "__main__":
   1.116  
   1.117 -    if len(sys.argv) != 5:
   1.118 +    if len(sys.argv) != 2:
   1.119      
   1.120 -        sys.stderr.write("Usage: %s <width> <height> <seed> <file name>\n\n" % sys.argv[0])
   1.121 -        sys.stderr.write("For the release version of Jungle Journey, use a value of 11\n"
   1.122 -                         "for both width and height, and one of 100, 239, 183 or 144\n"
   1.123 -                         "for the seed value.\n")
   1.124 +        sys.stderr.write("Usage: %s <file name template>\n\n" % sys.argv[0])
   1.125 +        sys.stderr.write("Creates images for the four maps used in the release version of Jungle Journey.\n"
   1.126 +                         "The file name of each image is derived from the template.\n"
   1.127 +                         "For example, specifying a template called map.png will result in files being\n"
   1.128 +                         "created called map1.png, map2.png, map3.png and map4.png.\n\n")
   1.129          sys.exit(1)
   1.130      
   1.131 -    width = int(sys.argv[1])
   1.132 -    height = int(sys.argv[2])
   1.133 -    seed = int(sys.argv[3])
   1.134 -    name = sys.argv[4]
   1.135 +    width = height = 11
   1.136 +    name = sys.argv[1]
   1.137      room_width = 10
   1.138      room_height = 10
   1.139      
   1.140      start_room = (width/2, height/2)
   1.141      stem, suffix = os.path.splitext(name)
   1.142 +    level = 1
   1.143      
   1.144 -    make_map("%s-%02x%s" % (stem, seed, suffix),
   1.145 -             width, height, room_width, room_height, seed)
   1.146 +    for seed in 100, 239, 183, 144:
   1.147      
   1.148 -    print "Created %s-%02x%s" % (stem, seed, suffix)
   1.149 +        file_name = "%s%i%s" % (stem, level, suffix)
   1.150 +        make_map(file_name, width, height, room_width, room_height, seed)
   1.151 +        
   1.152 +        print "Created %s" % file_name
   1.153 +        level += 1
   1.154      
   1.155      sys.exit()
     2.1 --- a/tools/maps/series.py	Sun Feb 05 00:28:07 2012 +0100
     2.2 +++ b/tools/maps/series.py	Sun Feb 05 02:09:50 2012 +0100
     2.3 @@ -1,3 +1,20 @@
     2.4 +"""
     2.5 +Copyright (C) 2011 David Boddie <david@boddie.org.uk>
     2.6 +
     2.7 +This program is free software: you can redistribute it and/or modify
     2.8 +it under the terms of the GNU General Public License as published by
     2.9 +the Free Software Foundation, either version 3 of the License, or
    2.10 +(at your option) any later version.
    2.11 +
    2.12 +This program is distributed in the hope that it will be useful,
    2.13 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.14 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.15 +GNU General Public License for more details.
    2.16 +
    2.17 +You should have received a copy of the GNU General Public License
    2.18 +along with this program.  If not, see <http://www.gnu.org/licenses/>.
    2.19 +"""
    2.20 +
    2.21  def values(first, second, number):
    2.22  
    2.23      # Add the two values as in the Fibonacci sequence, but take the modulus of
     3.1 --- a/tools/maps/tileimages.py	Sun Feb 05 00:28:07 2012 +0100
     3.2 +++ b/tools/maps/tileimages.py	Sun Feb 05 02:09:50 2012 +0100
     3.3 @@ -1,3 +1,20 @@
     3.4 +"""
     3.5 +Copyright (C) 2011 David Boddie <david@boddie.org.uk>
     3.6 +
     3.7 +This program is free software: you can redistribute it and/or modify
     3.8 +it under the terms of the GNU General Public License as published by
     3.9 +the Free Software Foundation, either version 3 of the License, or
    3.10 +(at your option) any later version.
    3.11 +
    3.12 +This program is distributed in the hope that it will be useful,
    3.13 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.14 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.15 +GNU General Public License for more details.
    3.16 +
    3.17 +You should have received a copy of the GNU General Public License
    3.18 +along with this program.  If not, see <http://www.gnu.org/licenses/>.
    3.19 +"""
    3.20 +
    3.21  import Image
    3.22  
    3.23  tile_size = (16, 24)