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

/home/James/ZEngine-dev/include/ZE_ZEngine.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002          This file is Part of the ZEngine Library for SDL Game Development.
00003                       Copyright (C) 2002 ConceptOfZero.net
00004 
00005              Licensed under the BSD License, see licensing.txt.
00006 
00007     The maintainer of this library is James Turk (jturk@conceptofzero.net) 
00008          and the home of this Library is http://www.conceptofzero.net/
00009 *******************************************************************************/
00010 
00024 #ifndef __ze_zengine_h__
00025 #define __ze_zengine_h__
00026 
00027 #include "ZE_DataPtr.h"
00028 #include "ZE_Error.h"
00029 #include "ZE_Defines.h"
00030 #include "ZE_Includes.h"
00031 
00037 namespace ZE
00038 {
00039 
00046 class ZEngine
00047 {
00049         //Singleton + Memory Management//
00051 
00052         private:
00054                 static ZEngine *sInstance;
00055 
00061                 ZEngine();
00062 
00063         public:
00064 
00071                 static ZEngine* GetInstance();
00072 
00078                 static void ReleaseInstance();
00079 
00086                 static string GetVersion();
00087 
00089         //Initialization//
00091 
00092         private:
00094                 int mWidth;
00096                 int mHeight;
00098                 int mBPP;
00100                 bool mFullscreen;
00101 
00102 #ifdef USE_SDL_MIXER 
00103 
00104                 int mRate;
00106                 bool mStereo;
00107 #endif 
00108 
00109 
00110         public:
00111                 //add initialization
00112 
00123                 void SetupDisplay(int width, int height, int bpp, bool fullscreen);
00124 
00125 #ifdef USE_SDL_MIXER
00126 
00134                 void SetupSound(int rate, bool stereo);
00135 #endif 
00136 
00146                 void CreateWindow(string title, string icon="");
00147 
00153                 void CloseWindow();
00154 
00156         //Screen Access//
00158 
00159         private:
00161                 SDL_Surface *mScreen;
00162 
00163         public:
00170                 SDL_Surface *GetDisplay();
00171 
00177                 void UpdateScreen();
00178 
00190                 Uint32 MapColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a=255);
00191 
00199                 void Clear(Uint32 color=0, SDL_Rect *rect=NULL);
00200 
00202         //Timer and Framerate Independent Movement//
00204         
00205         private:
00207                 bool mPaused;
00209                 bool mUnpauseOnActive;
00211                 Uint32 mLastPause;
00213                 Uint32 mPausedTime;
00215                 Uint32 mLastTime;
00217                 double mSecPerFrame;
00218 
00219         public:
00226                 void Sleep(Uint32 milliseconds);
00227 
00234                 Uint32 GetTime();
00235 
00241                 void PauseTimer();
00242 
00248                 void UnpauseTimer();
00249 
00256                 double GetFrameTime();
00257 
00264                 bool IsPaused();
00265 
00267         //Event and Input Handling//
00269 
00270         private:
00272                 bool mActive;
00274                 bool mQuit;
00276                 Uint8 *mKeyPressed;
00278                 int mMouseX;
00280                 int mMouseY;
00282                 Uint8 mMouseB;
00283 
00284         public:
00291                 bool IsActive();
00292 
00299                 void RequestQuit();
00300 
00308                 bool QuitRequested();
00309                 
00317                 bool KeyIsPressed(SDLKey key);
00318 
00324                 void HideCursor();
00325 
00331                 void ShowCursor();
00332 
00339                 int GetMouseX();
00340 
00347                 int GetMouseY();
00348 
00355                 bool LButtonPressed();
00356 
00363                 bool RButtonPressed();
00364 
00372                 bool MouseInRect(SDL_Rect *rect);
00373 
00379                 void CheckEvents();
00380 
00381 #ifdef USE_PHYSFS
00382 
00383         //Physfs Utilities//
00385         public:
00392                 void InitPhysFS(string argv);
00393 
00400                 void AddPhysFSDir(string dir);
00401 
00402 #endif  //USE_PHYSFS
00403 
00404 
00406         //Data Loading + Unloading//
00408         public:
00416                 ImageData LoadImage(string filename);
00417 
00424                 void FreeImage(ImageData &image);
00425 
00426 #ifdef USE_SDL_MIXER
00427 
00434                 SoundData LoadSound(string filename);
00435 
00442                 void FreeSound(SoundData &sound);
00443 
00451                 MusicData LoadMusic(string filename);
00452 
00459                 void FreeMusic(MusicData &music);
00460 #endif
00461 
00462 #ifdef USE_SDL_TTF
00463 
00471                 FontData LoadFont(string filename, int size);
00472 
00479                 void FreeFont(FontData &font);
00480 #endif 
00481 
00483         //Accessors//
00485         
00486         public: 
00493                 int GetWidth();
00494 
00501                 int GetHeight();
00502 
00509                 int GetBPP();
00510 
00517                 bool IsFullscreen();
00518 };
00519 
00520 }
00521 
00522 #endif //__ze_zengine_h__

Generated on Wed Nov 20 01:18:05 2002 for ZEngine by doxygen1.3-rc1