256 Colour Tutorial Part 2(V2.62): Difference between revisions

m
Line 67: Line 67:
==Changing an individual colour==
==Changing an individual colour==
Sometimes you may want to change the colour of a particular slot for some reasons, in such case you may check out the function '''SetPalRGB()''', again, let me just copy something from the AGS manual to bloat this space a bit:
Sometimes you may want to change the colour of a particular slot for some reasons, in such case you may check out the function '''SetPalRGB()''', again, let me just copy something from the AGS manual to bloat this space a bit:
  '''SetPalRGB (int slot, int red, int green, int blue)'''
<blockquote>
  Changes the RGB components of one of the palette slots. The palette
'''SetPalRGB'''<br>
  is initially set up in the Palette Editor, but you can override it
SetPalRGB (int slot, int red, int green, int blue)<br><br>
  during the game using this function for special effects. The RED,
Changes the RGB components of one of the palette slots. The palette is initially set up in the Palette Editor, but you can override it during the game using this function for special effects. The RED, GREEN and BLUE parameters each range from 0 to 63 (as used in the Palette Editor).<br>
  GREEN and BLUE parameters each range from 0 to 63 (as used in the
If SLOT is a background slot, then this function's effect will last until the player changes screen, when the palette is changed to the new room's palette. If SLOT is not a background slot, the effect of this function is permanent.<br><br>
  Palette Editor).
'''NOTE:''' This function will allow you to change the colours which are "locked" in the Room Editor. However, you should not normally do this as it can cause strange colours in the game.
  If SLOT is a background slot, then this function's effect will last
</blockquote>
  until the player changes screen, when the palette is changed to the
  new room's palette. If SLOT is not a background slot, the effect of
  this function is permanent.
  '''NOTE:''' This function will allow you to change the colours which
  are "locked" in the Room Editor. However, you should not normally do
  this as it can cause strange colours in the game.
 
Well, I won't bother explaining the above word by word, basically what this function does, is to change the colour of a slot directly, ''all'' pixels on screen which use this slot will be changed to the new colour immediately.
Well, I won't bother explaining the above word by word, basically what this function does, is to change the colour of a slot directly, ''all'' pixels on screen which use this slot will be changed to the new colour immediately.
Let's illustrate this with an example, remember the [[media:8bittut_ss1.pcx|sprites]] we used in the part 1? Conside the girl sprite:
Let's illustrate this with an example, remember the [[media:8bittut_ss1.pcx|sprites]] we used in the part 1? Conside the girl sprite: