increase particle limit, add command repeating to layer
This commit is contained in:
@@ -36,6 +36,9 @@ const float PARTICLE_SPEED = 300;
|
|||||||
const float SPIRAL_MAX_ZOOM = 2;
|
const float SPIRAL_MAX_ZOOM = 2;
|
||||||
const float SPIRAL_MIN_ZOOM = 0.3f;
|
const float SPIRAL_MIN_ZOOM = 0.3f;
|
||||||
|
|
||||||
|
#define MAX_TILES_WIDE (SCREEN_WIDTH/32+2)
|
||||||
|
#define MAX_TILES_HIGH (SCREEN_HEIGHT/32+2)
|
||||||
|
#define MAX_SPRITES (MAX_TILES_WIDE*MAX_TILES_HIGH)
|
||||||
|
|
||||||
|
|
||||||
BGAnimationLayer::BGAnimationLayer()
|
BGAnimationLayer::BGAnimationLayer()
|
||||||
@@ -59,6 +62,8 @@ void BGAnimationLayer::Init()
|
|||||||
{
|
{
|
||||||
Unload();
|
Unload();
|
||||||
|
|
||||||
|
m_fRepeatCommandEverySeconds = -1;
|
||||||
|
m_fSecondsUntilRepeatCommand = 0;
|
||||||
m_fUpdateRate = 1;
|
m_fUpdateRate = 1;
|
||||||
m_fFOV = -1; // no change
|
m_fFOV = -1; // no change
|
||||||
m_bLighting = false;
|
m_bLighting = false;
|
||||||
@@ -67,8 +72,7 @@ void BGAnimationLayer::Init()
|
|||||||
// m_bCycleAlpha = false;
|
// m_bCycleAlpha = false;
|
||||||
// m_Effect = EFFECT_STRETCH_STILL;
|
// m_Effect = EFFECT_STRETCH_STILL;
|
||||||
|
|
||||||
for( int i=0; i<MAX_SPRITES; i++ )
|
m_vParticleVelocity.clear();
|
||||||
m_vParticleVelocity[i] = RageVector3( 0, 0, 0 );
|
|
||||||
|
|
||||||
m_Type = TYPE_SPRITE;
|
m_Type = TYPE_SPRITE;
|
||||||
|
|
||||||
@@ -530,6 +534,8 @@ void BGAnimationLayer::LoadFromIni( CString sAniDir, CString sLayer )
|
|||||||
ini.GetValue( sLayer, "Type", (int&)m_Type );
|
ini.GetValue( sLayer, "Type", (int&)m_Type );
|
||||||
CLAMP( m_Type, (Type)0, TYPE_INVALID );
|
CLAMP( m_Type, (Type)0, TYPE_INVALID );
|
||||||
ini.GetValue( sLayer, "Command", m_sOnCommand );
|
ini.GetValue( sLayer, "Command", m_sOnCommand );
|
||||||
|
ini.GetValue( sLayer, "CommandRepeatSeconds", m_fRepeatCommandEverySeconds );
|
||||||
|
m_fSecondsUntilRepeatCommand = m_fRepeatCommandEverySeconds;
|
||||||
ini.GetValue( sLayer, "OffCommand", m_sOffCommand );
|
ini.GetValue( sLayer, "OffCommand", m_sOffCommand );
|
||||||
ini.GetValue( sLayer, "FOV", m_fFOV );
|
ini.GetValue( sLayer, "FOV", m_fFOV );
|
||||||
ini.GetValue( sLayer, "Lighting", m_bLighting );
|
ini.GetValue( sLayer, "Lighting", m_bLighting );
|
||||||
@@ -586,10 +592,10 @@ void BGAnimationLayer::LoadFromIni( CString sAniDir, CString sLayer )
|
|||||||
m_pActors.push_back( pActor );
|
m_pActors.push_back( pActor );
|
||||||
pActor->SetXY( randomf(SCREEN_LEFT,SCREEN_RIGHT), randomf(SCREEN_TOP,SCREEN_BOTTOM) );
|
pActor->SetXY( randomf(SCREEN_LEFT,SCREEN_RIGHT), randomf(SCREEN_TOP,SCREEN_BOTTOM) );
|
||||||
pActor->SetZoom( randomf(m_fZoomMin,m_fZoomMax) );
|
pActor->SetZoom( randomf(m_fZoomMin,m_fZoomMax) );
|
||||||
m_vParticleVelocity[i] = RageVector3(
|
m_vParticleVelocity.push_back( RageVector3(
|
||||||
randomf(m_fVelocityXMin,m_fVelocityXMax),
|
randomf(m_fVelocityXMin,m_fVelocityXMax),
|
||||||
randomf(m_fVelocityYMin,m_fVelocityYMax),
|
randomf(m_fVelocityYMin,m_fVelocityYMax),
|
||||||
randomf(m_fVelocityZMin,m_fVelocityZMax) );
|
randomf(m_fVelocityZMin,m_fVelocityZMax) ) );
|
||||||
if( m_fOverrideSpeed != 0 )
|
if( m_fOverrideSpeed != 0 )
|
||||||
{
|
{
|
||||||
RageVec3Normalize( &m_vParticleVelocity[i], &m_vParticleVelocity[i] );
|
RageVec3Normalize( &m_vParticleVelocity[i], &m_vParticleVelocity[i] );
|
||||||
@@ -720,42 +726,45 @@ void BGAnimationLayer::Update( float fDeltaTime )
|
|||||||
case TYPE_PARTICLES:
|
case TYPE_PARTICLES:
|
||||||
for( i=0; i<m_pActors.size(); i++ )
|
for( i=0; i<m_pActors.size(); i++ )
|
||||||
{
|
{
|
||||||
m_pActors[i]->SetX( m_pActors[i]->GetX() + fDeltaTime*m_vParticleVelocity[i].x );
|
Actor* pActor = m_pActors[i];
|
||||||
m_pActors[i]->SetY( m_pActors[i]->GetY() + fDeltaTime*m_vParticleVelocity[i].y );
|
RageVector3 &vel = m_vParticleVelocity[i];
|
||||||
m_pActors[i]->SetZ( m_pActors[i]->GetZ() + fDeltaTime*m_vParticleVelocity[i].z );
|
|
||||||
|
m_pActors[i]->SetX( pActor->GetX() + fDeltaTime*vel.x );
|
||||||
|
m_pActors[i]->SetY( pActor->GetY() + fDeltaTime*vel.y );
|
||||||
|
pActor->SetZ( pActor->GetZ() + fDeltaTime*vel.z );
|
||||||
if( m_bParticlesBounce )
|
if( m_bParticlesBounce )
|
||||||
{
|
{
|
||||||
if( HitGuardRailLeft(m_pActors[i]) )
|
if( HitGuardRailLeft(pActor) )
|
||||||
{
|
{
|
||||||
m_vParticleVelocity[i].x *= -1;
|
vel.x *= -1;
|
||||||
m_pActors[i]->SetX( GetGuardRailLeft(m_pActors[i]) );
|
pActor->SetX( GetGuardRailLeft(pActor) );
|
||||||
}
|
}
|
||||||
if( HitGuardRailRight(m_pActors[i]) )
|
if( HitGuardRailRight(pActor) )
|
||||||
{
|
{
|
||||||
m_vParticleVelocity[i].x *= -1;
|
vel.x *= -1;
|
||||||
m_pActors[i]->SetX( GetGuardRailRight(m_pActors[i]) );
|
pActor->SetX( GetGuardRailRight(pActor) );
|
||||||
}
|
}
|
||||||
if( HitGuardRailTop(m_pActors[i]) )
|
if( HitGuardRailTop(pActor) )
|
||||||
{
|
{
|
||||||
m_vParticleVelocity[i].y *= -1;
|
vel.y *= -1;
|
||||||
m_pActors[i]->SetY( GetGuardRailTop(m_pActors[i]) );
|
pActor->SetY( GetGuardRailTop(pActor) );
|
||||||
}
|
}
|
||||||
if( HitGuardRailBottom(m_pActors[i]) )
|
if( HitGuardRailBottom(pActor) )
|
||||||
{
|
{
|
||||||
m_vParticleVelocity[i].y *= -1;
|
vel.y *= -1;
|
||||||
m_pActors[i]->SetY( GetGuardRailBottom(m_pActors[i]) );
|
pActor->SetY( GetGuardRailBottom(pActor) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // !m_bParticlesBounce
|
else // !m_bParticlesBounce
|
||||||
{
|
{
|
||||||
if( m_vParticleVelocity[i].x<0 && IsOffScreenLeft(m_pActors[i]) )
|
if( vel.x<0 && IsOffScreenLeft(pActor) )
|
||||||
m_pActors[i]->SetX( GetOffScreenRight(m_pActors[i]) );
|
pActor->SetX( GetOffScreenRight(pActor) );
|
||||||
if( m_vParticleVelocity[i].x>0 && IsOffScreenRight(m_pActors[i]) )
|
if( vel.x>0 && IsOffScreenRight(pActor) )
|
||||||
m_pActors[i]->SetX( GetOffScreenLeft(m_pActors[i]) );
|
pActor->SetX( GetOffScreenLeft(pActor) );
|
||||||
if( m_vParticleVelocity[i].y<0 && IsOffScreenTop(m_pActors[i]) )
|
if( vel.y<0 && IsOffScreenTop(pActor) )
|
||||||
m_pActors[i]->SetY( GetOffScreenBottom(m_pActors[i]) );
|
pActor->SetY( GetOffScreenBottom(pActor) );
|
||||||
if( m_vParticleVelocity[i].y>0 && IsOffScreenBottom(m_pActors[i]) )
|
if( vel.y>0 && IsOffScreenBottom(pActor) )
|
||||||
m_pActors[i]->SetY( GetOffScreenTop(m_pActors[i]) );
|
pActor->SetY( GetOffScreenTop(pActor) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -918,6 +927,17 @@ void BGAnimationLayer::Update( float fDeltaTime )
|
|||||||
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if( m_fRepeatCommandEverySeconds != -1 ) // if repeating
|
||||||
|
{
|
||||||
|
m_fSecondsUntilRepeatCommand -= fDeltaTime;
|
||||||
|
if( m_fSecondsUntilRepeatCommand <= 0 )
|
||||||
|
{
|
||||||
|
for( unsigned i=0; i<m_pActors.size(); i++ )
|
||||||
|
m_pActors[i]->Command( m_sOnCommand );
|
||||||
|
m_fSecondsUntilRepeatCommand += m_fRepeatCommandEverySeconds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BGAnimationLayer::Draw()
|
void BGAnimationLayer::Draw()
|
||||||
@@ -981,9 +1001,12 @@ void BGAnimationLayer::GainingFocus( float fRate, bool bRewindMovie, bool bLoop
|
|||||||
pSprite->GetTexture()->Play();
|
pSprite->GetTexture()->Play();
|
||||||
pSprite->GetTexture()->SetPlaybackRate(fRate);
|
pSprite->GetTexture()->SetPlaybackRate(fRate);
|
||||||
|
|
||||||
|
if( m_fRepeatCommandEverySeconds == -1 ) // if not repeating
|
||||||
|
{
|
||||||
for( unsigned i=0; i<m_pActors.size(); i++ )
|
for( unsigned i=0; i<m_pActors.size(); i++ )
|
||||||
m_pActors[i]->Command( m_sOnCommand );
|
m_pActors[i]->Command( m_sOnCommand );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void BGAnimationLayer::LosingFocus()
|
void BGAnimationLayer::LosingFocus()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,11 +16,6 @@
|
|||||||
#include "Sprite.h"
|
#include "Sprite.h"
|
||||||
#include "GameConstantsAndTypes.h"
|
#include "GameConstantsAndTypes.h"
|
||||||
|
|
||||||
#define MAX_TILES_WIDE (SCREEN_WIDTH/32+2)
|
|
||||||
#define MAX_TILES_HIGH (SCREEN_HEIGHT/32+2)
|
|
||||||
#define MAX_SPRITES 16
|
|
||||||
// (MAX_TILES_WIDE*MAX_TILES_HIGH)
|
|
||||||
|
|
||||||
class BGAnimationLayer
|
class BGAnimationLayer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -48,7 +43,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
vector<Actor*> m_pActors;
|
vector<Actor*> m_pActors;
|
||||||
RageVector3 m_vParticleVelocity[MAX_SPRITES];
|
vector<RageVector3> m_vParticleVelocity;
|
||||||
|
|
||||||
enum Effect {
|
enum Effect {
|
||||||
EFFECT_CENTER,
|
EFFECT_CENTER,
|
||||||
@@ -99,7 +94,9 @@ protected:
|
|||||||
// common stuff
|
// common stuff
|
||||||
CString m_sOnCommand;
|
CString m_sOnCommand;
|
||||||
CString m_sOffCommand;
|
CString m_sOffCommand;
|
||||||
float m_fUpdateRate; // get by GainingFocus
|
float m_fRepeatCommandEverySeconds; // -1 = no repeat
|
||||||
|
float m_fSecondsUntilRepeatCommand;
|
||||||
|
float m_fUpdateRate; // set by GainingFocus
|
||||||
float m_fFOV; // -1 = no change
|
float m_fFOV; // -1 = no change
|
||||||
bool m_bLighting;
|
bool m_bLighting;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user