256 Colour Tutorial Part 1: Difference between revisions

m
Line 27: Line 27:
You can now make some graphics with your favourite graphics package, but bear in mind that if you really want to do nifty effects with the 8-bit palette, it's always preferrable to create the graphics ''natively'' under this colour depth, to save you from the mess of conversions. Two good choices of such programmes are Deluxe Paint ][ Enhanced and [http://code.google.com/p/grafx2/ Grafx 2], as they're 8-bit pixel graphics editors and they won't ''do foolish things automatically (like "friendly" sorting and trimming your palette, merging slots with similar colours, dithering you images, etc.)''. This is '''VERY''' important, as we want the imported graphics to be '''COMPLETELY IDENTICAL''' to the original, including the order of the colours assigned to the slot indices, for the desired effects to work. Most of the other graphics programmes, especially those Windows "modern" "powerful" ones, like M$Pain (hehe), Photoshop or Paintshop Pro, etc., are definitely ''NOT'' good choices. So take my advice - '''DON'T USE THEM''', or else you will end up in miserable troubles like ''some'' time traveller did.
You can now make some graphics with your favourite graphics package, but bear in mind that if you really want to do nifty effects with the 8-bit palette, it's always preferrable to create the graphics ''natively'' under this colour depth, to save you from the mess of conversions. Two good choices of such programmes are Deluxe Paint ][ Enhanced and [http://code.google.com/p/grafx2/ Grafx 2], as they're 8-bit pixel graphics editors and they won't ''do foolish things automatically (like "friendly" sorting and trimming your palette, merging slots with similar colours, dithering you images, etc.)''. This is '''VERY''' important, as we want the imported graphics to be '''COMPLETELY IDENTICAL''' to the original, including the order of the colours assigned to the slot indices, for the desired effects to work. Most of the other graphics programmes, especially those Windows "modern" "powerful" ones, like M$Pain (hehe), Photoshop or Paintshop Pro, etc., are definitely ''NOT'' good choices. So take my advice - '''DON'T USE THEM''', or else you will end up in miserable troubles like ''some'' time traveller did.


I usually start by drawing some sprites first, because after you have set up some of the "'''Gamewide'''" colours for the sprites, you can also use them in backgrounds if appropriate. After starting the graphics package of your choice, the first thing you need to do is to make the editing palette of your image to match the one you have exported from the AGS editor, in some of the graphics packages you can just start a new image and ''import the palette from the exported '''.BMP''' file'' but for programmes without this feature (like DP2E or Grafx 2) you can use the following trick:
I usually start by drawing some sprites first, because after you have set up some of the "'''Gamewide'''" colours for the sprites, you can also use them in backgrounds if appropriate. After starting the graphics package of your choice, the first thing you need to do is to make the editing palette of your image to match the one you have exported from the AGS editor. In some of the graphics packages you can just start a new image and ''import the palette from the exported '''.BMP''' file'' but for programmes without this feature (like DP2E or Grafx 2) you can use the following trick:
# Simply ''load'' the exported '''.BMP''' file into the programme. In case of programmes (like DP) not supporting this graphics format, convert the image to some other format they can load (say, PCX) first.
# Simply ''load'' the exported '''.BMP''' file into the programme. In case of programmes (like DP) not supporting this graphics format, convert the image to some other format they can load (say, PCX) first.
# Well, the size of the exported image was just '10 pixels by 10 pixels', which is obviously not what you want. You can just ''change the image size'' yourself (e.g. '320 pixels by 240 pixels', depending on your own needs. If you're drawing sprites just set it to a size which you think is large enough to hold some amount of sprites you're making in one session; if you're drawing a background just set it to the game's screen size for a non-scrollable room, or some other larger appropriate size if it's for a scrollable room). '''Note:''' To change the image size, if you're using DP2E, just choose "'''PICT(URE) --> Page Size...'''" and then enter the new size in the boxes below "'''Custom size'''", then click "'''OK'''"; if you're using Grafx 2, just click the "'''Screen size / Safe. res.'''" icon, then click the "'''Width'''" and "'''Height'''" boxes to change them (you have to hit '''ENTER''' after entering a value), then click "'''OK'''".
# Well, the size of the exported image was just '10 pixels by 10 pixels', which is obviously not what you want. You can just ''change the image size'' yourself (e.g. '320 pixels by 240 pixels', depending on your own needs. If you're drawing sprites just set it to a size which you think is large enough to hold some amount of sprites you're making in one session; if you're drawing a background just set it to the game's screen size for a non-scrollable room, or some other larger appropriate size if it's for a scrollable room). '''Note:''' To change the image size, if you're using DP2E, just choose "'''PICT(URE) --> Page Size...'''" and then enter the new size in the boxes below "'''Custom size'''", then click "'''OK'''"; if you're using Grafx 2, just click the "'''Screen size / Safe. res.'''" icon, then click the "'''Width'''" and "'''Height'''" boxes to change them (you have to hit '''ENTER''' after entering a value), then click "'''OK'''".
Line 34: Line 34:


