Files
itgmania212121/stepmania/src/Sprite.h
T

92 lines
2.2 KiB
C++
Raw Normal View History

/*
-----------------------------------------------------------------------------
File: Sprite.h
Desc: A bitmap Actor that animates and moves around.
Copyright (c) 2001 Chris Danford. All rights reserved.
-----------------------------------------------------------------------------
*/
2001-11-03 10:52:42 +00:00
#ifndef _SPRITE_H_
#define _SPRITE_H_
#include "Actor.h"
#include "RageUtil.h"
#include "RageTexture.h"
#define MAX_SPRITE_STATES 256
class Sprite: public Actor
{
public:
Sprite();
virtual ~Sprite();
2002-01-16 10:01:32 +00:00
virtual bool Load( CString sFilePath )
{
if( sFilePath.Right(7) == ".sprite" )
return LoadFromSpriteFile( sFilePath );
else
return LoadFromTexture( sFilePath );
};
2001-11-03 10:52:42 +00:00
2002-01-16 10:01:32 +00:00
virtual void RenderPrimitives();
virtual void Update( float fDeltaTime );
2001-11-03 10:52:42 +00:00
virtual void StartAnimating() { m_bIsAnimating = TRUE; };
virtual void StopAnimating() { m_bIsAnimating = FALSE; };
virtual void SetState( UINT uNewState );
2001-11-03 10:52:42 +00:00
UINT GetNumStates() { return m_uNumStates; };
CString GetTexturePath() { return m_sTexturePath; };
2002-01-29 21:56:14 +00:00
void SetCustomTextureRect( FRECT new_texcoord_frect );
void SetCustomTextureCoords( float fTexCoords[8] );
void SetCustomSourceRect( FRECT rectSourceCoords ); // in source pixel space
void SetCustomImageRect( FRECT rectImageCoords ); // in image pixel space
void SetCustomImageCoords( float fImageCoords[8] );
2001-11-03 10:52:42 +00:00
2001-12-19 01:50:57 +00:00
void TurnShadowOn() { m_bHasShadow = true; };
void TurnShadowOff() { m_bHasShadow = false; };
2001-11-03 10:52:42 +00:00
2001-12-28 10:15:59 +00:00
void SetBlendModeAdd() { m_bBlendAdd = true; };
void SetBlendModeNormal() { m_bBlendAdd = false; };
2001-11-03 10:52:42 +00:00
protected:
2002-01-16 10:01:32 +00:00
virtual bool LoadFromTexture( CString sTexturePath );
virtual bool LoadFromSpriteFile( CString sSpritePath );
2001-11-03 10:52:42 +00:00
2002-01-16 10:01:32 +00:00
2001-11-28 20:26:45 +00:00
bool LoadTexture( CString sTexture );
2001-11-03 10:52:42 +00:00
CString m_sSpritePath;
2002-01-16 10:01:32 +00:00
RageTexture* m_pTexture;
2001-11-03 10:52:42 +00:00
CString m_sTexturePath;
UINT m_uFrame[MAX_SPRITE_STATES]; // array of indicies into m_rectBitmapFrames
2001-11-28 20:26:45 +00:00
float m_fDelay[MAX_SPRITE_STATES];
2001-11-03 10:52:42 +00:00
UINT m_uNumStates;
UINT m_uCurState;
2001-11-28 20:26:45 +00:00
bool m_bIsAnimating;
float m_fSecsIntoState; // number of seconds that have elapsed since we switched to this frame
2001-11-03 10:52:42 +00:00
2001-12-28 10:15:59 +00:00
bool m_bUsingCustomTexCoords;
//FRECT m_CustomTexCoordRect;
float m_CustomTexCoords[8]; // (x,y) * 4
2001-12-19 01:50:57 +00:00
bool m_bHasShadow;
2001-12-28 10:15:59 +00:00
bool m_bBlendAdd;
2001-11-03 10:52:42 +00:00
};
#endif