/* Fire Routine for Net Yaroze (c) F Javier Ventoso Reigosa X'97 javier0003@mundivia.es or javier_ventoso@iname.com You can use it in your games if you want! Push PADup and down to change FirePower */ #include #include "pad.h" #define SCREEN_WIDTH 512 #define SCREEN_HEIGHT 256 static u_long PadRead(long); static long CheckPad (); static void Draw_Fire( void ); #define OT_LENGTH 1 GsOT WorldOT[2]; GsOT_TAG OTTags[2][1<= 10 ) FirePower = 10; } return( 0 ); } static void Draw_Fire( void ) { static unsigned char current[34][128]; static unsigned char working[34][128]; short pix1, pix2, pix3, pix4, pix5, color; short fil, col; // generar l¡neas aleatorias de brasas for( col = 0; col < 128; col++ ) { working[32][col] = rand() % 256; working[33][col] = working[32][col]; } // hallar valores medios for( fil = 33; fil >= 2; fil-- ) for( col = 1; col <= 127; col++ ) { pix1 = current[fil-1][col]; // arriba pix2 = current[fil][col+1]; // derecha pix3 = current[fil][col-1]; // izquierda pix4 = current[fil+1][col+1]; // arriba/derecha pix5 = current[fil+1][col-1]; // arriba/izquierda color = (pix1+pix2+pix3+pix4+pix5)/5; if( color > FirePower ) color -= FirePower; working[fil-1][col] = ( unsigned char ) color; } // copiar working a current for( fil = 0; fil < 34; fil++ ) for( col = 0; col < 128; col++ ) current[fil][col] = working[fil][col]; // generar paquetes de v¡deo for( fil = 0; fil < 32; fil++ ) for( col = 0; col < 128; col++ ) { FireBox.x = col*4 + Xleft; FireBox.y = fil*8 + Yup; FireBox.r = FireBox.g = FireBox.b = 0; if( current[fil][col] < 20 ) FireBox.r = current[fil][col] / 2; else { FireBox.b = current[fil][col]; FireBox.g = current[fil][col] / 3; } GsSortBoxFill( &FireBox, &WorldOT[activeBuff], 1 ); } }