Files
itgmania212121/stepmania/src/Sprite.h
T

82 lines
2.6 KiB
C++
Raw Normal View History

2002-05-19 01:59:48 +00:00
#pragma once
/*
-----------------------------------------------------------------------------
File: Sprite.h
Desc: A bitmap Actor that animates and moves around.
2002-05-19 01:59:48 +00:00
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
-----------------------------------------------------------------------------
*/
2001-11-03 10:52:42 +00:00
#include "Actor.h"
#include "RageUtil.h"
#include "RageTexture.h"
#define MAX_SPRITE_STATES 256
class Sprite: public Actor
{
public:
Sprite();
virtual ~Sprite();
2002-05-19 01:59:48 +00:00
virtual bool Load( CString sFilePath, bool bForceReload = false, int iMipMaps = 4, int iAlphaBits = 4, bool bDither = false, bool bStretch = 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-05-19 01:59:48 +00:00
return LoadFromSpriteFile( sFilePath, bForceReload, iMipMaps, iAlphaBits, bDither, bStretch );
2002-01-16 10:01:32 +00:00
else
2002-05-19 01:59:48 +00:00
return LoadFromTexture( sFilePath, bForceReload, iMipMaps, iAlphaBits, bDither, bStretch );
2002-01-16 10:01:32 +00:00
};
2002-04-16 17:31:00 +00:00
void UnloadTexture();
2002-04-28 20:42:32 +00:00
RageTexture* GetTexture() { return m_pTexture; };
2001-11-03 10:52:42 +00:00
2002-05-19 01:59:48 +00:00
virtual void DrawPrimitives();
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( int iNewState );
2001-11-03 10:52:42 +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-05-19 01:59:48 +00:00
virtual bool LoadFromTexture( CString sTexturePath, bool bForceReload = false, int iMipMaps = 4, int iAlphaBits = 4, bool bDither = false, bool bStretch = false );
virtual bool LoadFromSpriteFile( CString sSpritePath, bool bForceReload = false, int iMipMaps = 4, int iAlphaBits = 4, bool bDither = false, bool bStretch = false );
2001-11-03 10:52:42 +00:00
2002-05-19 01:59:48 +00:00
virtual bool LoadTexture( CString sTexture, bool bForceReload = false, int iMipMaps = 4, int iAlphaBits = 4, bool bDither = false, bool bStretch = 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;
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];
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
};