junglejourney

changeset 55:c749e19efb14

Moved the makesprites module into the newly created tools package.
author David Boddie <david@boddie.org.uk>
date Thu Aug 25 00:13:44 2011 +0200
parents 6cf850ec6261
children 1a555d848009
files makesprites.py tools/__init__.py tools/makesprites.py
diffstat 2 files changed, 205 insertions(+), 205 deletions(-) [+]
line diff
     1.1 --- a/makesprites.py	Tue Aug 23 02:03:25 2011 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,205 +0,0 @@
     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 -def read_xpm(path, symbols = None):
    1.24 -
    1.25 -    lines = open(path).readlines()
    1.26 -    char_lines = filter(lambda line: line.startswith('"'), lines)
    1.27 -    strings = map(lambda line: line.strip()[1:-2], char_lines)
    1.28 -    strings[-1] = strings[-1][:-1]
    1.29 -    
    1.30 -    width, height, colours = map(int, strings[0].split()[:3])
    1.31 -    strings = strings[-height:]
    1.32 -    
    1.33 -    if not symbols:
    1.34 -        symbols = [(".", 0), ("+", 2), ("@", 3)]
    1.35 -    
    1.36 -    data = []
    1.37 -    
    1.38 -    for s in strings:
    1.39 -    
    1.40 -        for symbol, value in symbols:
    1.41 -            s = s.replace(symbol, str(value))
    1.42 -        
    1.43 -        data.append(s)
    1.44 -    
    1.45 -    return data
    1.46 -
    1.47 -
    1.48 -tiles = [read_xpm("images/flowers.xpm", [(".", "0"), ("@", "1"), ("+", "2")]),
    1.49 -         read_xpm("images/leaf1.xpm"),
    1.50 -         read_xpm("images/leaf2.xpm"),
    1.51 -         read_xpm("images/flowers2.xpm", [(".", "0"), ("#", "1"), ("+", "2"), ("@", "3")]),
    1.52 -         read_xpm("images/leaf3.xpm", [(".", "0"), ("@", "3"), ("+", "2")]),
    1.53 -         read_xpm("images/leaf4.xpm", [(".", "0"), ("+", "1"), ("#", "2"), ("@", "3")]),
    1.54 -         read_xpm("images/bricks.xpm", [(".", "0"), ("#", "1"), ("+", "2"), ("@", "3")]),
    1.55 -         read_xpm("images/wall1.xpm"),
    1.56 -         read_xpm("images/wall2.xpm")]
    1.57 -
    1.58 -chars = [read_xpm("images/left1.xpm"),
    1.59 -         read_xpm("images/left2.xpm"),
    1.60 -         read_xpm("images/right1.xpm"),
    1.61 -         read_xpm("images/right2.xpm"),
    1.62 -         read_xpm("images/up1.xpm"),
    1.63 -         read_xpm("images/up2.xpm"),
    1.64 -         read_xpm("images/down1.xpm"),
    1.65 -         read_xpm("images/down2.xpm"),
    1.66 -
    1.67 -         # placeholder player demise sprites
    1.68 -         read_xpm("images/left1.xpm"),
    1.69 -         read_xpm("images/right1.xpm"),
    1.70 -         read_xpm("images/up1.xpm"),
    1.71 -         read_xpm("images/down1.xpm"),
    1.72 -
    1.73 -         read_xpm("images/spell1-1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    1.74 -         read_xpm("images/spell1-2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    1.75 -         # placeholder projectile sprites
    1.76 -         read_xpm("images/spell1-1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    1.77 -         read_xpm("images/spell1-2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    1.78 -         read_xpm("images/spell1-1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    1.79 -         read_xpm("images/spell1-2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    1.80 -         read_xpm("images/spell1-1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    1.81 -         read_xpm("images/spell1-2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    1.82 -         # placeholder projectile explode sprites
    1.83 -         read_xpm("images/spell1-1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    1.84 -         read_xpm("images/spell1-2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    1.85 -         read_xpm("images/spell1-1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    1.86 -         read_xpm("images/spell1-2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    1.87 -
    1.88 -         read_xpm("images/birdld1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    1.89 -         read_xpm("images/birdld2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    1.90 -         read_xpm("images/birdld3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    1.91 -         read_xpm("images/birdld4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    1.92 -         read_xpm("images/birdrd1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    1.93 -         read_xpm("images/birdrd2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    1.94 -         read_xpm("images/birdrd3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    1.95 -         read_xpm("images/birdrd4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    1.96 -
    1.97 -         read_xpm("images/waspld1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    1.98 -         read_xpm("images/waspld2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    1.99 -         read_xpm("images/waspld3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.100 -         read_xpm("images/waspld4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.101 -         read_xpm("images/wasprd1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.102 -         read_xpm("images/wasprd2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.103 -         read_xpm("images/wasprd3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.104 -         read_xpm("images/wasprd4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.105 -
   1.106 -         # placeholder enemy sprites
   1.107 -         read_xpm("images/birdld1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.108 -         read_xpm("images/birdld2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.109 -         read_xpm("images/birdld3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.110 -         read_xpm("images/birdld4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.111 -         read_xpm("images/birdrd1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.112 -         read_xpm("images/birdrd2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.113 -         read_xpm("images/birdrd3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.114 -         read_xpm("images/birdrd4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.115 -
   1.116 -         # placeholder enemy sprites
   1.117 -         read_xpm("images/birdld1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.118 -         read_xpm("images/birdld2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.119 -         read_xpm("images/birdld3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.120 -         read_xpm("images/birdld4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.121 -         read_xpm("images/birdrd1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.122 -         read_xpm("images/birdrd2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.123 -         read_xpm("images/birdrd3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.124 -         read_xpm("images/birdrd4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.125 -
   1.126 -         # placeholder enemy sprites
   1.127 -         read_xpm("images/birdld1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.128 -         read_xpm("images/birdld2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.129 -         read_xpm("images/birdld3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.130 -         read_xpm("images/birdld4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.131 -         read_xpm("images/birdrd1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.132 -         read_xpm("images/birdrd2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.133 -         read_xpm("images/birdrd3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.134 -         read_xpm("images/birdrd4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.135 -
   1.136 -         # placeholder enemy appear
   1.137 -         read_xpm("images/emerge1.xpm", [(".", "0"), ("+", "1"), ("#", "2"), ("@", "3")]),
   1.138 -         read_xpm("images/emerge2.xpm", [(".", "0"), ("+", "1"), ("#", "3"), ("@", "2")]),
   1.139 -         read_xpm("images/emerge3.xpm", [(".", "0"), ("+", "1"), ("#", "2"), ("@", "3")]),
   1.140 -         read_xpm("images/emerge4.xpm", [(".", "0"), ("+", "1"), ("#", "2"), ("@", "3")]),
   1.141 -
   1.142 -         # placeholder enemy demise
   1.143 -         read_xpm("images/emerge4.xpm", [(".", "0"), ("+", "1"), ("#", "2"), ("@", "3")]),
   1.144 -         read_xpm("images/emerge3.xpm", [(".", "0"), ("+", "1"), ("#", "2"), ("@", "3")]),
   1.145 -         read_xpm("images/emerge2.xpm", [(".", "0"), ("+", "1"), ("#", "3"), ("@", "2")]),
   1.146 -         read_xpm("images/emerge1.xpm", [(".", "0"), ("+", "1"), ("#", "2"), ("@", "3")]),
   1.147 -
   1.148 -         # placeholder weapons
   1.149 -         read_xpm("images/birdlu1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.150 -         read_xpm("images/birdlu2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.151 -         read_xpm("images/birdru1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.152 -         read_xpm("images/birdru2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.153 -
   1.154 -         # placeholder treasure
   1.155 -         read_xpm("images/birdlu1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.156 -         read_xpm("images/birdlu2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.157 -         read_xpm("images/birdru1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.158 -         read_xpm("images/birdru2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.159 -
   1.160 -         # exit
   1.161 -         read_xpm("images/exit1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.162 -         read_xpm("images/exit2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.163 -
   1.164 -         # placeholder final exit
   1.165 -         read_xpm("images/exit1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.166 -         read_xpm("images/exit2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   1.167 -         ]
   1.168 -
   1.169 -
   1.170 -def read_sprite(lines):
   1.171 -
   1.172 -    data = ""
   1.173 -    
   1.174 -    # Read 8 rows at a time.
   1.175 -    for row in range(0, len(lines), 8):
   1.176 -
   1.177 -        # Read 4 columns at a time.
   1.178 -        for column in range(0, len(lines[0]), 4):
   1.179 -
   1.180 -            # Read the rows.
   1.181 -            for line in lines[row:row + 8]:
   1.182 -
   1.183 -                shift = 3
   1.184 -                byte = 0
   1.185 -                for pixel in line[column:column + 4]:
   1.186 -
   1.187 -                    if pixel == "1":
   1.188 -                        byte = byte | (0x01 << shift)
   1.189 -                    elif pixel == "2":
   1.190 -                        byte = byte | (0x10 << shift)
   1.191 -                    elif pixel == "3":
   1.192 -                        byte = byte | (0x11 << shift)
   1.193 -
   1.194 -                    shift -= 1
   1.195 -
   1.196 -                data += chr(byte)
   1.197 -    
   1.198 -    return data
   1.199 -
   1.200 -
   1.201 -def read_sprites(sprites):
   1.202 -
   1.203 -    data = ""
   1.204 -    
   1.205 -    for lines in sprites:
   1.206 -        data += read_sprite(lines)
   1.207 -    
   1.208 -    return data
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tools/makesprites.py	Thu Aug 25 00:13:44 2011 +0200
     2.3 @@ -0,0 +1,205 @@
     2.4 +#!/usr/bin/env python
     2.5 +
     2.6 +"""
     2.7 +Copyright (C) 2011 David Boddie <david@boddie.org.uk>
     2.8 +
     2.9 +This program is free software: you can redistribute it and/or modify
    2.10 +it under the terms of the GNU General Public License as published by
    2.11 +the Free Software Foundation, either version 3 of the License, or
    2.12 +(at your option) any later version.
    2.13 +
    2.14 +This program is distributed in the hope that it will be useful,
    2.15 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.16 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.17 +GNU General Public License for more details.
    2.18 +
    2.19 +You should have received a copy of the GNU General Public License
    2.20 +along with this program.  If not, see <http://www.gnu.org/licenses/>.
    2.21 +"""
    2.22 +
    2.23 +def read_xpm(path, symbols = None):
    2.24 +
    2.25 +    lines = open(path).readlines()
    2.26 +    char_lines = filter(lambda line: line.startswith('"'), lines)
    2.27 +    strings = map(lambda line: line.strip()[1:-2], char_lines)
    2.28 +    strings[-1] = strings[-1][:-1]
    2.29 +    
    2.30 +    width, height, colours = map(int, strings[0].split()[:3])
    2.31 +    strings = strings[-height:]
    2.32 +    
    2.33 +    if not symbols:
    2.34 +        symbols = [(".", 0), ("+", 2), ("@", 3)]
    2.35 +    
    2.36 +    data = []
    2.37 +    
    2.38 +    for s in strings:
    2.39 +    
    2.40 +        for symbol, value in symbols:
    2.41 +            s = s.replace(symbol, str(value))
    2.42 +        
    2.43 +        data.append(s)
    2.44 +    
    2.45 +    return data
    2.46 +
    2.47 +
    2.48 +tiles = [read_xpm("images/flowers.xpm", [(".", "0"), ("@", "1"), ("+", "2")]),
    2.49 +         read_xpm("images/leaf1.xpm"),
    2.50 +         read_xpm("images/leaf2.xpm"),
    2.51 +         read_xpm("images/flowers2.xpm", [(".", "0"), ("#", "1"), ("+", "2"), ("@", "3")]),
    2.52 +         read_xpm("images/leaf3.xpm", [(".", "0"), ("@", "3"), ("+", "2")]),
    2.53 +         read_xpm("images/leaf4.xpm", [(".", "0"), ("+", "1"), ("#", "2"), ("@", "3")]),
    2.54 +         read_xpm("images/bricks.xpm", [(".", "0"), ("#", "1"), ("+", "2"), ("@", "3")]),
    2.55 +         read_xpm("images/wall1.xpm"),
    2.56 +         read_xpm("images/wall2.xpm")]
    2.57 +
    2.58 +chars = [read_xpm("images/left1.xpm"),
    2.59 +         read_xpm("images/left2.xpm"),
    2.60 +         read_xpm("images/right1.xpm"),
    2.61 +         read_xpm("images/right2.xpm"),
    2.62 +         read_xpm("images/up1.xpm"),
    2.63 +         read_xpm("images/up2.xpm"),
    2.64 +         read_xpm("images/down1.xpm"),
    2.65 +         read_xpm("images/down2.xpm"),
    2.66 +
    2.67 +         # placeholder player demise sprites
    2.68 +         read_xpm("images/left1.xpm"),
    2.69 +         read_xpm("images/right1.xpm"),
    2.70 +         read_xpm("images/up1.xpm"),
    2.71 +         read_xpm("images/down1.xpm"),
    2.72 +
    2.73 +         read_xpm("images/spell1-1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    2.74 +         read_xpm("images/spell1-2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    2.75 +         # placeholder projectile sprites
    2.76 +         read_xpm("images/spell1-1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    2.77 +         read_xpm("images/spell1-2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    2.78 +         read_xpm("images/spell1-1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    2.79 +         read_xpm("images/spell1-2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    2.80 +         read_xpm("images/spell1-1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    2.81 +         read_xpm("images/spell1-2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    2.82 +         # placeholder projectile explode sprites
    2.83 +         read_xpm("images/spell1-1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    2.84 +         read_xpm("images/spell1-2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    2.85 +         read_xpm("images/spell1-1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    2.86 +         read_xpm("images/spell1-2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    2.87 +
    2.88 +         read_xpm("images/birdld1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    2.89 +         read_xpm("images/birdld2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    2.90 +         read_xpm("images/birdld3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    2.91 +         read_xpm("images/birdld4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    2.92 +         read_xpm("images/birdrd1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    2.93 +         read_xpm("images/birdrd2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    2.94 +         read_xpm("images/birdrd3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    2.95 +         read_xpm("images/birdrd4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    2.96 +
    2.97 +         read_xpm("images/waspld1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    2.98 +         read_xpm("images/waspld2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
    2.99 +         read_xpm("images/waspld3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.100 +         read_xpm("images/waspld4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.101 +         read_xpm("images/wasprd1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.102 +         read_xpm("images/wasprd2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.103 +         read_xpm("images/wasprd3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.104 +         read_xpm("images/wasprd4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.105 +
   2.106 +         # placeholder enemy sprites
   2.107 +         read_xpm("images/birdld1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.108 +         read_xpm("images/birdld2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.109 +         read_xpm("images/birdld3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.110 +         read_xpm("images/birdld4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.111 +         read_xpm("images/birdrd1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.112 +         read_xpm("images/birdrd2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.113 +         read_xpm("images/birdrd3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.114 +         read_xpm("images/birdrd4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.115 +
   2.116 +         # placeholder enemy sprites
   2.117 +         read_xpm("images/birdld1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.118 +         read_xpm("images/birdld2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.119 +         read_xpm("images/birdld3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.120 +         read_xpm("images/birdld4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.121 +         read_xpm("images/birdrd1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.122 +         read_xpm("images/birdrd2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.123 +         read_xpm("images/birdrd3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.124 +         read_xpm("images/birdrd4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.125 +
   2.126 +         # placeholder enemy sprites
   2.127 +         read_xpm("images/birdld1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.128 +         read_xpm("images/birdld2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.129 +         read_xpm("images/birdld3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.130 +         read_xpm("images/birdld4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.131 +         read_xpm("images/birdrd1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.132 +         read_xpm("images/birdrd2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.133 +         read_xpm("images/birdrd3.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.134 +         read_xpm("images/birdrd4.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.135 +
   2.136 +         # placeholder enemy appear
   2.137 +         read_xpm("images/emerge1.xpm", [(".", "0"), ("+", "1"), ("#", "2"), ("@", "3")]),
   2.138 +         read_xpm("images/emerge2.xpm", [(".", "0"), ("+", "1"), ("#", "3"), ("@", "2")]),
   2.139 +         read_xpm("images/emerge3.xpm", [(".", "0"), ("+", "1"), ("#", "2"), ("@", "3")]),
   2.140 +         read_xpm("images/emerge4.xpm", [(".", "0"), ("+", "1"), ("#", "2"), ("@", "3")]),
   2.141 +
   2.142 +         # placeholder enemy demise
   2.143 +         read_xpm("images/emerge4.xpm", [(".", "0"), ("+", "1"), ("#", "2"), ("@", "3")]),
   2.144 +         read_xpm("images/emerge3.xpm", [(".", "0"), ("+", "1"), ("#", "2"), ("@", "3")]),
   2.145 +         read_xpm("images/emerge2.xpm", [(".", "0"), ("+", "1"), ("#", "3"), ("@", "2")]),
   2.146 +         read_xpm("images/emerge1.xpm", [(".", "0"), ("+", "1"), ("#", "2"), ("@", "3")]),
   2.147 +
   2.148 +         # placeholder weapons
   2.149 +         read_xpm("images/birdlu1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.150 +         read_xpm("images/birdlu2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.151 +         read_xpm("images/birdru1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.152 +         read_xpm("images/birdru2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.153 +
   2.154 +         # placeholder treasure
   2.155 +         read_xpm("images/birdlu1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.156 +         read_xpm("images/birdlu2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.157 +         read_xpm("images/birdru1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.158 +         read_xpm("images/birdru2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.159 +
   2.160 +         # exit
   2.161 +         read_xpm("images/exit1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.162 +         read_xpm("images/exit2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.163 +
   2.164 +         # placeholder final exit
   2.165 +         read_xpm("images/exit1.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.166 +         read_xpm("images/exit2.xpm", [(".", "0"), ("+", "1"), ("@", "3")]),
   2.167 +         ]
   2.168 +
   2.169 +
   2.170 +def read_sprite(lines):
   2.171 +
   2.172 +    data = ""
   2.173 +    
   2.174 +    # Read 8 rows at a time.
   2.175 +    for row in range(0, len(lines), 8):
   2.176 +
   2.177 +        # Read 4 columns at a time.
   2.178 +        for column in range(0, len(lines[0]), 4):
   2.179 +
   2.180 +            # Read the rows.
   2.181 +            for line in lines[row:row + 8]:
   2.182 +
   2.183 +                shift = 3
   2.184 +                byte = 0
   2.185 +                for pixel in line[column:column + 4]:
   2.186 +
   2.187 +                    if pixel == "1":
   2.188 +                        byte = byte | (0x01 << shift)
   2.189 +                    elif pixel == "2":
   2.190 +                        byte = byte | (0x10 << shift)
   2.191 +                    elif pixel == "3":
   2.192 +                        byte = byte | (0x11 << shift)
   2.193 +
   2.194 +                    shift -= 1
   2.195 +
   2.196 +                data += chr(byte)
   2.197 +    
   2.198 +    return data
   2.199 +
   2.200 +
   2.201 +def read_sprites(sprites):
   2.202 +
   2.203 +    data = ""
   2.204 +    
   2.205 +    for lines in sprites:
   2.206 +        data += read_sprite(lines)
   2.207 +    
   2.208 +    return data