Sprite Class Reference

Sprite objects handling module. More...

Inheritance diagram for Sprite:

ScreenObject GFX

List of all members.

Public Member Functions

 Sprite ()
 Sprite constructor.
 Sprite (const GFX &InitGFX)
 Alternative sprite constructor.
bool IsWarped ()
void SetWarped (bool w=true)
bool IsConstrained ()
void SetConstrained (bool c=true)
virtual void SetPrio (u16 NewPrio=DEFAULT_SPRITE_PRIO)
 change the object priority (the higher the most on top)
virtual void SetXY (s16 NewX=0, s16 NewY=0)
virtual void Draw ()
 draw a single sprite on the screen. Usually this in not invoked directly (except you dont wanna use default DrawScreen and/or want to override the priority system).
bool isVisible ()
void SetVisible (bool b=true)
void Show ()
void Hide ()
u16 GetPrio () const
 return the object priority
s16 GetX () const
 return the horizontal screen coordinate of the upper-left corner of the object
s16 GetY () const
 return the vertical screen coordinate of the upper-left corner of the object
s16 GetVX () const
 return the horizontal object velocity
s16 GetVY () const
 return the vertical object velocity
Point GetPosition (void) const
void SetX (const s16 NewX=0)
void SetY (const s16 NewY=0)
void SetVX (const s16 NewVX=0)
void SetVY (const s16 NewVY=0)
void SetVXY (const s16 NewVX=0, const s16 NewVY=0)
bool isMoving () const
s16 GetCenterX (void) const
 Return the center's X coordinate of the object.
s16 GetCenterY (void) const
 Return the center's Y coordinate of the object.
u16 Distance (const ScreenObject &Another) const
 Compute the distance (in pixels) between the centers of two screen objects (member version).
s16 Angle (const ScreenObject &Another) const
 Compute the angle (in degrees) between the centers of two screen objects (member version).
bool CollisionRect (const ScreenObject &Another, u16 Range=0) const
 Rectangular collision checker (member version).
bool CollisionCirc (const ScreenObject &Another, u16 Range=0) const
 Circular collision checker (member version).
GFX Clone (void) const
void Save (const std::string Filename) const
 saves this graphical surface into a BMP file.
SDL_Surface * GetSurface () const
 return the associated SDL Surface for direct manipulation
void SetSurface (SDL_Surface *NewSurface)
 NewSurface is copied and can be safely fred after invocation.
u16 GetWidth () const
u16 GetHeight () const
u8 GetNoFrames ()
void SetNoFrames (const u16 NewNoFrames=1)
SDL_Color GetTrans (void) const
void SetTrans (const SDL_Color NewTransparent=NONE)
void SetAlpha (const u8 NewAlpha=SDL_ALPHA_OPAQUE)
u8 GetAlpha () const
u16 GetFrame () const
 get current frame number (count starts from 0)
void SetFrame (const u16 NewFrame=0)
 set current frame number (count starts from 0, must be < NoFrames)
bool isAnim () const
 return true if playing animation
void StartAnim ()
 start sprite auto-animation
void PauseAnim ()
void StopAnim ()
u8 GetFPS ()
SDL_Color GetPixel (const u16 X, const u16 Y) const
void SetPixel (const u16 X, const u16 Y, const SDL_Color Color=BLACK)
void DrawLine (const u16 X1, const u16 Y1, const u16 X2, const u16 Y2, SDL_Color EdgeColor=BLACK, u8 Thick=1)
void DrawRect (Rect r, SDL_Color FillColor=BLACK)

Static Public Member Functions

