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

/include/ZE_ZEngine.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002         This file is Part of the ZEngine Library for 2D game development.
00003                    Copyright (C) 2002, 2003 James Turk
00004 
00005                      Licensed under a BSD-style license.
00006 
00007     The maintainer of this library is James Turk (james@conceptofzero.net) 
00008      and the home of this Library is http://www.zengine.sourceforge.net
00009 *******************************************************************************/
00010 
00024 #ifndef __ze_zengine_h__
00025 #define __ze_zengine_h__
00026 
00027 #include "ZE_Error.h"
00028 #include "ZE_Defines.h"
00029 #include "ZE_Macros.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 CreateDisplay(string title, string icon="");
00147 
00153         void CloseDisplay();
00154 
00156     //Screen Access//
00158 
00159     private:
00161         SDL_Surface *mScreen;
00162 
00163     public:
00170         SDL_Surface *Display();
00171 
00177         void Update();
00178 
00188         void Clear(float red=0.0f, float green=0.0f, float blue=0.0f, float alpha=1.0f);
00189 
00191     //OpenGL Specific Functions//
00193     public:
00194 
00201         void SetGL2D();
00202 
00204     //Timer and Framerate Independent Movement//
00206     
00207     private:
00209         bool mPaused;
00211         bool mUnpauseOnActive;
00213         Uint32 mLastPause;
00215         Uint32 mPausedTime;
00217         Uint32 mLastTime;
00219         double mSecPerFrame;
00220 
00221     public:
00228         void Delay(Uint32 milliseconds);
00229 
00236         Uint32 GetTime();
00237 
00243         void PauseTimer();
00244 
00250         void UnpauseTimer();
00251 
00258         double GetFrameTime();
00259 
00266         bool IsPaused();
00267 
00269     //Event and Input Handling//
00271     private:
00273         bool mNeedReload;
00275         bool mActive;
00277         bool mQuit;
00279         Uint8 *mKeyIsPressed;
00281         bool mKeyPress[SDLK_LAST];
00283         int mMouseX;
00285         int mMouseY;
00287         Uint8 mMouseB;
00288 
00289     public:
00296         bool IsActive();
00297 
00304         void RequestQuit();
00305 
00313         bool QuitRequested();
00314 
00319         void SetReloadNeed(bool state);
00320 
00328         bool ImagesNeedReload();
00329         
00339         void SetKeyRepeatRate(int rate);
00340 
00348         bool KeyIsPressed(SDLKey key);
00349 
00357         bool KeyPress(SDLKey key);
00358 
00364         void HideCursor();
00365 
00371         void ShowCursor();
00372 
00379         int MouseX();
00380 
00387         int MouseY();
00388 
00395         bool LButtonPressed();
00396 
00403         bool RButtonPressed();
00404 
00412         bool MouseInRect(SDL_Rect *rect);
00413 
00419         void CheckEvents();
00420 
00421 #ifdef USE_PHYSFS
00422 
00423     //Physfs Utilities//
00425     public:
00432         void InitPhysFS(string argv);
00433 
00440         void AddPhysFSDir(string dir);
00441 
00442 #endif    //USE_PHYSFS
00443 
00444 
00446     //Data Loading + Unloading//
00448     public:
00456         SDL_Surface* LoadImage(string filename);
00457 
00458 #ifdef USE_SDL_MIXER
00459 
00466         Mix_Chunk* LoadSound(string filename);
00467 
00475         Mix_Music* LoadMusic(string filename);
00476 #endif
00477 
00478 #ifdef USE_SDL_TTF
00479 
00487         TTF_Font* LoadFont(string filename, int size);
00488 #endif 
00489 
00491     //Accessors//
00493 
00494     public:    
00501         int Width();
00502 
00509         int Height();
00510 
00517         int BPP();
00518 
00525         bool IsFullscreen();
00526 };
00527 
00528 }
00529 
00530 #endif //__ze_zengine_h__

Generated on Sun Dec 29 02:21:35 2002 for ZEngine by doxygen1.3-rc2