2001-11-04 19:34:28 +00:00
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
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-02-03 20:45:08 +00:00
|
|
|
virtual bool Load( CString sFilePath, DWORD dwHints = 0, bool bForceReload = false )
|
2002-01-16 10:01:32 +00:00
|
|
|
{
|
2002-03-31 07:55:25 +00:00
|
|
|
ASSERT( sFilePath != "" );
|
2002-01-16 10:01:32 +00:00
|
|
|
if( sFilePath.Right(7) == ".sprite" )
|
2002-02-03 20:45:08 +00:00
|
|
|
return LoadFromSpriteFile( sFilePath, dwHints, bForceReload );
|
2002-01-16 10:01:32 +00:00
|
|
|
else
|
2002-02-03 20:45:08 +00:00
|
|
|
return LoadFromTexture( sFilePath, dwHints, bForceReload );
|
2002-01-16 10:01:32 +00:00
|
|
|
};
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2002-01-16 10:01:32 +00:00
|
|
|
virtual void RenderPrimitives();
|
2001-12-11 11:25:37 +00:00
|
|
|
virtual void Update( float fDeltaTime );
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2001-12-11 11:25:37 +00:00
|
|
|
virtual void StartAnimating() { m_bIsAnimating = TRUE; };
|
|
|
|
|
virtual void StopAnimating() { m_bIsAnimating = FALSE; };
|
2002-03-30 20:00:13 +00:00
|
|
|
virtual void SetState( int iNewState );
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2002-03-30 20:00:13 +00:00
|
|
|
int GetNumStates() { return m_iNumStates; };
|
2001-11-03 10:52:42 +00:00
|
|
|
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] );
|
2002-03-31 07:55:25 +00:00
|
|
|
void StopUsingCustomCoords();
|
2001-11-03 10:52:42 +00:00
|
|
|
|
|
|
|
|
protected:
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2002-02-03 20:45:08 +00:00
|
|
|
virtual bool LoadFromTexture( CString sTexturePath, DWORD dwHints = 0, bool bForceReload = false );
|
|
|
|
|
virtual bool LoadFromSpriteFile( CString sSpritePath, DWORD dwHints = 0, bool bForceReload = false );
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2002-02-03 20:45:08 +00:00
|
|
|
virtual bool LoadTexture( CString sTexture, DWORD dwHints = 0, bool bForceReload = false );
|
2002-01-16 10:01:32 +00:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
2002-03-30 20:00:13 +00:00
|
|
|
int m_iStateToFrame[MAX_SPRITE_STATES]; // array of indicies into m_rectBitmapFrames
|
2001-11-28 20:26:45 +00:00
|
|
|
float m_fDelay[MAX_SPRITE_STATES];
|
2002-03-30 20:00:13 +00:00
|
|
|
int m_iNumStates;
|
|
|
|
|
int m_iCurState;
|
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-11-03 10:52:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|