static void HideAll ()
 hide all the sprites (but do not unregister 'em all)
static void ShowAll ()
 set all the sprites visible
static void DrawAll (void)

Protected Types

typedef std::multiset
< ScreenObject
*, CompareByPrio > 
MultisetSortedByPrio

Protected Member Functions

void Move (void)
 change object's position according to current velocities
void Register ()
void Unregister ()
void UpdateFrame (void)
SDL_Rect GetFrameRect () const

Protected Attributes

bool Visible
 if false makes the object invisible. Can be useful in a lot of situations...
s16 X
s16 Y
 current screen position (pixel coords) for Sprites and Banners. For BGs indicate current scrolling position (the upper-left corner).
s16 VX
s16 VY
 velocities (in pixel/sec)
u32 LastMoveTime
 last (SDL) time when position changed
u16 Prio
MultisetSortedByPrio::const_iterator ROs_Pos
SDL_Surface * Surface
SDL_Color Transparent
u8 Alpha
bool RotZoomEnabled
SDL_Surface * OriginalSurface
u16 W
u16 H
u8 NoFrames
u16 Frame
bool Anim
u32 LastFrameTime
u8 FPS
s8 AnimNoLoops

Static Protected Attributes

static MultisetSortedByPrio RegisteredScreenObjects


Detailed Description

Sprite objects handling module.

Member Typedef Documentation

typedef std::multiset<ScreenObject*, CompareByPrio> ScreenObject::MultisetSortedByPrio [protected, inherited]


Constructor & Destructor Documentation

Sprite::Sprite (  )  [inline]

Sprite constructor.

Sprite::Sprite ( const GFX InitGFX  )  [inline]

Alternative sprite constructor.


Member Function Documentation

s16 ScreenObject::Angle ( const ScreenObject Another  )  const [inline, inherited]

Compute the angle (in degrees) between the centers of two screen objects (member version).

References ScreenObject::GetCenterX(), and ScreenObject::GetCenterY().

Referenced by Angle().

GFX GFX::Clone ( void   )  const [inline, inherited]

bool ScreenObject::CollisionCirc ( const ScreenObject Another,
u16  Range = 0 
) const [inline, inherited]

Circular collision checker (member version).

References ScreenObject::GetCenterX(), ScreenObject::GetCenterY(), and GFX::GetWidth().

Referenced by CollisionCirc().

bool ScreenObject::CollisionRect ( const ScreenObject Another,
u16  Range = 0 
) const [inline, inherited]

Rectangular collision checker (member version).

References ScreenObject::GetCenterX(), ScreenObject::GetCenterY(), GFX::GetHeight(), and GFX::GetWidth().

Referenced by CollisionRect().

u16 ScreenObject::Distance ( const ScreenObject Another  )  const [inline, inherited]

Compute the distance (in pixels) between the centers of two screen objects (member version).

References ScreenObject::GetCenterX(), and ScreenObject::GetCenterY().

Referenced by Distance().

virtual void Sprite::Draw (  )  [virtual]

draw a single sprite on the screen. Usually this in not invoked directly (except you dont wanna use default DrawScreen and/or want to override the priority system).

Reimplemented from ScreenObject.

static void ScreenObject::DrawAll ( void   )  [static, inherited]

Referenced by DrawScreen().

void GFX::DrawLine ( const u16  X1,
const u16  Y1,
const u16  X2,
const u16  Y2,
SDL_Color  EdgeColor = BLACK,
u8  Thick = 1 
) [inline, inherited]

void GFX::DrawRect ( Rect  r,
SDL_Color  FillColor = BLACK 
) [inline, inherited]

References GFX::Surface.

Referenced by GFX::DrawLine().

u8 GFX::GetAlpha (  )  const [inline, inherited]

References GFX::Alpha.

s16 ScreenObject::GetCenterX ( void   )  const [inline, inherited]

Return the center's X coordinate of the object.

References GFX::GetWidth(), and ScreenObject::GetX().

Referenced by ScreenObject::Angle(), ScreenObject::CollisionCirc(), ScreenObject::CollisionRect(), and ScreenObject::Distance().

s16 ScreenObject::GetCenterY ( void   )  const [inline, inherited]

Return the center's Y coordinate of the object.

References GFX::GetHeight(), and ScreenObject::GetY().

Referenced by ScreenObject::Angle(), ScreenObject::CollisionCirc(), ScreenObject::CollisionRect(), and ScreenObject::Distance().

u8 GFX::GetFPS (  )  [inline, inherited]

References GFX::FPS.

u16 GFX::GetFrame (  )  const [inline, inherited]

get current frame number (count starts from 0)

References GFX::Frame.

SDL_Rect GFX::GetFrameRect (  )  const [protected, inherited]

u16 GFX::GetHeight (  )  const [inline, inherited]

u8 GFX::GetNoFrames (  )  [inline, inherited]

References GFX::NoFrames.

SDL_Color GFX::GetPixel ( const u16  X,
const u16  Y 
) const [inline, inherited]

References GFX::Surface.

Point ScreenObject::GetPosition ( void   )  const [inline, inherited]

u16 ScreenObject::GetPrio (  )  const [inline, inherited]

return the object priority

References ScreenObject::Prio.

SDL_Surface* GFX::GetSurface (  )  const [inline, inherited]

return the associated SDL Surface for direct manipulation

References GFX::Surface.

SDL_Color GFX::GetTrans ( void   )  const [inline, inherited]

References GFX::Transparent.

s16 ScreenObject::GetVX (  )  const [inline, inherited]

return the horizontal object velocity

References ScreenObject::VX.

s16 ScreenObject::GetVY (  )  const [inline, inherited]

return the vertical object velocity

References ScreenObject::VY.

u16 GFX::GetWidth (  )  const [inline, inherited]

s16 ScreenObject::GetX (  )  const [inline, inherited]

return the horizontal screen coordinate of the upper-left corner of the object

References ScreenObject::X.

Referenced by ScreenObject::GetCenterX(), and ScreenObject::GetPosition().

s16 ScreenObject::GetY (  )  const [inline, inherited]

return the vertical screen coordinate of the upper-left corner of the object

References ScreenObject::Y.

Referenced by ScreenObject::GetCenterY(), and ScreenObject::GetPosition().

void ScreenObject::Hide (  )  [inline, inherited]

static void Sprite::HideAll (  )  [static]

hide all the sprites (but do not unregister 'em all)

Referenced by HideAllSprites().

bool GFX::isAnim (  )  const [inline, inherited]

return true if playing animation

References GFX::Anim.

bool Sprite::IsConstrained (  )  [inline]

bool ScreenObject::isMoving (  )  const [inline, inherited]

bool ScreenObject::isVisible (  )  [inline, inherited]

References ScreenObject::Visible.

bool Sprite::IsWarped (  )  [inline]

void ScreenObject::Move ( void   )  [protected, inherited]

change object's position according to current velocities

void GFX::PauseAnim (  )  [inline, inherited]

References GFX::Anim.

void ScreenObject::Register (  )  [inline, protected, inherited]

void GFX::Save ( const std::string  Filename  )  const [inline, inherited]

saves this graphical surface into a BMP file.

References GFX::Surface.

void GFX::SetAlpha ( const u8  NewAlpha = SDL_ALPHA_OPAQUE  )  [inline, inherited]

Parameters:
NewAlpha set the alpha blending. If invoked with no args reset to opaque.

References GFX::Alpha, and GFX::Surface.

void Sprite::SetConstrained ( bool  c = true  )  [inline]

void GFX::SetFrame ( const u16  NewFrame = 0  )  [inline, inherited]

set current frame number (count starts from 0, must be < NoFrames)

References GFX::Frame, and GFX::NoFrames.

void GFX::SetNoFrames ( const u16  NewNoFrames = 1  )  [inline, inherited]

References GFX::H, GFX::NoFrames, GFX::StopAnim(), GFX::Surface, and GFX::W.

Referenced by GFX::GFX().

void GFX::SetPixel ( const u16  X,
const u16  Y,
const SDL_Color  Color = BLACK 
) [inline, inherited]

References GFX::Surface.

Referenced by GFX::DrawLine().

virtual void Sprite::SetPrio ( u16  NewPrio = DEFAULT_SPRITE_PRIO  )  [inline, virtual]

change the object priority (the higher the most on top)

Reimplemented from ScreenObject.

void GFX::SetSurface ( SDL_Surface *  NewSurface  )  [inline, inherited]

NewSurface is copied and can be safely fred after invocation.

References GFX::Surface.

Referenced by GFX::GFX().

void GFX::SetTrans ( const SDL_Color  NewTransparent = NONE  )  [inline, inherited]

Parameters:
NewTransparent set the transparent color. Invoked with no arguments will remove any previously set transparency.

References GFX::Surface, and GFX::Transparent.

Referenced by GFX::GFX().

void ScreenObject::SetVisible ( bool  b = true  )  [inline, inherited]

void ScreenObject::SetVX ( const s16  NewVX = 0  )  [inline, inherited]

Parameters:
NewVX Set the horizontal speed (in pixel/sec)

References ScreenObject::LastMoveTime, and ScreenObject::VX.

Referenced by ScreenObject::SetVXY().

void ScreenObject::SetVXY ( const s16  NewVX = 0,
const s16  NewVY = 0 
) [inline, inherited]

void ScreenObject::SetVY ( const s16  NewVY = 0  )  [inline, inherited]

Parameters:
NewVY Set the vertical speed (in pixel/sec)

References ScreenObject::LastMoveTime, and ScreenObject::VY.

Referenced by ScreenObject::SetVXY().

void Sprite::SetWarped ( bool  w = true  )  [inline]

void ScreenObject::SetX ( const s16  NewX = 0  )  [inline, inherited]

References ScreenObject::X.

Referenced by ScreenObject::SetXY().

virtual void Sprite::SetXY ( s16  NewX = 0,
s16  NewY = 0 
) [virtual]

Reimplemented from ScreenObject.

void ScreenObject::SetY ( const s16  NewY = 0  )  [inline, inherited]

References ScreenObject::Y.

Referenced by ScreenObject::SetXY().

void ScreenObject::Show (  )  [inline, inherited]

static void Sprite::ShowAll (  )  [static]

set all the sprites visible

Referenced by ShowAllSprites().

void GFX::StartAnim (  )  [inline, inherited]

start sprite auto-animation

References GFX::Anim, and GFX::LastFrameTime.

void GFX::StopAnim (  )  [inline, inherited]

References GFX::Anim, and GFX::Frame.

Referenced by GFX::SetNoFrames().

void ScreenObject::Unregister (  )  [inline, protected, inherited]

void GFX::UpdateFrame ( void   )  [protected, inherited]


Member Data Documentation

u8 GFX::Alpha [protected, inherited]

Referenced by GFX::GetAlpha(), and GFX::SetAlpha().

bool GFX::Anim [protected, inherited]

s8 GFX::AnimNoLoops [protected, inherited]

u8 GFX::FPS [protected, inherited]

Referenced by GFX::GetFPS().

u16 GFX::Frame [protected, inherited]

u16 GFX::H [protected, inherited]

Referenced by GFX::GetHeight(), and GFX::SetNoFrames().

u32 GFX::LastFrameTime [protected, inherited]

Referenced by GFX::StartAnim().

u32 ScreenObject::LastMoveTime [protected, inherited]

last (SDL) time when position changed

Referenced by ScreenObject::ScreenObject(), ScreenObject::SetVX(), and ScreenObject::SetVY().

u8 GFX::NoFrames [protected, inherited]

SDL_Surface* GFX::OriginalSurface [protected, inherited]

Referenced by GFX::Clone().

u16 ScreenObject::Prio [protected, inherited]

MultisetSortedByPrio::const_iterator ScreenObject::ROs_Pos [protected, inherited]

bool GFX::RotZoomEnabled [protected, inherited]

Referenced by GFX::Clone().

SDL_Surface* GFX::Surface [protected, inherited]

SDL_Color GFX::Transparent [protected, inherited]

Referenced by GFX::GetTrans(), and GFX::SetTrans().

bool ScreenObject::Visible [protected, inherited]

if false makes the object invisible. Can be useful in a lot of situations...

Referenced by ScreenObject::isVisible(), ScreenObject::ScreenObject(), ScreenObject::SetVisible(), and ScreenObject::~ScreenObject().

s16 ScreenObject::VX [protected, inherited]

s16 ScreenObject::VY [protected, inherited]

u16 GFX::W [protected, inherited]

Referenced by GFX::GetWidth(), and GFX::SetNoFrames().

s16 ScreenObject::X [protected, inherited]

s16 ScreenObject::Y [protected, inherited]

current screen position (pixel coords) for Sprites and Banners. For BGs indicate current scrolling position (the upper-left corner).

Referenced by ScreenObject::GetY(), ScreenObject::ScreenObject(), and ScreenObject::SetY().


The documentation for this class was generated from the following file:

Generated on Tue May 12 09:01:35 2009 for libmSDL by  doxygen 1.5.9