jbperin wrote: ↑Tue Jun 16, 2020 12:19 pm
Please may I ask you to explain a bit further this idea ? How is that possible to use a green color in a character ?
How do you deal with transparency ? is it based on ORing pixels of the front character with the background character ?
Sure. It is quite easy. For each sprite you need the graphic and the mask, for instance:
- manta.png (260 Bytes) Viewed 8032 times
The mask has pixels set to 1 (white) where there has to be transparency. When you draw the graphic over a background you first perform an AND with the mask (so the non-transparent parts are removed) then an OR with the graphic.
In Blake's 7 and Skooldaze what I did was draw the graphics this way:
- 00-lookRight.png (731 Bytes) Viewed 8032 times
Then create a script that does the following:
1/ Initialize two sets of tiles, one for the graphics with one tile set to all 0s and one for the masks with all 1s
2/ Create the graphic and mask from the above picture. I do this this way (it is a Matlab script):
Code: Select all
% im is the image
im=rgb2gray(im);
graphic=im>0;
mask=(im==150); % This corresponds to the green color (results in gray)
graphic=(graphic) & not(mask);
Yeah, I know it is ugly and dirty, but I came up with it once and...
3/ Sections the graphic in tiles and add each tile to the list if it is not there already. The same for the mask.
4/ Creates all the data to be used by the program
In my case, this ends up as a tile map:
Code: Select all
.byt 0, 1, 2, 3, 0
.byt 4, 5, 6, 7, 8
.byt 9, 10, 11, 12, 13
.byt 14, 15, 16, 17, 0
.byt 18, 19, 20, 21, 0
.byt 22, 23, 24, 25, 0
.byt 26, 27, 28, 29, 0
where each code represents a graphic tile and a mask tile:
Code: Select all
; Tile graphic 1
.byt $0, $0, $0, $0, $0, $0, $0, $2
; Tile graphic 2
.byt $0, $0, $0, $0, $0, $0, $14, $22
...
; Tile mask 1
.byt $ff, $ff, $ff, $ff, $ff, $ff, $78, $60
; Tile mask 2
.byt $ff, $ff, $ff, $ff, $ff, $ff, $40, $40
...
Obviously you can store the image data in other formats (not in tiles, for instance, but as a single block).
Hope it is clear.
Cheers!