junglejourney

view tools/maps/tileimages.py @ 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
line source
1 """
2 Copyright (C) 2011 David Boddie <david@boddie.org.uk>
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 """
18 import Image
20 tile_size = (16, 24)
22 blank = Image.new("P", tile_size, 0)
23 visited = Image.new("P", (tile_size[0]/4, tile_size[1]/4), 1)
25 def read_xpm(path, symbols = None):
27 lines = open(path).readlines()
28 char_lines = filter(lambda line: line.startswith('"'), lines)
29 strings = map(lambda line: line.strip()[1:-2], char_lines)
30 strings[-1] = strings[-1][:-1]
32 width, height, colours = map(int, strings[0].split()[:3])
33 strings = strings[-height:]
35 if not symbols:
36 symbols = [(".", "\x00"), ("+", "\x02"), ("@", "\x03")]
38 # Fix the symbol replacement table if necessary.
39 for i in range(len(symbols)):
41 old, new = symbols[i]
42 if 48 <= ord(new) <= 57:
43 symbols[i] = (old, chr(ord(new) - 48))
45 data = []
47 for s in strings:
49 for symbol, value in symbols:
50 s = s.replace(symbol, value)
52 data.append(s)
54 return data
56 flowers = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/flowers.xpm",
57 [(".", "\x00"), ("@", "\x01"), ("+", "\x02")])))
58 leaf1 = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/leaf1.xpm")))
59 leaf2 = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/leaf2.xpm")))
61 flowers2 = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/flowers2.xpm",
62 [(".", "\x00"), ("@", "\x01"), ("+", "\x02")])))
63 leaf6 = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/leaf6.xpm")))
64 leaf4 = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/leaf4.xpm")))
66 flowers3 = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/flowers3.xpm",
67 [(".", "\x00"), ("@", "\x01"), ("+", "\x02"), ("#", "\x03")])))
68 leaf5 = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/leaf5.xpm")))
69 leaf3 = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/leaf3.xpm")))
71 exit = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/exit1.xpm",
72 [("+", "\x00"), ("#", "\x01"), (".", "\x02"), ("@", "\x03")])))
74 final_exit1 = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/finalexitl.xpm",
75 [("+", "\x00"), ("#", "\x01"), (".", "\x02"), ("@", "\x03")])))
76 final_exit2 = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/finalexitr.xpm",
77 [(".", "\x00"), ("#", "\x01"), ("+", "\x02"), ("@", "\x03")])))
79 player_size = (8, 24)
81 player = Image.fromstring("P", player_size, "".join(read_xpm("../../images/down1.xpm")))
83 item_size = (16, 16)
85 treasure_images = [
86 Image.fromstring("P", item_size, "".join(
87 read_xpm("../../images/weapon1.xpm", [(".", "\x00"), ("+", "\x01"), ("@", "\x03")]))),
88 Image.fromstring("P", item_size, "".join(
89 read_xpm("../../images/weapon2.xpm", [(".", "\x00"), ("@", "\x01"), ("+", "\x02")]))),
90 Image.fromstring("P", item_size, "".join(
91 read_xpm("../../images/weapon3.xpm", [(".", "\x00"), ("#", "\x01"), ("+", "\x02"), ("@", "\x03")]))),
92 Image.fromstring("P", item_size, "".join(
93 read_xpm("../../images/weapon4.xpm", [(".", "\x00"), ("@", "\x01"), ("+", "\x03")]))),
95 Image.fromstring("P", item_size, "".join(
96 read_xpm("../../images/key.xpm", [(".", "\x00"), ("+", "\x01"), ("@", "\x03")]))),
97 Image.fromstring("P", item_size, "".join(
98 read_xpm("../../images/chest.xpm", [(".", "\x00"), ("+", "\x01"), ("@", "\x03")]))),
99 Image.fromstring("P", item_size, "".join(
100 read_xpm("../../images/statue.xpm", [(".", "\x00"), ("+", "\x02"), ("@", "\x03")]))),
101 Image.fromstring("P", item_size, "".join(
102 read_xpm("../../images/jewel.xpm", [(".", "\x00"), ("@", "\x01"), ("+", "\x02"), ("#", "\x03")]))),
103 Image.fromstring("P", item_size, "".join(
104 read_xpm("../../images/health.xpm", [(".", "\x00"), ("#", "\x01"), ("+", "\x02"), ("@", "\x03")])))
105 ]