Heres a very simple code i was using in AXRIA, but decided to share with thou.
All it requires is a Draw actor function using vairables of r, g, b. Plus a special actor vairable that in this case i've called "fade".
Camper1995 wrote:Neat. Now make this as a function and it'll be great.
CoFFiN6 wrote:Wow this would look awsum on main menu backgrounds.
int coldir=0;
void changeColor(int rate) {
switch(coldir) {
case 0:
g+=rate;
if (g>=255) {
coldir++;
}
break;
case 1:
r-=rate;
if (r<=0) {
coldir++;
}
break;
case 2:
b+=rate;
if (b>=255) {
coldir++;
}
break;
case 3:
g-=rate;
if (g<=0) {
coldir++;
}
break;
case 4:
r+=rate;
if (r>=255) {
coldir++;
}
break;
case 5:
b-=rate;
if (b<=0) {
coldir=0;
}
break;
}
}
float colSpeed=4;
int colDir=0;
int colSwitch=0;
int colValues[][]={{1, 0, 0},{0, 0, -1},{0, 1, 0},{-1, 0, 0},{0, 0, 1},{0, -1, 0}};
void rotateColor(){
colSwitch+=colSpeed;
if(colSwitch>=255){
colSwitch=0;
colDir++;
colDir=iLoop(colDir, 0, 5);
}
r+=colValues[colDir][0]*colSpeed;
g+=colValues[colDir][1]*colSpeed;
b+=colValues[colDir][2]*colSpeed;
}
int iConstrain(int xx, int ll, int ul){
if(xx<ll){xx=ll;}
if(xx>ul){xx=ul;}
return xx;
}
float fConstrain(float xx, float ll, float ul){
if(xx<ll){xx=ll;}
if(xx>ul){xx=ul;}
return xx;
}
int iLoop(int xx, int ll, int ul){
if(xx<ll){xx=ul;}
else if(xx>ul){xx=ll;
}
return xx;
}
float fLoop(float xx, float ll, float ul){
if(xx<ll){xx=ul;}
else if(xx>ul){xx=ll;
}
return xx;
}
Users browsing this forum: No registered users and 1 guest