Before you start drawing, you may do two more things to aid you through the rest of your creations:
Before you start drawing, you may do two more things to aid you through the rest of your creations:
# If you don't like the default colours set by AGS you may discard them first (if you don't have problems with their existence, and like to use them in their default forms anyway or, if you want to keep CJ's original classic roger and GUI sprites, just skip this step). Note that the first 17 colours (slots #0 through #16) are supposed to be used by the engine to display system messages, etc., so it is not advisible to change them (these colours were marked as "locked" in previous versions of AGS). This leaves slots #17 through #41, that you can change if required. The easiest way to do this is to turn them all into black first. '''Tip:''' If you are using DP2E, launch the '''palette dialog''' by clicking on the active colour on the bottom right part of the screen, first click '''colour #16''' (the first colour on the second column, which is already black), click the "'''Spread'''" button, then click '''colour #47''' (the last colour on the third row, which is also black by default). If you are using Grafx 2, launch the palette dialog by clicking the "'''palette editor'''" button, click '''colour #16''', ''hold'' the mouse button and ''drag'' until the colours in the second and the third columns are all selected, then click the "'''Spread'''" button. '''Note: Be careful that you didn't alter the colours of the "locked" colours.'''
# If you don't like the default colours set by AGS you may discard them first (if you don't have problems with their existence, and like to use them in their default forms anyway or, if you want to keep CJ's original classic [Roger] and GUI sprites, just skip this step). Note that the first 17 colours (slots #0 through #16) are supposed to be used by the engine to display system messages, etc., so it is not advisible to change them (these colours were marked as "locked" in previous versions of AGS). This leaves slots #17 through #41, that you can change if required. The easiest way to do this is to turn them all into black first. '''Tip:''' If you are using DP2E, launch the '''palette dialog''' by clicking on the active colour on the bottom right part of the screen, first click '''colour #16''' (the first colour on the second column, which is already black), click the "'''Spread'''" button, then click '''colour #47''' (the last colour on the third row, which is also black by default). If you are using Grafx 2, launch the palette dialog by clicking the "'''palette editor'''" button, click '''colour #16''', ''hold'' the mouse button and ''drag'' until the colours in the second and the third columns are all selected, then click the "'''Spread'''" button. '''Note: Be careful that you didn't alter the colours of the "locked" colours.'''
# You may have noticed that colour #0 is black by default, but now I am telling you, that you ''should'' change the colour of this entry to something else (even if it belongs to a "'''locked'''" colour, I will explain later). I usually change it to <font color="FF00FF">pink</font> (by dragging both of the <font color="FF0000">R</font> and <font color="0000FF">B</font> sliders to full intensity) which is the default transparent colour used in many programmes, if you want to use this <font color="FF00FF">pink</font> colour (or some other colours close enough to it) in you game's graphics, you may change the colour of this slot to some other colour that will clash less with your in-game graphics. After the changes the palette should look like this:
# You may have noticed that colour #0 is black by default, but now I am telling you, that you ''should'' change the colour of this entry to something else (even if it belongs to a "'''locked'''" colour, I will explain later). I usually change it to <font color="FF00FF">pink</font> (by dragging both of the <font color="FF0000">R</font> and <font color="0000FF">B</font> sliders to full intensity) which is the default transparent colour used in many programmes, if you want to use this <font color="FF00FF">pink</font> colour (or some other colours close enough to it) in you game's graphics, you may change the colour of this slot to some other colour that will clash less with your in-game graphics. After the changes the palette should look like this:


Line 47: Line 47:
[[Image:8bittut_ss0pal.png|center|Girl sprite palette]]
[[Image:8bittut_ss0pal.png|center|Girl sprite palette]]


You'll see that before drawing this first sprite, ''I thought'' that shades of skin colour, red and blue might be quite frequently used in my sprites, so I first set up slots #17 to #31 to contain these colours (the second row). Even though some of the slots were still not used for painting my first sprite, they may still be used later in some other sprites in the future, so don't be afraid that they'd be wasted at the time being. When I was drawing the sprite I added more colours to the palette when needed (see the third row of colours). Note that when I needed the black colour I used slot #16 (like in her antenna and eyes), whereas when I needed the transparent colour I used slot #0, as shown by the surrounding pink colour, that's the reason I changed slot #0 to some other colour - it won't clash with the black colour in case I need to use it in my sprites. Note also that I drew a white rectangle surrounding the sprite, it will certainly help when it is to be imported into an AGS game.
You'll see that before drawing this first sprite, ''I thought'' that shades of skin colour, red and blue might be quite frequently used in my sprites, so I first set up slots #17 to #31 to contain these colours (the second row). Even though some of the slots were still not used for painting my first sprite, they may still be used later in some other sprites in the future, so don't be afraid that they'd be wasted at the time being. When I was drawing the sprite I added more colours to the palette when needed (see the third row of colours). Note that when I needed the black colour I used slot #16 (like in her antennae and eyes), whereas when I needed the transparent colour I used slot #0, as shown by the surrounding pink colour. That's the reason I changed slot #0 to some other colour - it won't clash with the black colour in case I need to use it in my sprites. Note also that I drew a white rectangle surrounding the sprite. It will certainly help when it is to be imported into an AGS game.
 
