junglejourney

view tools/maps/tileimages.py @ 230:f7b16fb00dda

Added tools created in an experimental map making repository.
author David Boddie <david@boddie.org.uk>
date Sun Feb 05 00:28:07 2012 +0100
parents
children e24e7d33b5e7
line source
1 import Image
3 tile_size = (16, 24)
5 blank = Image.new("P", tile_size, 0)
6 visited = Image.new("P", (tile_size[0]/4, tile_size[1]/4), 1)
8 def read_xpm(path, symbols = None):
10 lines = open(path).readlines()
11 char_lines = filter(lambda line: line.startswith('"'), lines)
12 strings = map(lambda line: line.strip()[1:-2], char_lines)
13 strings[-1] = strings[-1][:-1]
15 width, height, colours = map(int, strings[0].split()[:3])
16 strings = strings[-height:]
18 if not symbols:
19 symbols = [(".", "\x00"), ("+", "\x02"), ("@", "\x03")]
21 # Fix the symbol replacement table if necessary.
22 for i in range(len(symbols)):
24 old, new = symbols[i]
25 if 48 <= ord(new) <= 57:
26 symbols[i] = (old, chr(ord(new) - 48))
28 data = []
30 for s in strings:
32 for symbol, value in symbols:
33 s = s.replace(symbol, value)
35 data.append(s)
37 return data
39 flowers = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/flowers.xpm",
40 [(".", "\x00"), ("@", "\x01"), ("+", "\x02")])))
41 leaf1 = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/leaf1.xpm")))
42 leaf2 = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/leaf2.xpm")))
44 flowers2 = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/flowers2.xpm",
45 [(".", "\x00"), ("@", "\x01"), ("+", "\x02")])))
46 leaf6 = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/leaf6.xpm")))
47 leaf4 = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/leaf4.xpm")))
49 flowers3 = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/flowers3.xpm",
50 [(".", "\x00"), ("@", "\x01"), ("+", "\x02"), ("#", "\x03")])))
51 leaf5 = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/leaf5.xpm")))
52 leaf3 = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/leaf3.xpm")))
54 exit = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/exit1.xpm",
55 [("+", "\x00"), ("#", "\x01"), (".", "\x02"), ("@", "\x03")])))
57 final_exit1 = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/finalexitl.xpm",
58 [("+", "\x00"), ("#", "\x01"), (".", "\x02"), ("@", "\x03")])))
59 final_exit2 = Image.fromstring("P", tile_size, "".join(read_xpm("../../images/finalexitr.xpm",
60 [(".", "\x00"), ("#", "\x01"), ("+", "\x02"), ("@", "\x03")])))
62 player_size = (8, 24)
64 player = Image.fromstring("P", player_size, "".join(read_xpm("../../images/down1.xpm")))
66 item_size = (16, 16)
68 treasure_images = [
69 Image.fromstring("P", item_size, "".join(
70 read_xpm("../../images/weapon1.xpm", [(".", "\x00"), ("+", "\x01"), ("@", "\x03")]))),
71 Image.fromstring("P", item_size, "".join(
72 read_xpm("../../images/weapon2.xpm", [(".", "\x00"), ("@", "\x01"), ("+", "\x02")]))),
73 Image.fromstring("P", item_size, "".join(
74 read_xpm("../../images/weapon3.xpm", [(".", "\x00"), ("#", "\x01"), ("+", "\x02"), ("@", "\x03")]))),
75 Image.fromstring("P", item_size, "".join(
76 read_xpm("../../images/weapon4.xpm", [(".", "\x00"), ("@", "\x01"), ("+", "\x03")]))),
78 Image.fromstring("P", item_size, "".join(
79 read_xpm("../../images/key.xpm", [(".", "\x00"), ("+", "\x01"), ("@", "\x03")]))),
80 Image.fromstring("P", item_size, "".join(
81 read_xpm("../../images/chest.xpm", [(".", "\x00"), ("+", "\x01"), ("@", "\x03")]))),
82 Image.fromstring("P", item_size, "".join(
83 read_xpm("../../images/statue.xpm", [(".", "\x00"), ("+", "\x02"), ("@", "\x03")]))),
84 Image.fromstring("P", item_size, "".join(
85 read_xpm("../../images/jewel.xpm", [(".", "\x00"), ("@", "\x01"), ("+", "\x02"), ("#", "\x03")]))),
86 Image.fromstring("P", item_size, "".join(
87 read_xpm("../../images/health.xpm", [(".", "\x00"), ("#", "\x01"), ("+", "\x02"), ("@", "\x03")])))
88 ]