SBSPSS/source/gfx/fader.cpp

378 lines
7.8 KiB
C++
Raw Normal View History

2000-11-20 16:31:03 +01:00
/*=========================================================================
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
2001-01-03 21:43:49 +01:00
#ifndef __SOUND_SOUND_H__
#include "sound\sound.h"
#endif
2000-11-20 16:31:03 +01:00
/* Std Lib
------- */
/* Data
---- */
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
/*----------------------------------------------------------------------
Vars
---- */
2001-01-11 21:26:42 +01:00
int CFader::s_fadeValue=0;
2000-11-20 16:31:03 +01:00
CFader::FADE_MODE CFader::s_fadeMode=FADED_IN;
2001-01-11 21:26:42 +01:00
CFader::FADE_STYLE CFader::s_fadeStyle;
2000-11-20 16:31:03 +01:00
/*----------------------------------------------------------------------
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
2001-01-23 22:56:51 +01:00
false, // m_applyMapOffsets
2000-11-20 16:31:03 +01:00
// m_bubicleBase
{
10, // m_life
0,0,0, // m_vx,m_vdx,m_vxmax
-200,0,0, // m_vy,m_vdy,m_vymax
2001-03-01 22:07:38 +01:00
27,18, // m_w,m_h
2000-11-20 16:31:03 +01:00
0, // m_dvSizeChange
0,0, // m_theta,m_vtheta
0,0,0, // m_wobbleWidth,m_vwobbleWidth,m_vdwobbleWidth
0, // m_ot
2001-01-11 23:20:09 +01:00
{0,0,0} // m_colour
2000-11-20 16:31:03 +01:00
},
// m_bubicleRange;
{
10, // m_life
0,0,0, // m_vx,m_vdx,m_vxmax
50,0,0, // m_vy,m_vdy,m_vymax
2001-03-01 22:07:38 +01:00
4,4, // m_w,m_h
2000-11-20 16:31:03 +01:00
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:
{
2001-01-11 21:26:42 +01:00
switch(s_fadeStyle)
2000-11-20 16:31:03 +01:00
{
2001-01-11 21:26:42 +01:00
case BUBBLE_FADE:
{
if(s_fadeValue>0)
{
POLY_F4 *f4;
POLY_G4 *g4;
POLY_FT3 *ft3;
f4=GetPrimF4();
setXYWH(f4,0,-FADE_BORDER_SIZE,512,s_fadeValue-(FADE_SMOOTH_BORDER_SIZE/2)+FADE_BORDER_SIZE);
setRGB0(f4,255,255,255);
AddPrimToList(f4,0);
g4=GetPrimG4();
setXYWH(g4,0,s_fadeValue-(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 BLACK_FADE:
{
POLY_F4 *f4;
POLY_FT3 *ft3;
f4=GetPrimF4();
setXYWH(f4,0,0,511,255);
setRGB0(f4,s_fadeValue,s_fadeValue,s_fadeValue);
setShadeTex(f4,0);
setSemiTrans(f4,1);
AddPrimToList(f4,0);
ft3=GetPrimFT3();
setPolyFT3(ft3);
setShadeTex(ft3,1);
setSemiTrans(ft3,1);
ft3->tpage=(2<<5);
setXY3(ft3,512,512,512,512,512,512);
AddPrimToList(ft3,0);
break;
}
2000-11-20 16:31:03 +01:00
}
}
break;
case FADING_OUT:
{
2001-01-11 21:26:42 +01:00
switch(s_fadeStyle)
{
case BUBBLE_FADE:
{
POLY_F4 *f4;
POLY_G4 *g4;
POLY_FT3 *ft3;
f4=GetPrimF4();
setXYWH(f4,0,s_fadeValue+(FADE_SMOOTH_BORDER_SIZE/2),512,256-s_fadeValue-(FADE_SMOOTH_BORDER_SIZE/2));
setRGB0(f4,255,255,255);
AddPrimToList(f4,0);
g4=GetPrimG4();
setXYWH(g4,0,s_fadeValue-(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 BLACK_FADE:
{
POLY_F4 *f4;
POLY_FT3 *ft3;
int col;
col=255-s_fadeValue;
f4=GetPrimF4();
setXYWH(f4,0,0,511,255);
setRGB0(f4,col,col,col);
setShadeTex(f4,0);
setSemiTrans(f4,1);
AddPrimToList(f4,0);
ft3=GetPrimFT3();
setPolyFT3(ft3);
setShadeTex(ft3,1);
setSemiTrans(ft3,1);
ft3->tpage=(2<<5);
setXY3(ft3,512,512,512,512,512,512);
AddPrimToList(ft3,0);
break;
}
}
2000-11-20 16:31:03 +01:00
}
break;
case FADED_OUT:
{
POLY_F4 *f4;
f4=GetPrimF4();
setXYWH(f4,0,0,512,256);
2001-01-11 21:26:42 +01:00
switch(s_fadeStyle)
{
case BUBBLE_FADE:
setRGB0(f4,255,255,255);
break;
case BLACK_FADE:
setRGB0(f4,0,0,0);
break;
}
AddPrimToList(f4,0);
2000-11-20 16:31:03 +01:00
return;
}
}
2001-01-11 21:26:42 +01:00
if(s_fadeStyle==BUBBLE_FADE)
{
s_fadeBubicleSpawner.m_y=s_fadeValue-20;
for(int i=0;i<BUBBLES_PER_FRAME;i++)
CBubicleFactory::spawnParticle(&s_fadeBubicleSpawner);
}
2000-11-20 16:31:03 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CFader::think(int _frames)
{
if(s_fadeMode!=FADED_IN&&s_fadeMode!=FADED_OUT)
{
2001-01-11 21:26:42 +01:00
s_fadeValue-=_frames*FADE_SPEED;
switch(s_fadeStyle)
2000-11-20 16:31:03 +01:00
{
2001-01-11 21:26:42 +01:00
case BUBBLE_FADE:
2001-01-03 21:43:49 +01:00
{
2001-01-11 21:26:42 +01:00
if(s_fadeValue<-FADE_BORDER_SIZE)
{
if(s_fadeMode==FADING_OUT)
{
s_fadeMode=FADED_OUT;
CSoundMediator::setVolume(CSoundMediator::VOL_FADE,0);
}
else
{
s_fadeMode=FADED_IN;
CSoundMediator::setVolume(CSoundMediator::VOL_FADE,255);
}
}
else
{
if(s_fadeValue>=0&&s_fadeValue<=255)
{
CSoundMediator::setVolume(CSoundMediator::VOL_FADE,s_fadeMode==FADING_OUT?s_fadeValue:255-s_fadeValue);
}
}
break;
2001-01-03 21:43:49 +01:00
}
2001-01-11 21:26:42 +01:00
case BLACK_FADE:
2001-01-03 21:43:49 +01:00
{
2001-01-11 21:26:42 +01:00
if(s_fadeValue<0)
{
s_fadeValue=0;
if(s_fadeMode==FADING_OUT)
{
s_fadeMode=FADED_OUT;
CSoundMediator::setVolume(CSoundMediator::VOL_FADE,0);
}
else
{
s_fadeMode=FADED_IN;
CSoundMediator::setVolume(CSoundMediator::VOL_FADE,255);
}
}
else
{
CSoundMediator::setVolume(CSoundMediator::VOL_FADE,s_fadeMode==FADING_OUT?s_fadeValue:255-s_fadeValue);
}
break;
2001-01-03 21:43:49 +01:00
}
2000-11-20 16:31:03 +01:00
}
}
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-01-11 21:26:42 +01:00
void CFader::setFadingOut(FADE_STYLE _style)
2000-11-20 16:31:03 +01:00
{
2001-01-11 21:26:42 +01:00
switch(_style)
{
case BUBBLE_FADE:
s_fadeValue=256+FADE_BORDER_SIZE;
break;
case BLACK_FADE:
s_fadeValue=255;
break;
}
2000-11-20 16:31:03 +01:00
s_fadeMode=FADING_OUT;
2001-01-11 21:26:42 +01:00
s_fadeStyle=_style;
2000-11-20 16:31:03 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-01-11 21:26:42 +01:00
void CFader::setFadingIn(FADE_STYLE _style)
2000-11-20 16:31:03 +01:00
{
2001-01-11 21:26:42 +01:00
switch(_style)
{
case BUBBLE_FADE:
s_fadeValue=256+FADE_BORDER_SIZE;
break;
case BLACK_FADE:
s_fadeValue=255;
break;
}
2000-11-20 16:31:03 +01:00
s_fadeMode=FADING_IN;
2001-01-11 21:26:42 +01:00
s_fadeStyle=_style;
2000-11-20 16:31:03 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
int CFader::isFading()
{
return s_fadeMode==FADING_IN||s_fadeMode==FADING_OUT;
}
/*===========================================================================
end */