Palette

Started by Babar, Tue 07/06/2005 11:26:35

Previous topic - Next topic

Gilbert

#20
Well my bad, in my game I declared some of the variables globally outside of the function. So, after I copied the code here I had to add back some of the declarations.
However, I made some typos, so there're some errors with the declarations ("color cycinc, cycind;" should be "int cycinc, cycind;", and "int cycind;" should be "color cyctmp;").
Should be fixed now, try recopying the codes.

Edit:Argh, seems that CJ forgot to add the color struct into V2.7+, I'll bug him to fix this bug.
Currently you can use this code instead (or create the struct your self):
Code: ags

function CycPal(int start, int end) {
Ã,  int cycinc, cycind;
Ã,  char tmpr, tmpg, tmpb;
Ã,  tmpr=palette[start].r;
Ã,  tmpg=palette[start].g;
Ã,  tmpb=palette[start].b;
Ã,  if (end>start) cycinc=1;
Ã,  else cycinc=-1;
Ã,  cycind=start;
Ã,  while (cycind!=end) {
Ã,  Ã,  palette[cycind].r=palette[cycind+cycinc].r;
Ã,  Ã,  palette[cycind].g=palette[cycind+cycinc].g;
Ã,  Ã,  palette[cycind].b=palette[cycind+cycinc].b;
Ã,  Ã,  cycind+=cycinc;
Ã,  Ã,  }
Ã,  palette[end].r=tmpr;
Ã,  palette[end].g=tmpg;
Ã,  palette[end].b=tmpb;
Ã,  UpdatePalette();
Ã,  }


(Well the above function works, but I'd just checked, CyclePalette() in opposite direction won't work, even in V2.7 or V2.62, I'll definitely report this bug.)

Babar

Thanks again Gilbot. Worked perfectly. It's a good thing that all the problems I am having now were already solved by you ;D
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

SMF spam blocked by CleanTalk