mSDL::GFX Class Reference

A graphic object. It handles surfaces manipulation and animation. More...

Inheritance diagram for mSDL::GFX:

mSDL::ScreenObject mSDL::Banner mSDL::BG mSDL::Sprite

List of all members.

Public Member Functions

 GFX ()
 GFX (const std::string Filename, const SDL_Color InitTransparent=NONE, const u16 InitNoFrames=1)
 GFX (SDL_Surface *InitSurface, const SDL_Color InitTransparent=NONE, const u16 InitNoFrames=1)
 GFX (SDL_Color InitColor, u16 Width=Screen->w, u16 Height=Screen->h)
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)

Protected Member Functions

void UpdateFrame (void)
SDL_Rect GetFrameRect () const

Protected Attributes

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


Detailed Description

A graphic object. It handles surfaces manipulation and animation.

Constructor & Destructor Documentation

mSDL::GFX::GFX (  )  [inline]

default constructor: create an empty/invisible surface

mSDL::GFX::GFX ( const std::string  Filename,
const SDL_Color  InitTransparent = NONE,
const u16  InitNoFrames = 1 
) [inline]

most-used constructor: load a surface from a graphic file (only BMPs are supported, use SDL_image and the second constructor to load other image formats)

mSDL::GFX::GFX ( SDL_Surface *  InitSurface,
const SDL_Color  InitTransparent = NONE,
const u16  InitNoFrames = 1 
) [inline]

alternative constructor no.1: uses a given SDL_Surface NOTE: InitSurface is copied and can be safely fred after invocation.

mSDL::GFX::GFX ( SDL_Color  InitColor,
u16  Width = Screen->w,
u16  Height = Screen->h 
) [inline]

alternative constructor no.2: create an empty surface of given dimensions (default is screen size) and fills it with a solid color


Member Function Documentation

GFX mSDL::GFX::Clone ( void   )  const [inline]

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

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

u8 mSDL::GFX::GetAlpha (  )  const [inline]

u8 mSDL::GFX::GetFPS (  )  [inline]

u16 mSDL::GFX::GetFrame (  )  const [inline]

get current frame number (count starts from 0)

SDL_Rect mSDL::GFX::GetFrameRect (  )  const [protected]

u16 mSDL::GFX::GetHeight (  )  const [inline]

u8 mSDL::GFX::GetNoFrames (  )  [inline]

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

SDL_Surface* mSDL::GFX::GetSurface (  )  const [inline]

return the associated SDL Surface for direct manipulation

SDL_Color mSDL::GFX::GetTrans ( void   )  const [inline]

u16 mSDL::GFX::GetWidth (  )  const [inline]

bool mSDL::GFX::isAnim (  )  const [inline]

return true if playing animation

void mSDL::GFX::PauseAnim (  )  [inline]

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

saves this graphical surface into a BMP file.

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

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

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

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

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

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

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

NewSurface is copied and can be safely fred after invocation.

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

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

void mSDL::GFX::StartAnim (  )  [inline]

start sprite auto-animation

void mSDL::GFX::StopAnim (  )  [inline]

void mSDL::GFX::UpdateFrame ( void   )  [protected]


Member Data Documentation

u8 mSDL::GFX::Alpha [protected]

bool mSDL::GFX::Anim [protected]

u8 mSDL::GFX::FPS [protected]

u16 mSDL::GFX::Frame [protected]

u16 mSDL::GFX::H [protected]

u8 mSDL::GFX::NoFrames [protected]

SDL_Surface* mSDL::GFX::OriginalSurface [protected]

bool mSDL::GFX::RotZoomEnabled [protected]

SDL_Surface* mSDL::GFX::Surface [protected]

SDL_Color mSDL::GFX::Transparent [protected]

u16 mSDL::GFX::W [protected]


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