ScreenObject Class Reference

A screen object. It handles objects positioning and drawing on screen. More...

Inheritance diagram for ScreenObject:

GFX Banner BG Sprite

List of all members.

Public Member Functions

bool isVisible ()
void SetVisible (bool b=true)
void Show ()
void Hide ()
u16 GetPrio () const
 return the object priority
virtual void SetPrio (const u16 NewPrio)
 change the object priority (the higher the most on top)
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)
virtual void SetXY (const s16 NewX=0, 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
virtual void Draw (void)
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 DrawAll (void)

Protected Types

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

Protected Member Functions

 ScreenObject ()
 ~ScreenObject ()
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

A screen object. It handles objects positioning and drawing on screen.

Member Typedef Documentation

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


Constructor & Destructor Documentation

ScreenObject::ScreenObject (  )  [inline, protected]

References LastMoveTime, Visible, VX, VY, X, and Y.

ScreenObject::~ScreenObject (  )  [inline, protected]

References Unregister(), and Visible.


Member Function Documentation

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

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

References GetCenterX(), and GetCenterY().

Referenced by Angle().

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

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

Circular collision checker (member version).

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

Referenced by CollisionCirc().

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

Rectangular collision checker (member version).

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

Referenced by CollisionRect().

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

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

References GetCenterX(), and GetCenterY().

Referenced by Distance().

virtual void ScreenObject::Draw ( void   )  [virtual]

Reimplemented in Banner, BG, and Sprite.

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

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]

Return the center's X coordinate of the object.

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

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

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

Return the center's Y coordinate of the object.

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

Referenced by Angle(), CollisionCirc(), CollisionRect(), and 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]

References GFX::H.

Referenced by CollisionRect(), and GetCenterY().

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]

References GetX(), and GetY().

u16 ScreenObject::GetPrio (  )  const [inline]

return the object priority

References 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]

return the horizontal object velocity

References VX.

s16 ScreenObject::GetVY (  )  const [inline]

return the vertical object velocity

References VY.

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

References GFX::W.

Referenced by CollisionCirc(), CollisionRect(), and GetCenterX().

s16 ScreenObject::GetX (  )  const [inline]

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

References X.

Referenced by GetCenterX(), and GetPosition().

s16 ScreenObject::GetY (  )  const [inline]

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

References Y.

Referenced by GetCenterY(), and GetPosition().

void ScreenObject::Hide (  )  [inline]

References SetVisible().

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

return true if playing animation

References GFX::Anim.

bool ScreenObject::isMoving (  )  const [inline]

References VX, and VY.

bool ScreenObject::isVisible (  )  [inline]

References Visible.

void ScreenObject::Move ( void   )  [protected]

change object's position according to current velocities

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

References GFX::Anim.

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

References RegisteredScreenObjects, and ROs_Pos.

Referenced by Banner::Banner(), and SetPrio().

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 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 ScreenObject::SetPrio ( const u16  NewPrio  )  [inline, virtual]

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

Reimplemented in Banner, BG, and Sprite.

References Prio, Register(), and Unregister().

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]

References Visible.

Referenced by Hide(), and Show().

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

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

References LastMoveTime, and VX.

Referenced by SetVXY().

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

References SetVX(), and SetVY().

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

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

References LastMoveTime, and VY.

Referenced by SetVXY().

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

References X.

Referenced by SetXY().

virtual void ScreenObject::SetXY ( const s16  NewX = 0,
const s16  NewY = 0 
) [inline, virtual]

Reimplemented in Sprite.

References SetX(), and SetY().

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

References Y.

Referenced by SetXY().

void ScreenObject::Show (  )  [inline]

References SetVisible().

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]

References RegisteredScreenObjects, and ROs_Pos.

Referenced by SetPrio(), and ~ScreenObject().

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]

last (SDL) time when position changed

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

u8 GFX::NoFrames [protected, inherited]

SDL_Surface* GFX::OriginalSurface [protected, inherited]

Referenced by GFX::Clone().

u16 ScreenObject::Prio [protected]

Referenced by Banner::Banner(), GetPrio(), and SetPrio().

Referenced by Register(), and Unregister().

MultisetSortedByPrio::const_iterator ScreenObject::ROs_Pos [protected]

Referenced by Register(), and Unregister().

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]

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

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

s16 ScreenObject::VX [protected]

Referenced by GetVX(), isMoving(), ScreenObject(), and SetVX().

s16 ScreenObject::VY [protected]

velocities (in pixel/sec)

Referenced by GetVY(), isMoving(), ScreenObject(), and SetVY().

u16 GFX::W [protected, inherited]

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

s16 ScreenObject::X [protected]

Referenced by GetX(), ScreenObject(), and SetX().

s16 ScreenObject::Y [protected]

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

Referenced by GetY(), ScreenObject(), and 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