Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ZE::ZEngine Class Reference

#include <ZE_ZEngine.h>

List of all members.


Detailed Description

ZEngine Singleton Class, accessible from anywhere in a ZEngine-based program by nature. Controls core elements of program and does majority of SDL wrapping. Also keeps track of loaded data and helps programs avoid memory leaks and dangling pointers.


Public Methods

void SetupDisplay (int width, int height, int bpp, bool fullscreen)
 Setup Display for SDL.

void SetupSound (int rate, bool stereo)
 Initialize Sound for SDL.

void CreateWindow (string title, string icon="")
 Create Window with predefined settings.

void CloseWindow ()
 Quit SDL and any Subsystems.

SDL_Surface * GetDisplay ()
 Allow access to Screen Surface.

void UpdateScreen ()
 Update screen contents.

Uint32 MapColor (Uint8 r, Uint8 g, Uint8 b, Uint8 a=255)
 Create Color in SDL Uint32 Format.

void Clear (Uint32 color=0, SDL_Rect *rect=NULL)
 Clear screen or portion of screen to a color.

void Sleep (Uint32 milliseconds)
 Sleep for a certain amount of time.

Uint32 GetTime ()
 Get Global ZEngine time.

void PauseTimer ()
 Pause ZEngine.

void UnpauseTimer ()
 Unpause ZEngine.

double GetFrameTime ()
 Get Seconds Per Frame.

bool IsPaused ()
 Check Engine Paused State.

bool IsActive ()
 Find out if application is active.

void RequestQuit ()
 Request A Quit.

bool QuitRequested ()
 Find out if user has requested to quit.

bool KeyIsPressed (SDLKey key)
 Find the state of a key.

void HideCursor ()
 Hide mouse cursor.

void ShowCursor ()
 Show mouse cursor.

int GetMouseX ()
 Get X Position of Mouse.

int GetMouseY ()
 Get Y Position of Mouse.

bool LButtonPressed ()
 Get Status of Left Button.

bool RButtonPressed ()
 Get Status of Right Button.

bool MouseInRect (SDL_Rect *rect)
 Check if mouse is in given rectangle.

void CheckEvents ()
 Check for Activation, Window Manager, and Quit Events.

ImageData LoadImage (string filename)
 Load an Image.

void FreeImage (ImageData &image)
 Free an Image.

SoundData LoadSound (string filename)
 Load a Sound.

void FreeSound (SoundData &sound)
 Free a Sound.

MusicData LoadMusic (string filename)
 Load a Music File.

void FreeMusic (MusicData &music)
 Free a Music Sample.

FontData LoadFont (string filename, int size)
 Load a Font.

void FreeFont (FontData &font)
 Free a Font.

int GetWidth ()
 Get Current Display Width.

int GetHeight ()
 Get Current Display Height.

int GetBPP ()
 Get Current Display BPP.

bool IsFullscreen ()
 Get Fullscreen setting.


Static Public Methods

ZEngine * GetInstance ()
 Get Instance.

void ReleaseInstance ()
 Release Instance.

string GetVersion ()
 Get Current Version.


Private Methods

 ZEngine ()
 Constructor for ZEngine.


Private Attributes

int mWidth
 Width of Display.

int mHeight
 Height of Display.

int mBPP
 BPP Setting of Display.

bool mFullscreen
 Fullscreen setting of Display.

int mRate
 Sound Bitrate.

bool mStereo
 Stereo setting of Sound Subsystem.

SDL_Surface * mScreen
 Pointer to Display.

bool mPaused
 Keep track of paused state of game.

bool mUnpauseOnActive
 Keep track of if ZEngine should unpause on active event.

Uint32 mLastPause
 Keep track of time game was last paused.

Uint32 mPausedTime
 Keep track of total globally paused time.

Uint32 mLastTime
 Keep track of last screen update time.

double mSecPerFrame
 Seconds per frame.

bool mActive
 bool describing Active or Inactive State of Game

bool mQuit
 bool for checking if a Quit event has been detected

