back to the text
/*----------------------------------------------------
*
* SPIN.c - app variables and draw functions
*
*--------------------------------------------------*/
#include "INCLUDES.h"
static float alphaname[4] = {1.0, 1.0, 1.0, 1.0};
static int spinA=41;
static int eye = 0;
static int spinROT1 = 0;
static int spinROT2 = 0;
static int spinROT3 = 0;
static int spinGROW1 = 3;
static int spinGROW2 = 5;
static int spinGROW3 = 7;
static float spinB=1;
static float spinCNT=1;
/*--------------------------------------------------*/
void spin_cubes(int, int, int, int, int, int);
/*--------------------------------------------------*/
/*--------------------------------------------------*/
/*--------------------------------------------------*/
/*--------------------------------------------------*/
/*----------------------------------------------------
*
* DRAW functions
*
*--------------------------------------------------*/
void draw_SPIN()
{
cpack(0xff000030); clear(); zclear();
translate(0.0, 0.75, 0.0);
/*----------------------------*/
texbind(TX_TEXTURE_0, img_list[spinA]);
blendfunction(BF_SA, BF_MSA);
spin_cubes(spinROT1, spinROT2, spinROT3,
spinGROW1, spinGROW2, spinGROW3);
blendfunction(BF_ONE, BF_ZERO);
texbind(TX_TEXTURE_0, 0);
/*----------------------------*/
if(eye)
{
spinB = spinB + .999;
if (spinB < 1 && spinB > 0) spinA = 41;
else if (spinB < 2 && spinB > 1) spinA = 42;
else if (spinB < 3 && spinB > 2) spinA = 43;
else if (spinB < 4 && spinB > 3) spinA = 44;
else if (spinB < 5 && spinB > 4) spinA = 45;
else if (spinB < 6 && spinB > 5) spinA = 46;
else if (spinB < 7 && spinB > 6) spinA = 47;
else if (spinB < 8 && spinB > 7) spinA = 48;
else if (spinB < 9 && spinB > 8) spinA = 49;
else if (spinB < 10 && spinB > 9) spinA = 50;
else if (spinB < 11 && spinB > 10) spinA = 51;
else if (spinB < 12 && spinB > 11) spinA = 52;
else if (spinB < 13 && spinB > 12) spinA = 53;
else if (spinB < 14 && spinB > 13) spinA = 54;
else if (spinB < 15 && spinB > 14) spinA = 55;
else if (spinB >= 15)
{
spinA = 40;
spinB = 0;
}
spinCNT = spinCNT + .999;
if (spinCNT < 1 && spinCNT > 0) alphaname[3] = 0.1;
else if (spinCNT < 2 && spinCNT > 1) alphaname[3] = 0.2;
else if (spinCNT < 3 && spinCNT > 2) alphaname[3] = 0.3;
else if (spinCNT < 4 && spinCNT > 3) alphaname[3] = 0.4;
else if (spinCNT < 5 && spinCNT > 4) alphaname[3] = 0.5;
else if (spinCNT < 6 && spinCNT > 5) alphaname[3] = 0.6;
else if (spinCNT < 7 && spinCNT > 6) alphaname[3] = 0.7;
else if (spinCNT < 8 && spinCNT > 7) alphaname[3] = 0.8;
else if (spinCNT < 9 && spinCNT > 8) alphaname[3] = 0.9;
else if (spinCNT < 10 && spinCNT > 9) alphaname[3] = 0.8;
else if (spinCNT < 11 && spinCNT > 10) alphaname[3] = 0.7;
else if (spinCNT < 12 && spinCNT > 11) alphaname[3] = 0.6;
else if (spinCNT < 13 && spinCNT > 12) alphaname[3] = 0.5;
else if (spinCNT < 14 && spinCNT > 13) alphaname[3] = 0.4;
else if (spinCNT < 15 && spinCNT > 14) alphaname[3] = 0.3;
else if (spinCNT < 16 && spinCNT > 15) alphaname[3] = 0.2;
else if (spinCNT >= 16)
{
alphaname[3] = 0.1;
spinCNT = 0;
}
}
eye=!eye;
spinROT1 = spinROT1 + 4;
if (spinROT1 >3500) spinROT1 = 0;
spinROT2 = spinROT2 + 14;
if (spinROT2 >3500) spinROT2 = 0;
spinROT3 = spinROT3 + 7;
if (spinROT3 >3500) spinROT3 = 0;
spinGROW1 = spinGROW1 + .1;
if (spinGROW1 == 10) spinGROW1 = 3;
spinGROW2 = spinGROW2 + .1;
if (spinGROW2 == 10) spinGROW2 = 3;
spinGROW3 = spinGROW3 + .1;
if (spinGROW3 == 10) spinGROW3 = 3;
}
/*--------------------------------------------------*/
void spin_cubes(int spinROT1, int spinROT2, int spinROT3,
int spinGROW1, int spinGROW2, int spinGROW3)
{
c4f(alphaname);
pushmatrix();
translate(0.0, 1.0, -5.0);
pushmatrix();
translate(0.0, 1.0, 0.0);
rotate(spinROT1, 'x');
scale(spinGROW1, spinGROW1, spinGROW1);
callobj(GLobjCubeIndex);
popmatrix();
pushmatrix();
c4f(alphaname);
translate(1.0, 0.0, 0.0);
rotate(spinROT2, 'y');
scale(spinGROW2, spinGROW2, spinGROW2);
callobj(GLobjCubeIndex);
popmatrix();
pushmatrix();
c4f(alphaname);
translate(0.0, 0.0, 1.0);
rotate(spinROT3, 'z');
scale(spinGROW3, spinGROW3, spinGROW3);
callobj(GLobjCubeIndex);
popmatrix();
popmatrix();
}
/*--------------------------------------------------*/