OpenVideo Documentation

   Main Page       Modules       Class Hierarchy       Alphabetical List       Compound List       File List       Compound Members       Related Pages   

game.h

Go to the documentation of this file.
00001 
00002 //
00003 // PocketHAL
00004 // Copyright 2004 by Thierry Tremblay
00005 //
00007 
00008 #ifndef POCKETHAL_GAME_H
00009 #define POCKETHAL_GAME_H
00010 
00011 #include <PocketHAL/PocketHAL.h>
00012 #include "Win32/GameBase.h"
00013 
00014 
00015 
00016 namespace PHAL
00017 {
00018 
00019 class Display;
00020 
00021 
00023 //
00024 // Game
00025 //
00027 
00028 class Game : public GameBase
00029 {
00030 public:
00031 
00032     Game();
00033     ~Game();
00034 
00035     // Start running the game, returns false if initialization failed.
00036     bool Run();
00037 
00038 
00039 protected:
00040 
00041     // Get access to the display
00042     Display* GetDisplay()   { return m_display; }
00043 
00044     // Shutdown the game
00045     void Shutdown();
00046 
00047 
00048     // Game callbacks
00049     virtual bool OnInitialize();            // Return true or false depending on success
00050     virtual void OnShutdown();              // Game is shutting down, game loop won't be called again
00051     virtual bool OnGameLoop();              // Game loop, return true to continue running or false to shutdown
00052     virtual void OnSuspend();               // Game is suspended (ex: in the background)
00053     virtual void OnResume();                // Game can resume
00054 
00055     // Keys/button press/release events
00056     virtual void OnKeyDown( int key );      // A key was pressed
00057     virtual void OnKeyUp( int key );        // A key was released
00058 
00059     // Stylus events
00060     virtual void OnStylusDown( Point p );   // The stylus/pointer is down
00061     virtual void OnStylusMove( Point p );   // The stylus/pointer is moving
00062     virtual void OnStylusUp( Point p );     // The stylus/pointer is up
00063 
00064 
00065 protected:
00066     
00067     // Data
00068     Config      m_config;       // Configuration
00069 
00070     // Retrieve the FPS string
00071     const char* GetFPSString() const    { return m_fpsString; }
00072 
00073 
00074 private:
00075 
00076     // Initialize the framework
00077     bool Initialize();
00078 
00079     // Build the FPS string
00080     void BuildFPSString( int fps );
00081 
00082     // Data
00083     bool        m_bShutdown;            // Shutdown?
00084     Display*    m_display;              // Display
00085     uint32_t    m_lastInactivityReset;  // Last time we resetted inactivity
00086 
00087     // FPS related variables
00088     uint32_t    m_lastFPSTime;          // Clock time used to calculate fps
00089     uint32_t    m_nbFrames;             // Number of frames rendered
00090     int         m_fps;                  // Frame per second (*100)
00091     char        m_fpsString[7];         // FPS string
00092 };
00093 
00094 
00095 
00096 } // end of namespace PHAL
00097 
00098 
00099 
00100 #endif
 This page was generated at Wed May 31 13:04:16 2006 for OpenVideo by Doxygen.
 If you have any comments, please send a message to schmalstieg@icg.tu-graz.ac.at.
www.studierstube.org