Uint8 * mKeyPressed
 Pointer to array of Keys.

int mMouseX
 X Position of Mouse.

int mMouseY
 Y Position of Mouse.

Uint8 mMouseB
 Mouse Button Information.


Static Private Attributes

ZEngine * sInstance = NULL
 Static Pointer to Instance of ZEngine for Singleton.


Constructor & Destructor Documentation

ZE::ZEngine::ZEngine   [private]
 

Initialize ZEngine values to defaults. (Private so that only one instance may be created.)


Member Function Documentation

ZEngine * ZE::ZEngine::GetInstance   [static]
 

Static function, returns pointer to instance of ZEngine, creating an instance if none exist.

Returns:
Instance to the ZEngine.

void ZE::ZEngine::ReleaseInstance   [static]
 

Release memory held by instance of engine and closes window.

string ZE::ZEngine::GetVersion   [static]
 

Get Version Number of ZEngine. (Major.Minor.Extension#)

Returns:
string containing version number

void ZE::ZEngine::SetupDisplay int    width,
int    height,
int    bpp,
bool    fullscreen
 

Sets display parameters to specified parameters. (called before CreateDisplay)

Parameters:
width Desired width of screen or window.
height Desired height of screen or window.
bpp Desired BPP for screen (only works in fullscreen).
fullscreen A bool for fullscreen setting.

void ZE::ZEngine::SetupSound int    rate,
bool    stereo
 

Set sound settings to specified parameters. (called before CreateDisplay)

Parameters:
rate Desired sound bitrate.
stereo A bool for stereo setting.

void ZE::ZEngine::CreateWindow string    title,
string    icon = ""
 

SetupDisplay and SetupSound should be called prior to this to change settings, settings from those do not go into effect until this function is called. Specify no icon file to use default OS icon.

Parameters:
title Window Title.
icon Path to Icon File.

void ZE::ZEngine::CloseWindow  
 

Shut down SDL (and SDL_ttf,SDL_mixer if necessary).

SDL_Surface * ZE::ZEngine::GetDisplay  
 

Get pointer to screen SDL_Surface, allowing direct screen manipulation using SDL.

Returns:
Pointer to Display Surface.

void ZE::ZEngine::UpdateScreen  
 

Flip double buffer in SDL if double buffered, otherwise tell video to refresh entire screen.

Uint32 ZE::ZEngine::MapColor Uint8    r,
Uint8    g,
Uint8    b,
Uint8    a = 255
 

Turn RGBA values into SDL Uint32 color. (Alpha value will be ignored if not in use)

Parameters:
r Red component of color (0-255).
g Green component of color (0-255).
b Blue component of color (0-255).
a Alpha (translucency) component of color (0-255). [Default 255]
Returns:
Uint32 of color requested.

void ZE::ZEngine::Clear Uint32    color = 0,
SDL_Rect *    rect = NULL
 

Clears a rectangle on screen to a color.

Parameters:
color Color to clear surface to, defaults to black.
rect Rectangle of screen to clear or NULL for entire surface.

void ZE::ZEngine::Sleep Uint32    milliseconds
 

Freeze everything for given number of milliseconds.

Parameters:
milliseconds Number of milliseconds to freeze.

Uint32 ZE::ZEngine::GetTime  
 

Get active time since ZEngine initialization in milliseconds, paused time doesn't count.

Returns:
Number of active milliseconds since initialization.

void ZE::ZEngine::PauseTimer  
 

Pause ZEngine timer and all ZTimer objects that rely on ZEngine.

void ZE::ZEngine::UnpauseTimer  
 

Unpause ZEngine timer and all ZTimer objects that rely on ZEngine.

double ZE::ZEngine::GetFrameTime  
 

Get double that describes the time passed between screen updates. (used for Framerate Independant Movement)

Returns:
Time between screen updates.

bool ZE::ZEngine::IsPaused  
 

Find out if engine timer is paused.

Returns:
Paused State of engine.

bool ZE::ZEngine::IsActive  
 

Function to find out if application currently has focus.

Returns:
bool telling active/inactive state of application.

void ZE::ZEngine::RequestQuit  
 

Tell the engine that it should behave as if a Quit was requested, does not call any shutdown functions.

bool ZE::ZEngine::QuitRequested  
 

Function to find out if user or operating system has requested program cease execution, can be set by Alt-F4, SDL_Quit event or ZEngine::RequestQuit().

Returns:
bool telling if quit has been requested.

bool ZE::ZEngine::KeyIsPressed SDLKey    key
 

Function returns true/false based on if key is pressed or not.

Parameters:
key code of key to find status of.
Returns:
bool state of requested key.

void ZE::ZEngine::HideCursor  
 

Hide the system mouse cursor.

void ZE::ZEngine::ShowCursor  
 

Show the system mouse cursor.

int ZE::ZEngine::GetMouseX  
 

Find X Position of Mouse on screen.

Returns:
X Position of Mouse.

int ZE::ZEngine::GetMouseY  
 

Find Y Position of Mouse on screen.

Returns:
Y Position of Mouse.

bool ZE::ZEngine::LButtonPressed  
 

Get pressed status of left button of mouse.

Returns:
true if left button is pressed, false otherwise.

bool ZE::ZEngine::RButtonPressed  
 

Get pressed status of right button of mouse.

Returns:
true if right button is pressed, false otherwise.

bool ZE::ZEngine::MouseInRect SDL_Rect *    rect
 

Return status of mouse in current rectangle (used for buttons)

Parameters:
rect Rectangle to check if mouse is in.
Returns:
true if mouse is in rectangle, false otherwise

void ZE::ZEngine::CheckEvents  
 

Cycle through event queue, processing events, updating all Event Related variables, should be called once per frame.

ImageData ZE::ZEngine::LoadImage string    filename
 

Loads an Image to an ImageData class which keeps vital information on the Image.

Parameters:
filename path to file to load.
Returns:
A ImageData class containing filename and pointer to data.

void ZE::ZEngine::FreeImage ImageData   image
 

Free memory of an Image in an ImageData class.

Parameters:
image ImageData structure of image to free.

SoundData ZE::ZEngine::LoadSound string    filename
 

Loads a Sound to a SoundData class which keeps vital information on the Sound

Parameters:
filename path to file to load.
Returns:
A SoundData class containing filename and pointer to data.

void ZE::ZEngine::FreeSound SoundData   sound
 

Free memory of a Sound in a SoundData class.

Parameters:
sound SoundData structure of sound to free.

MusicData ZE::ZEngine::LoadMusic string    filename
 

Loads a Music Clip to a MusicData class which keeps vital information on the Music Data

Parameters:
filename path to file to load.
Returns:
A MusicData class containing filename and pointer to data.

void ZE::ZEngine::FreeMusic MusicData   music
 

Free memory of Music in a MusicData class.

Parameters:
music MusicData structure of music to free.

FontData ZE::ZEngine::LoadFont string    filename,
int    size
 

Loads a Font to a FontData class which keeps vital information on the Font

Parameters:
filename path to file to load.
size point size of font
Returns:
A FontData class containing filename and pointer to data.

void ZE::ZEngine::FreeFont FontData   font
 

Free memory of a Font in a FontData class.

Parameters:
font FontData structure of font to free.

int ZE::ZEngine::GetWidth  
 

Get Width of Window or Fullscreen mode.

Returns:
Width of Display.

int ZE::ZEngine::GetHeight  
 

Get Height of Window or Fullscreen mode.

Returns:
Height of Display.

int ZE::ZEngine::GetBPP  
 

Get BPP of Window or Fullscreen mode.

Returns:
BPP of Display.

bool ZE::ZEngine::IsFullscreen  
 

Get Fullscreen setting of Display.

Returns:
True if Fullscreen, False if Windowed


The documentation for this class was generated from the following files:
Generated on Wed Nov 20 01:18:06 2002 for ZEngine by doxygen1.3-rc1