Next, I may continue to draw more sprites, but as I am so excited I really want to see it imported into my game. Go to "'''Colours'''" of the AGS editor, change the range of colours to import as ''Gamewide''. In my case it's slot #17 through #37, so I first click slot #17, ''HOLD'' the '''SHIFT''' key and click slot #37, so that the desired range is selected, and then select "'''Replace selected slots from file...'''" after right-clicking on the selected colours. We just need to choose the image file containing the sprite (if it already is in '''.BMP''' format; if not, convert it to '''.BMP''' format first), and the colours of the selected slots will change to match your image file. Now, slots #38 through #41 still contain the original colours set by the editor and I don't like them, I just select these 4 slots (click slot #38, hold '''SHIFT''' and click slot #41) and change them to ''Background'', to make them get out of my sight ''temporally''. The current palette should look like this:
Next, I may continue to draw more sprites, but as I am so excited I really want to see it imported into my game. Go to "'''Colours'''" of the AGS editor, change the range of colours to import as ''Gamewide''. In my case it's slot #17 through #37, so I first click slot #17, ''HOLD'' the '''SHIFT''' key and click slot #37, so that the desired range is selected, and then select "'''Replace selected slots from file...'''" after right-clicking on the selected colours. We just need to choose the image file containing the sprite (if it already is in '''.BMP''' format; if not, convert it to '''.BMP''' format first), and the colours of the selected slots will change to match your image file. Now, slots #38 through #41 still contain the original colours set by the editor and I don't like them, I just select these 4 slots (click slot #38, hold '''SHIFT''' and click slot #41) and change them to ''Background'', to make them get out of my sight ''temporally''. The current palette should look like this:


[[Image:8bittut_ss0pala_v3.png|center|AGS palette after importing the Girl sprite]]
[[Image:8bittut_ss0pala_v3.png|center|AGS palette after importing the Girl sprite]]


Now, go to "'''Sprites'''" of the AGS editor, right click and select "'''Import new sprite from file...'''" and select that image file containing the sprite, making sure that 1) the "'''Remap colours to game palette'''" checkbox is ''un''checked'', and 2) the "'''Transparent colour'''" is set to "'''Palette index 0'''" (you can set the other settings yourself depending on your need), as below:
Now, go to "'''Sprites'''" of the AGS editor, right click and select "'''Import new sprite from file...'''" and select that image file containing the sprite, making sure that 1) the "'''Remap colours to game palette'''" checkbox is ''un''checked, and 2) the "'''Transparent colour'''" is set to "'''Palette index 0'''" (you can set the other settings yourself depending on your need), as below:


[[Image:8bittut_imspr00_v3.png|center|Exact palette import sprite settings]]
[[Image:8bittut_imspr00_v3.png|center|Exact palette import sprite settings]]


Now, right drag the rectangle to match the size, blah bla... and your imported sprite will now be stored '''EXACTLY''' like the originally drawn one. (During import you may see that the pink colour becomes black, but don't panic, as you'll later find out that it should be imported perfectly with that "pink" colour region transparent when you put it over a background. You may also find out that drawing a rectangle around the sprite helps, otherwise I might have cropped out the antenna accidentally.)
Now, right drag the rectangle to match the size, blah bla... and your imported sprite will now be stored '''EXACTLY''' like the originally drawn one. (During import you may see that the pink colour becomes black, but don't panic, as you'll later find out that it should be imported perfectly with that "pink" colour region transparent when you put it over a background. You may also find out that drawing a rectangle around the sprite helps, otherwise I might have cropped out the antennae accidentally.)


'''Note: As of AGS V3.12, the editor cannot remember some of these settings (in particular the "Remap colours to game palette" option) well, so if you import another sprite later, you should double-check to make sure that the settings are correct before importing. This is unfortunately a step backward as this issue was supposed to be fixed since V2.61 in the old editor. Also, the sprites may not be shown in their correct colours in the sprite lists (sometimes, you need to restart the editor to have them shown correctly), so you need to check them later in game to make sure that they're imported correctly.'''
'''Note: As of AGS V3.1.2, the editor cannot remember some of these settings (in particular the "Remap colours to game palette" option) well, so if you import another sprite later, you should double-check to make sure that the settings are correct before importing. This is unfortunately a step backward as this issue was supposed to be fixed since V2.61 in the old editor. Also, the sprites may not be shown in their correct colours in the sprite lists (sometimes, you need to restart the editor to have them shown correctly), so you need to check them later in game to make sure that they're imported correctly.'''


Now I draw another sprite on the [[media:8bittut_ss1.bmp|same image file]], adding the following sprite:
Now I draw another sprite on the [[media:8bittut_ss1.bmp|same image file]], adding the following sprite:
Line 68: Line 69:
[[Image:8bittut_ss1pal.png|center|Alien sprite palette]]
[[Image:8bittut_ss1pal.png|center|Alien sprite palette]]


You'll see that in this second sprite some of the Gamewide colours set before were used (this time I even used some of the colours not used in the last sprite, e.g. slot #17, the darkest skin tone), and more colours were added (slots #38 through #40).
You'll see that in this second sprite some of the Gamewide colours set before were used (this time I even used some of the colours that are not used in the last sprite, e.g. slot #17, the darkest skin tone), and more colours were added (slots #38 through #40).
So, to import this sprite, I first select slot #38 to slot #40 in the '''Palette editor''' (like before), change them to "'''Gamewide'''" (if necessary), and then import these three new colours from the sprite sheet into the editor:
So, to import this sprite, I first select slot #38 to slot #40 in the '''Palette editor''' (like before), change them to "'''Gamewide'''" (if necessary), and then import these three new colours from the sprite sheet into the editor: