// Filename : INTRO.C // Coded by : Scott Evans // Created/Modified : 27/2/98 // Description : Bouncer 2 (v2) intro #include "intro.h" static void HandleIntroExplosionFragment(OBJECT *); // Width and height of intro sprites #define WIDTH 24 #define HEIGHT 24 // Variables declared in BOUNCER.C extern DBUFFER *db[2]; extern PROGRAM_DATA pd; extern SPRITE_DATA_INFO font_sprite_info; extern u_long bouncy_factor[]; extern BRIGHTNESS brightness[]; extern SOUND_DATA *sounds; // Variables local to this module OBJECT_LIST_HEADER intro_objects; OBJECT *number2; VOLUME intro_volume={SS_MAX_VOLUME,SS_MAX_VOLUME}; // Function : InitIntroObjects() // Coded by : Scott Evans // Created/Modified : 26/2/98 // Description : Initialise all intro objects // Parameters : None // Returns : None // Notes : None void InitIntroObjects(void) { OBJECT *new; SPRITE *spr; u_byte *s={"BOUNCER"}; u_byte n,i=0; u_word x,y[]={-60,-70,-80,-90,-80,-70,-60}; u_long timers[]={300,330,360,390,360,330,300}; // Initialise the intro objects list InitObjectList(&intro_objects); // Seed random number generator srand(VSync(-1)); // Create a '2' sprite if((number2=new=CreateObject(&intro_objects,SPRITE_OBJECT))) { n=MapCharacterToImage("2"); spr=&new->type.s; spr->info=&font_sprite_info.offsets[0]; spr->animation_on=0; SetGsSPRITE(&spr->s,TRANSPARENCY_ON|BG_PLUS_SP,new->screen.vx,new->screen.vy, 8,8,font_sprite_info.tpage,spr->info[n].u,spr->info[n].v, font_sprite_info.cx,font_sprite_info.cy+spr->info[n].clut_y, 0,0,0,0,0,ONE*7,ONE*7,0); SetObjectsPosition(new,(pd.screen.w>>1)-28,(pd.screen.h>>1)-28,0); SetObjectsBrightness(new,&brightness[INTRO_MIN_BRIGHTNESS]); new->active=0; new->tmp=0; } // Find centre of screen for string of sprites x=(pd.screen.w>>1)-((strlen(s)*WIDTH)>>1); // Make a sprite object for each letter while(*s) { n=MapCharacterToImage(s); if(n>0 && n!=NEW_LINE && n!=SPACE) { if((new=CreateObject(&intro_objects,SPRITE_OBJECT))) { spr=&new->type.s; spr->info=&font_sprite_info.offsets[0]; spr->animation_on=0; SetGsSPRITE(&spr->s,0,new->screen.vx,new->screen.vy, 8,8,font_sprite_info.tpage,spr->info[n].u,spr->info[n].v, font_sprite_info.cx,font_sprite_info.cy+spr->info[n].clut_y, 0,0,0,0,0,ONE*3,ONE*3,0); SetObjectsDefaultProperties(new); SetObjectsPosition(new,x,y[i],0); //SetObjectsBrightness(new,&brightness[INTRO_TEXT_BRIGHTNESS]); SetObjectsBrightness(new,&brightness[GAME_RED_BRIGHTNESS]); SetObjectsVelocity(new,0,0,0); SetObjectsAcceleration(new,0,0.15,0); new->f=HandleIntroObjects; new->timer=timers[i]; new->tmp=1; x+=WIDTH; i++; } } if(n==SPACE) x+=WIDTH; s++; } #ifdef DEBUG_INFO PrintFM("Completed\n"); #endif } // Function : KillIntroObjects() // Coded by : Scott Evans // Created/Modified : 26/2/98 // Description : Destory all intro objects // Parameters : l - pointer to object list // Returns : None // Notes : None void KillIntroObjects(OBJECT_LIST_HEADER *l) { if(l->no_objects) ClearObjectList(l); } // Function : ShowIntro() // Coded by : Scott Evans // Created/Modified : 26/2/98 // Description : Show the intro sequence // Parameters : None // Returns : None // Notes : None void ShowIntro(void) { pd.running=1; while(pd.running) { if(!intro_objects.no_objects) pd.running=0; db[1]=SwapBuffer(db[1],db[0]); GsSetWorkBase(db[1]->pb); GsClearOt(0,0,db[1]->ot); UpdateSoundEffects(); UpdateObjects(&intro_objects); SortObjects(&intro_objects,db[1]->ot,0); DrawSync(0); pd.vsync=VSync(0); SwapDisplay(db[1],1); GsDrawOt(db[1]->ot); } #ifdef DEBUG_INFO PrintFM("Completed\n"); #endif } // Function : HandleIntroObjects() // Coded by : Scott Evans // Created/Modified : 26/2/98 // Description : Handle the intro objects // Parameters : o - pointer to object to handle // Returns : None // Notes : None void HandleIntroObjects(OBJECT *o) { if(o->tmp && o->screen.vy>-32) { FadeObjectBrightness(o,&brightness[0],30<screen.vy>(pd.screen.h>>1)-(HEIGHT>>1)) { o->screen.vy=(pd.screen.h>>1)-(HEIGHT>>1); o->position.vy=o->screen.vy<velocity.vy=-((o->velocity.vy*bouncy_factor[0])>>FP24_8); PlaySoundEffect(sounds,&intro_volume,SFX_HIT_BLOCK); } if(o->timer>0) { o->timer--; if(o->timer==110 && !number2->active) { if(number2) { SetObjectsDefaultProperties(number2); number2->f=HandleNumber2; number2->timer=SECOND*10; PlaySoundEffect(sounds,&intro_volume,SFX_INTRO_FADE); } } if(o->timer<80) { o->acceleration.vy+=(0.02*FPN24_8); o->velocity.vy-=0.05*FPN24_8; } } else { PARTICLE_EXPLOSION explosion; SetParticleExplosion(&explosion,&intro_objects,HandleIntroExplosionFragment,25,280,4,4,0,0); setVECTOR(&explosion.maxvel,4,6,0); setVECTOR(&explosion.acc,0,0.2*FPN24_8,0); explosion.b.r=o->brightness.r; explosion.b.g=o->brightness.g; explosion.b.b=o->brightness.b; setRECT(&explosion.r,o->screen.vx,o->screen.vy,WIDTH,HEIGHT); CreateParticleExplosion(&explosion); RemoveObjectFromList(&intro_objects,o); PlaySoundEffect(sounds,&intro_volume,SFX_SPLIT_BLOKE); //CreateIntroExplosionSprite(o->screen.vx,o->screen.vy); //CreateIntroExplosionSprite(o->screen.vx+16,o->screen.vy); //CreateIntroExplosionSprite(o->screen.vx-16,o->screen.vy); //CreateIntroExplosionSprite(o->screen.vx,o->screen.vy+16); //CreateIntroExplosionSprite(o->screen.vx,o->screen.vy-16); } } // Function : HandleNumber2() // Coded by : Scott Evans // Created/Modified : 26/2/98 // Description : Handle the number 2 object // Parameters : o - pointer to object to handle // Returns : None // Notes : None void HandleNumber2(OBJECT *o) { // Is the object still active if(o->timer>0) { o->timer--; if(o->timer>280) FadeObjectBrightness(o,&brightness[INTRO_MAX_BRIGHTNESS],75<type.p.timer>0) o->type.p.timer--; // Kill fragment if(!o->type.p.timer || !is_fading || o->screen.vx<0 || o->screen.vx>pd.screen.w || o->screen.vy<0 || o->screen.vy>pd.screen.h) RemoveObjectFromList(&intro_objects,o); // Check for fragment hitting sides of screen #ifdef 0 if(o->screen.vx<0) { o->position.vx=o->screen.vx=0; o->velocity.vx=-((o->velocity.vx*bouncy_factor[1])>>FP24_8); } if(o->screen.vx>pd.screen.w) { o->position.vx=(pd.screen.w<screen.vx=pd.screen.w; o->velocity.vx=-((o->velocity.vx*bouncy_factor[1])>>FP24_8); } if(o->screen.vy<0) { o->position.vy=0; o->screen.vy=0; o->velocity.vy=-((o->velocity.vy*bouncy_factor[1])>>FP24_8); } if(o->screen.vy>pd.screen.h) { o->position.vy=pd.screen.h<screen.vy=pd.screen.h; o->velocity.vy=-((o->velocity.vy*bouncy_factor[1])>>FP24_8); } #endif } // Function : Intro() // Coded by : Scott Evans // Created/Modified : 27/2/98 // Description : The Bouncer 2 intro // Parameters : None // Returns : None // Notes : None void Intro(void) { InitIntroObjects(); ShowIntro(); KillIntroObjects(&intro_objects); KillSounds(); #ifdef DEBUG_INFO PrintFM("Completed\n"); #endif }