SBSPSS/source/gfx/fader.cpp
2000-11-20 15:31:03 +00:00

241 lines
5.1 KiB
C++

/*=========================================================================
fader.cpp
Author: PKG
Created:
Project: Spongebob
Purpose:
Copyright (c) 2000 Climax Development Ltd
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
#include "fader.h"
#ifndef __PRIM_HEADER__
#include "gfx\prim.h"
#endif
#ifndef __GFX_BUBICLES_H__
#include "gfx\bubicles.h"
#endif
/* Std Lib
------- */
/* Data
---- */
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
/*----------------------------------------------------------------------
Vars
---- */
int CFader::s_fadeLine=0;
CFader::FADE_MODE CFader::s_fadeMode=FADED_IN;
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
BubicleEmitterData s_fadeBubicleSpawner=
{
0,0,512,40, // m_x,m_y,m_w,m_h
0,0, // m_birthRate,m_birthAmount
0, // m_life
// m_bubicleBase
{
10, // m_life
0,0,0, // m_vx,m_vdx,m_vxmax
-200,0,0, // m_vy,m_vdy,m_vymax
10,7, // m_w,m_h
0, // m_dvSizeChange
0,0, // m_theta,m_vtheta
0,0,0, // m_wobbleWidth,m_vwobbleWidth,m_vdwobbleWidth
0, // m_ot
{220,220,220} // m_colour
},
// m_bubicleRange;
{
10, // m_life
0,0,0, // m_vx,m_vdx,m_vxmax
50,0,0, // m_vy,m_vdy,m_vymax
3,3, // m_w,m_h
0, // m_dvSizeChange
0,100, // m_theta,m_vtheta
10,0,0, // m_wobbleWidth,m_vwobbleWidth,m_vdwobbleWidth
0, // m_ot
{30,30,30} // m_colour
}
};
void CFader::render()
{
switch(s_fadeMode)
{
case FADED_IN:
return;
case FADING_IN:
{
if(s_fadeLine>0)
{
POLY_F4 *f4;
POLY_G4 *g4;
POLY_FT3 *ft3;
f4=GetPrimF4();
setXYWH(f4,0,-FADE_BORDER_SIZE,512,s_fadeLine-(FADE_SMOOTH_BORDER_SIZE/2)+FADE_BORDER_SIZE);
setRGB0(f4,255,255,255);
AddPrimToList(f4,0);
g4=GetPrimG4();
setXYWH(g4,0,s_fadeLine-(FADE_SMOOTH_BORDER_SIZE/2),512,FADE_SMOOTH_BORDER_SIZE);
setRGB0(g4,255,255,255);
setRGB1(g4,255,255,255);
setRGB2(g4,0,0,0);
setRGB3(g4,0,0,0);
setShadeTex(g4,0);
setSemiTrans(g4,1);
AddPrimToList(g4,0);
ft3=GetPrimFT3();
setShadeTex(ft3,1);
setSemiTrans(ft3,1);
ft3->tpage=(1<<5);
setXY3(ft3,512,512,512,512,512,512);
AddPrimToList(ft3,0);
}
}
break;
case FADING_OUT:
{
POLY_F4 *f4;
POLY_G4 *g4;
POLY_FT3 *ft3;
f4=GetPrimF4();
setXYWH(f4,0,s_fadeLine+(FADE_SMOOTH_BORDER_SIZE/2),512,256-s_fadeLine-(FADE_SMOOTH_BORDER_SIZE/2));
setRGB0(f4,255,255,255);
AddPrimToList(f4,0);
g4=GetPrimG4();
setXYWH(g4,0,s_fadeLine-(FADE_SMOOTH_BORDER_SIZE/2),512,FADE_SMOOTH_BORDER_SIZE);
setRGB0(g4,0,0,0);
setRGB1(g4,0,0,0);
setRGB2(g4,255,255,255);
setRGB3(g4,255,255,255);
setShadeTex(g4,0);
setSemiTrans(g4,1);
AddPrimToList(g4,0);
ft3=GetPrimFT3();
setShadeTex(ft3,1);
setSemiTrans(ft3,1);
ft3->tpage=(1<<5);
setXY3(ft3,512,512,512,512,512,512);
AddPrimToList(ft3,0);
}
break;
case FADED_OUT:
{
POLY_F4 *f4;
f4=GetPrimF4();
setXYWH(f4,0,0,512,256);
setRGB0(f4,255,255,255);
AddPrimToList(f4,1);
return;
}
}
s_fadeBubicleSpawner.m_y=s_fadeLine-20;
for(int i=0;i<BUBBLES_PER_FRAME;i++)
CBubicleFactory::spawnParticle(&s_fadeBubicleSpawner);
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CFader::think(int _frames)
{
if(s_fadeMode!=FADED_IN&&s_fadeMode!=FADED_OUT)
{
s_fadeLine-=_frames*FADE_SPEED;
if(s_fadeLine<-FADE_BORDER_SIZE)
{
s_fadeMode=s_fadeMode==FADING_OUT?FADED_OUT:FADED_IN;
}
}
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CFader::setFadingOut()
{
s_fadeLine=256+FADE_BORDER_SIZE;
s_fadeMode=FADING_OUT;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CFader::setFadingIn()
{
s_fadeLine=256+FADE_BORDER_SIZE;
s_fadeMode=FADING_IN;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
int CFader::isFading()
{
return s_fadeMode==FADING_IN||s_fadeMode==FADING_OUT;
}
/*===========================================================================
end */