GFX Class Reference

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

Inheritance diagram for GFX:

ScreenObject Banner BG 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

GFX::GFX (  )  [inline]

default constructor: create an empty/invisible surface

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)

References SetNoFrames(), SetTrans(), and Surface.

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.

References SetNoFrames(), SetSurface(), and SetTrans().

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

References mSDL::Screen, SetNoFrames(), and Surface.


Member Function Documentation

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

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

References DrawRect(), SetPixel(), and Surface.

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

References Surface.

Referenced by DrawLine().

u8 GFX::GetAlpha (  )  const [inline]

References Alpha.

u8 GFX::GetFPS (  )  [inline]

References FPS.

u16 GFX::GetFrame (  )  const [inline]

get current frame number (count starts from 0)

References Frame.

SDL_Rect GFX::GetFrameRect (  )  const [protected]

u16 GFX::GetHeight (  )  const [inline]

u8 GFX::GetNoFrames (  )  [inline]

References NoFrames.

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

References Surface.

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

return the associated SDL Surface for direct manipulation

References Surface.

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

References Transparent.

u16 GFX::GetWidth (  )  const [inline]

bool GFX::isAnim (  )  const [inline]

return true if playing animation

References Anim.

void GFX::PauseAnim (  )  [inline]

References Anim.

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

saves this graphical surface into a BMP file.

References Surface.

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

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

References Alpha, and Surface.

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

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

References Frame, and NoFrames.

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

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

Referenced by GFX().

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

References Surface.

Referenced by DrawLine().

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

NewSurface is copied and can be safely fred after invocation.

References Surface.

Referenced by GFX().

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

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

References Surface, and Transparent.

Referenced by GFX().

void GFX::StartAnim (  )  [inline]

start sprite auto-animation

References Anim, and LastFrameTime.

void GFX::StopAnim (  )  [inline]

References Anim, and Frame.

Referenced by SetNoFrames().

void GFX::UpdateFrame ( void   )  [protected]


Member Data Documentation

u8 GFX::Alpha [protected]

Referenced by GetAlpha(), and SetAlpha().

bool GFX::Anim [protected]

Referenced by isAnim(), PauseAnim(), StartAnim(), and StopAnim().

s8 GFX::AnimNoLoops [protected]

u8 GFX::FPS [protected]

Referenced by GetFPS().

u16 GFX::Frame [protected]

Referenced by GetFrame(), SetFrame(), and StopAnim().

u16 GFX::H [protected]

Referenced by GetHeight(), and SetNoFrames().

u32 GFX::LastFrameTime [protected]

Referenced by StartAnim().

u8 GFX::NoFrames [protected]

Referenced by GetNoFrames(), SetFrame(), and SetNoFrames().

SDL_Surface* GFX::OriginalSurface [protected]

Referenced by Clone().

bool GFX::RotZoomEnabled [protected]

Referenced by Clone().

SDL_Surface* GFX::Surface [protected]

SDL_Color GFX::Transparent [protected]

Referenced by GetTrans(), and SetTrans().

u16 GFX::W [protected]

Referenced by GetWidth(), and SetNoFrames().


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