# HG changeset patch # User David Boddie # Date 1345933130 -7200 # Node ID b74ffb65fb883a002977305bade435da192837f6 # Parent 8862c859a18a6b1296d893197cfaf1b6932c1dec Added more sprites for the Atom and a script to convert them to screen data. diff -r 8862c859a18a -r b74ffb65fb88 images/atom/demise1.png Binary file images/atom/demise1.png has changed diff -r 8862c859a18a -r b74ffb65fb88 images/atom/demise2.png Binary file images/atom/demise2.png has changed diff -r 8862c859a18a -r b74ffb65fb88 images/atom/demise3.png Binary file images/atom/demise3.png has changed diff -r 8862c859a18a -r b74ffb65fb88 images/atom/demise4.png Binary file images/atom/demise4.png has changed diff -r 8862c859a18a -r b74ffb65fb88 images/atom/down1.png Binary file images/atom/down1.png has changed diff -r 8862c859a18a -r b74ffb65fb88 images/atom/down2.png Binary file images/atom/down2.png has changed diff -r 8862c859a18a -r b74ffb65fb88 images/atom/left1.png Binary file images/atom/left1.png has changed diff -r 8862c859a18a -r b74ffb65fb88 images/atom/left2.png Binary file images/atom/left2.png has changed diff -r 8862c859a18a -r b74ffb65fb88 images/atom/right1.png Binary file images/atom/right1.png has changed diff -r 8862c859a18a -r b74ffb65fb88 images/atom/right2.png Binary file images/atom/right2.png has changed diff -r 8862c859a18a -r b74ffb65fb88 images/atom/up1.png Binary file images/atom/up1.png has changed diff -r 8862c859a18a -r b74ffb65fb88 images/atom/up2.png Binary file images/atom/up2.png has changed diff -r 8862c859a18a -r b74ffb65fb88 tools/atom/makesprites.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/atom/makesprites.py Sun Aug 26 00:18:50 2012 +0200 @@ -0,0 +1,100 @@ +#!/usr/bin/env python + +""" +Copyright (C) 2012 David Boddie + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" + +""" Information provided by Kees van Oss: + + BBC ATOM +TILES 16 x 24 -> 12 x 16 +PLAYER 8 x 24 -> 8 x 16 +PROJECTILE 8 x 8 -> 8 x 8 +ENEMIES 16 x 16 -> 12 x 12 +WEAPONS 16 x 16 -> 12 x 12 +TREASURE 16 x 16 -> 12 x 12 +EXIT 16 x 24 -> 12 x 16 + +Hex: $a0 , $80 , $aa +Bin:%10 10 00 00, %10 00 00 00, %10 10 10 10 +Col: BL BL GR GR BL GR GR GR BL BL BL BL + +00 = GR = GREEN, 01 = YE = YELLOW, 10 = BL = BLUE, 11 = RE = RED +""" + +import os, sys +import Image + +# Map RGB values to the appropriate values for the Atom palette. +palette = {"\x00\x00\x00": 2, "\xff\x00\x00": 3, + "\x00\x80\x00": 0, "\xff\xff\x00": 2} + +if __name__ == "__main__": + + this_dir = os.path.split(os.path.abspath(__file__))[0] + image_dir = os.path.join(this_dir, os.path.pardir, os.path.pardir, "images", "atom") + + sprites = "" + + for file_name in os.listdir(image_dir): + + if file_name.endswith(".png"): + + im = Image.open(os.path.join(image_dir, file_name)) + im = im.convert("RGB") + data = im.tostring() + k = 0 + + sprite = "" + + for i in range(im.size[1]): + + # Initialise the byte value for insertion into the sprite data. + byte = 0 + # The offset into the byte for each pixel starts at the highest + # two bits. + offset = 6 + + for j in range(im.size[0]): + + rgb = data[k:k+3] + v = palette[rgb] + byte = byte | (v << offset) + + if offset == 0: + # For the last pixel in a byte, insert it into the sprite + # data, and reset the offset and byte values. + sprite += chr(byte) + offset = 6 + else: + # Otherwise, decrease the offset into the byte to accept + # data for the next pixel. + offset -= 2 + + k += 3 + + if offset != 6: + # If the current byte has not been added to the sprite data, + # add it now. + sprite += chr(byte) + + # Add the sprite data to the collection. + sprites += sprite + + # Write the sprite data to a file. + open("sprites.data", "w").write(sprites) + + sys.exit()