no message
This commit is contained in:
+149
-15
@@ -19,10 +19,23 @@
|
|||||||
|
|
||||||
const CString VIS_DIR = "Visualizations\\";
|
const CString VIS_DIR = "Visualizations\\";
|
||||||
const CString PARTICLE_DIR = "BGEffects\\particles\\";
|
const CString PARTICLE_DIR = "BGEffects\\particles\\";
|
||||||
|
const CString BACKGROUND_DIR = "BGEffects\\backgrounds\\";
|
||||||
|
|
||||||
|
|
||||||
|
// macro for handling CArrays of pointers
|
||||||
|
#define DELETE_CARRAY_CONTENTS( p ) {\
|
||||||
|
for( int d_ca_cI=0; d_ca_cI < (p).GetSize(); d_ca_cI++ ){ \
|
||||||
|
if((p).GetAt( d_ca_cI )) \
|
||||||
|
delete (p).GetAt( d_ca_cI ); \
|
||||||
|
}}
|
||||||
|
|
||||||
|
#define GET_RAND_ELEMENT( p ) ( (p).GetAt( rand() % (p).GetSize() ) )
|
||||||
|
|
||||||
|
|
||||||
Background::Background()
|
Background::Background()
|
||||||
{
|
{
|
||||||
|
m_totalTime = 0.0f;
|
||||||
|
|
||||||
m_bShowDanger = false;
|
m_bShowDanger = false;
|
||||||
|
|
||||||
m_sprDanger.SetZoom( 2 );
|
m_sprDanger.SetZoom( 2 );
|
||||||
@@ -33,15 +46,25 @@ Background::Background()
|
|||||||
m_sprDangerBackground.Load( THEME->GetPathTo(GRAPHIC_GAMEPLAY_DANGER_BACKGROUND) );
|
m_sprDangerBackground.Load( THEME->GetPathTo(GRAPHIC_GAMEPLAY_DANGER_BACKGROUND) );
|
||||||
m_sprDangerBackground.StretchTo( CRect((int)SCREEN_LEFT, (int)SCREEN_TOP, (int)SCREEN_RIGHT, (int)SCREEN_BOTTOM) );
|
m_sprDangerBackground.StretchTo( CRect((int)SCREEN_LEFT, (int)SCREEN_TOP, (int)SCREEN_RIGHT, (int)SCREEN_BOTTOM) );
|
||||||
|
|
||||||
|
// load particle sprites
|
||||||
|
m_curParticleSprite = NULL;
|
||||||
LoadParticleSprites( PARTICLE_DIR );
|
LoadParticleSprites( PARTICLE_DIR );
|
||||||
|
|
||||||
|
// load particle systems
|
||||||
|
m_curPS = NULL;
|
||||||
|
LoadParticleSystems();
|
||||||
|
|
||||||
|
// load background sprites
|
||||||
|
m_curBackground = NULL;
|
||||||
|
LoadBackgroundSprites( BACKGROUND_DIR );
|
||||||
|
|
||||||
|
m_songBackground = NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Background::LoadParticleSprites( CString path )
|
void Background::LoadParticleSprites( CString path )
|
||||||
{
|
{
|
||||||
CArray<Sprite*,Sprite*> m_particleSprites;
|
|
||||||
|
|
||||||
CStringArray filenames;
|
CStringArray filenames;
|
||||||
|
|
||||||
// get full path filenames for particleSprites
|
// get full path filenames for particleSprites
|
||||||
@@ -53,31 +76,85 @@ void Background::LoadParticleSprites( CString path )
|
|||||||
Sprite * temp = new Sprite();
|
Sprite * temp = new Sprite();
|
||||||
|
|
||||||
temp->Load( filenames.GetAt(i) );
|
temp->Load( filenames.GetAt(i) );
|
||||||
|
temp->SetBlendModeAdd();
|
||||||
|
|
||||||
m_particleSprites.Add( temp );
|
m_particleSprites.Add( temp );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Background::LoadParticleSystems()
|
||||||
|
{
|
||||||
|
m_particleSystems.Add( new DroppingParticleSystem );
|
||||||
|
m_particleSystems.Add( new SpiralParticleSystem );
|
||||||
|
m_particleSystems.Add( new ScrollingParticleSystem );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Background::LoadBackgroundSprites( CString path )
|
||||||
|
{
|
||||||
|
CStringArray filenames;
|
||||||
|
|
||||||
|
// get full path filenames for particleSprites
|
||||||
|
GetDirListing( path+"*.png", filenames, false, true );
|
||||||
|
|
||||||
|
// load sprites
|
||||||
|
for( int i=0; i < filenames.GetSize(); i++ )
|
||||||
|
{
|
||||||
|
Sprite * temp = new Sprite();
|
||||||
|
|
||||||
|
temp->Load( filenames.GetAt(i) );
|
||||||
|
|
||||||
|
float colTiles = SCREEN_WIDTH / temp->GetUnzoomedWidth();
|
||||||
|
float rowTiles = SCREEN_HEIGHT / temp->GetUnzoomedHeight();
|
||||||
|
|
||||||
|
temp->StretchTo( CRect( SCREEN_LEFT, SCREEN_TOP, SCREEN_RIGHT, SCREEN_BOTTOM ) );
|
||||||
|
|
||||||
|
float textCoords[] = {
|
||||||
|
0,rowTiles, // bottom-left
|
||||||
|
0,0, // top-left
|
||||||
|
colTiles, rowTiles, // bottom-right
|
||||||
|
colTiles, 0, // top-right
|
||||||
|
};
|
||||||
|
temp->SetCustomTextureCoords( textCoords );
|
||||||
|
|
||||||
|
m_backgroundSprites.Add( temp );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Background::~Background()
|
||||||
|
{
|
||||||
|
DELETE_CARRAY_CONTENTS( m_particleSprites );
|
||||||
|
DELETE_CARRAY_CONTENTS( m_particleSystems );
|
||||||
|
DELETE_CARRAY_CONTENTS( m_backgroundSprites );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Background::LoadFromSong( Song* pSong, bool bDisableVisualizations )
|
bool Background::LoadFromSong( Song* pSong, bool bDisableVisualizations )
|
||||||
{
|
{
|
||||||
|
Sprite * sprSongBackground = new Sprite();
|
||||||
|
|
||||||
if( pSong->HasBackgroundMovie() )
|
if( pSong->HasBackgroundMovie() )
|
||||||
{
|
{
|
||||||
// load the movie backgound, and don't load a visualization
|
// load the movie backgound, and don't load a visualization
|
||||||
m_sprSongBackground.Load( pSong->GetBackgroundMoviePath() );
|
sprSongBackground->Load( pSong->GetBackgroundMoviePath() );
|
||||||
m_sprSongBackground.StretchTo( CRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) );
|
sprSongBackground->StretchTo( CRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) );
|
||||||
m_sprSongBackground.SetZoomY( -1 );
|
sprSongBackground->SetZoomY( -1 );
|
||||||
m_sprSongBackground.SetDiffuseColor( D3DXCOLOR(0,0,0,1) );
|
sprSongBackground->SetDiffuseColor( D3DXCOLOR(0,0,0,1) );
|
||||||
this->AddActor( &m_sprSongBackground );
|
//this->AddActor( &m_sprSongBackground );
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// load the static background (if available), and a visualization
|
// load the static background (if available), and a visualization
|
||||||
if( pSong->HasBackground() ) m_sprSongBackground.Load( pSong->GetBackgroundPath(), false, 2, 0, true );
|
if( pSong->HasBackground() ) sprSongBackground->Load( pSong->GetBackgroundPath(), false, 2, 0, true );
|
||||||
else m_sprSongBackground.Load( THEME->GetPathTo(GRAPHIC_FALLBACK_BACKGROUND), false, 2, 0, true );
|
else sprSongBackground->Load( THEME->GetPathTo(GRAPHIC_FALLBACK_BACKGROUND), false, 2, 0, true );
|
||||||
|
|
||||||
m_sprSongBackground.StretchTo( CRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) );
|
sprSongBackground->StretchTo( CRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) );
|
||||||
m_sprSongBackground.SetDiffuseColor( D3DXCOLOR(0,0,0,1) );
|
sprSongBackground->SetDiffuseColor( D3DXCOLOR(0,0,0,1) );
|
||||||
this->AddActor( &m_sprSongBackground );
|
//this->AddActor( &m_sprSongBackground );
|
||||||
|
|
||||||
|
|
||||||
if( PREFSMAN->m_bUseRandomVis && !bDisableVisualizations )
|
if( PREFSMAN->m_bUseRandomVis && !bDisableVisualizations )
|
||||||
@@ -103,6 +180,13 @@ bool Background::LoadFromSong( Song* pSong, bool bDisableVisualizations )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_backgroundSprites.Add( sprSongBackground );
|
||||||
|
m_songBackground = sprSongBackground;
|
||||||
|
|
||||||
|
|
||||||
|
// get a effect to start with
|
||||||
|
NextEffect();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,10 +194,36 @@ void Background::Update( float fDeltaTime )
|
|||||||
{
|
{
|
||||||
ActorFrame::Update( fDeltaTime );
|
ActorFrame::Update( fDeltaTime );
|
||||||
|
|
||||||
|
m_totalTime += fDeltaTime;
|
||||||
|
|
||||||
m_sprVisualizationOverlay.Update( fDeltaTime );
|
m_sprVisualizationOverlay.Update( fDeltaTime );
|
||||||
m_sprSongBackground.Update( fDeltaTime );
|
//m_sprSongBackground.Update( fDeltaTime );
|
||||||
m_sprDanger.Update( fDeltaTime );
|
m_sprDanger.Update( fDeltaTime );
|
||||||
m_sprDangerBackground.Update( fDeltaTime );
|
m_sprDangerBackground.Update( fDeltaTime );
|
||||||
|
|
||||||
|
if( m_curPS && m_curParticleSprite )
|
||||||
|
{
|
||||||
|
m_curParticleSprite->Update( fDeltaTime );
|
||||||
|
m_curPS->update( fDeltaTime );
|
||||||
|
}
|
||||||
|
if( m_curBackground )
|
||||||
|
{
|
||||||
|
if( m_curBackground != m_songBackground )
|
||||||
|
{
|
||||||
|
float tweenPeriod = 2.0f;
|
||||||
|
float rads = ( fmodf( m_totalTime, tweenPeriod ) / tweenPeriod ) * 2.0f * D3DX_PI;
|
||||||
|
|
||||||
|
D3DXCOLOR color = D3DXCOLOR(
|
||||||
|
cosf( rads ) * 0.5f + 0.5f,
|
||||||
|
cosf( rads + D3DX_PI * 2.0f / 3.0f ) * 0.5f + 0.5f,
|
||||||
|
cosf( rads + D3DX_PI * 4.0f / 3.0f) * 0.5f + 0.5f,
|
||||||
|
1.0f
|
||||||
|
);
|
||||||
|
m_curBackground->SetDiffuseColor( color );
|
||||||
|
|
||||||
|
}
|
||||||
|
m_curBackground->Update( fDeltaTime );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Background::DrawPrimitives()
|
void Background::DrawPrimitives()
|
||||||
@@ -127,10 +237,34 @@ void Background::DrawPrimitives()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_sprSongBackground.Draw();
|
//m_sprSongBackground.Draw();
|
||||||
m_sprVisualizationOverlay.Draw();
|
m_sprVisualizationOverlay.Draw();
|
||||||
|
|
||||||
|
if( m_curBackground )
|
||||||
|
m_curBackground->Draw();
|
||||||
|
|
||||||
|
if( m_curPS && m_curParticleSprite )
|
||||||
|
m_curPS->draw( m_curParticleSprite );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void Background::NextEffect()
|
||||||
|
{
|
||||||
|
// randomly choose a particle system
|
||||||
|
if( m_particleSystems.GetSize() > 0 )
|
||||||
|
m_curPS = GET_RAND_ELEMENT( m_particleSystems );
|
||||||
|
|
||||||
|
// randomly choose a particle sprite
|
||||||
|
if( m_particleSprites.GetSize() > 0 )
|
||||||
|
m_curParticleSprite = GET_RAND_ELEMENT( m_particleSprites );
|
||||||
|
|
||||||
|
// randomly choose a background sprite
|
||||||
|
if( m_backgroundSprites.GetSize() > 0 )
|
||||||
|
{
|
||||||
|
m_curBackground = GET_RAND_ELEMENT( m_backgroundSprites );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
+21
-11
@@ -12,6 +12,7 @@
|
|||||||
#define _Background_H_
|
#define _Background_H_
|
||||||
|
|
||||||
|
|
||||||
|
#include "RageUtil.h"
|
||||||
#include "Sprite.h"
|
#include "Sprite.h"
|
||||||
#include "ActorFrame.h"
|
#include "ActorFrame.h"
|
||||||
#include "Song.h"
|
#include "Song.h"
|
||||||
@@ -25,6 +26,8 @@ class Background : public ActorFrame
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
Background();
|
Background();
|
||||||
|
virtual ~Background();
|
||||||
|
|
||||||
virtual bool LoadFromSong( Song *pSong, bool bDisableVisualizations = false );
|
virtual bool LoadFromSong( Song *pSong, bool bDisableVisualizations = false );
|
||||||
|
|
||||||
virtual void Update( float fDeltaTime );
|
virtual void Update( float fDeltaTime );
|
||||||
@@ -33,7 +36,12 @@ public:
|
|||||||
virtual void SetDiffuseColor( D3DXCOLOR c )
|
virtual void SetDiffuseColor( D3DXCOLOR c )
|
||||||
{
|
{
|
||||||
m_sprVisualizationOverlay.SetDiffuseColor( c );
|
m_sprVisualizationOverlay.SetDiffuseColor( c );
|
||||||
m_sprSongBackground.SetDiffuseColor( c );
|
|
||||||
|
for( int i=0; i < m_backgroundSprites.GetSize(); i++ )
|
||||||
|
m_backgroundSprites[i]->SetDiffuseColor(c);
|
||||||
|
|
||||||
|
//m_sprSongBackground.SetDiffuseColor( c );
|
||||||
|
|
||||||
m_sprDanger.SetDiffuseColor( c );
|
m_sprDanger.SetDiffuseColor( c );
|
||||||
m_sprDangerBackground.SetDiffuseColor( c );
|
m_sprDangerBackground.SetDiffuseColor( c );
|
||||||
};
|
};
|
||||||
@@ -43,32 +51,34 @@ public:
|
|||||||
|
|
||||||
virtual bool IsDangerOn() { return m_bShowDanger; };
|
virtual bool IsDangerOn() { return m_bShowDanger; };
|
||||||
|
|
||||||
virtual void nextEffect() {};
|
virtual void NextEffect();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual void LoadParticleSprites( CString path );
|
virtual void LoadParticleSprites( CString path );
|
||||||
|
virtual void LoadBackgroundSprites( CString path );
|
||||||
|
virtual void LoadParticleSystems();
|
||||||
|
|
||||||
|
|
||||||
enum ParticleEffect
|
|
||||||
{
|
|
||||||
PE_DROPPING = 0,
|
|
||||||
PE_SPIRAL_OUT,
|
|
||||||
PE_NUM
|
|
||||||
};
|
|
||||||
|
|
||||||
//CArray<Sprite*,Sprite*> m_backgroundTiles;
|
//CArray<Sprite*,Sprite*> m_backgroundTiles;
|
||||||
CArray<Sprite*,Sprite*> m_particleSprites;
|
CArray<Sprite*,Sprite*> m_particleSprites;
|
||||||
|
Sprite * m_curParticleSprite;
|
||||||
|
|
||||||
ParticleSystem* m_pPS;
|
CArray<ParticleSystem*,ParticleSystem*> m_particleSystems;
|
||||||
|
ParticleSystem* m_curPS;
|
||||||
|
|
||||||
|
CArray<Sprite*,Sprite*> m_backgroundSprites;
|
||||||
|
Sprite * m_curBackground;
|
||||||
|
|
||||||
Sprite m_sprVisualizationOverlay;
|
Sprite m_sprVisualizationOverlay;
|
||||||
Sprite m_sprSongBackground;
|
Sprite * m_songBackground;
|
||||||
|
|
||||||
Sprite m_sprDanger;
|
Sprite m_sprDanger;
|
||||||
Sprite m_sprDangerBackground;
|
Sprite m_sprDangerBackground;
|
||||||
|
|
||||||
bool m_bShowDanger;
|
bool m_bShowDanger;
|
||||||
|
|
||||||
|
float m_totalTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user