-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
game's main loop added, glut removed from vs sample project
- Loading branch information
Showing
17 changed files
with
23,106 additions
and
22,143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "SEGameLoop.h" | ||
#include "SEGameLoopEngineConstantGameSpeedMaximumFPS.h" | ||
|
||
|
||
SEGameLoopPtr SEGameLoop::mInstance; | ||
|
||
SEGameLoop::SEGameLoop(void) | ||
{ | ||
} | ||
|
||
SEGameLoop::~SEGameLoop(void) | ||
{ | ||
} | ||
|
||
SEGameLoopPtr SEGameLoop::sharedInstance() | ||
{ | ||
if( mInstance.get() == 0 ) | ||
{ | ||
mInstance = SEGameLoopPtr( SENewObject<SEGameLoop>() ); | ||
} | ||
|
||
return mInstance; | ||
} | ||
|
||
void SEGameLoop::Run() | ||
{ | ||
if( mEngine.get() == NULL ) | ||
{ | ||
mEngine = SEGameLoopEngineInterfacePtr( SENewObject<SEGameLoopEngineConstantGameSpeedMaximumFPS>() ); | ||
} | ||
|
||
mEngine->Run(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
#ifndef SEGameLoop_H | ||
#define SEGameLoop_H | ||
|
||
|
||
#include "SEGameLoopEngineInterface.h" | ||
#include "SEIncludeLibrary.h" | ||
|
||
class SEGameLoop; | ||
|
||
typedef shared_ptr<SEGameLoop> SEGameLoopPtr; | ||
|
||
class SEGameLoop | ||
{ | ||
static SEGameLoopPtr mInstance; | ||
SEGameLoopEngineInterfacePtr mEngine; | ||
|
||
public: | ||
SEGameLoop(void); | ||
~SEGameLoop(void); | ||
|
||
static SEGameLoopPtr sharedInstance(); | ||
void Run(); | ||
}; | ||
|
||
#endif SEGameLoop_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "SEGameLoopEngineConstantGameSpeedMaximumFPS.h" | ||
#include "SEPhysicWorld.h" | ||
|
||
SEGameLoopEngineConstantGameSpeedMaximumFPS::SEGameLoopEngineConstantGameSpeedMaximumFPS(void) | ||
{ | ||
} | ||
|
||
SEGameLoopEngineConstantGameSpeedMaximumFPS::~SEGameLoopEngineConstantGameSpeedMaximumFPS(void) | ||
{ | ||
} | ||
|
||
void SEGameLoopEngineConstantGameSpeedMaximumFPS::Run() | ||
{ | ||
static const int TICKS_PER_SECOND = 50; | ||
static const int SKIP_TICKS = 1000 / TICKS_PER_SECOND; | ||
static const int MAX_FRAMESKIP = 10; | ||
|
||
static DWORD next_game_tick = GetTickCount(); | ||
int loops; | ||
|
||
{ | ||
loops = 0; | ||
while( GetTickCount() > next_game_tick && loops < MAX_FRAMESKIP) | ||
{ | ||
SEPhysicWorld::sharedInstance()->world()->stepSimulation(1.0/25.0,1); | ||
|
||
next_game_tick += SKIP_TICKS; | ||
loops++; | ||
} | ||
|
||
SEPhysicWorld::sharedInstance()->Draw(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
#ifndef SEGameLoopEngineConstantGameSpeedMaximumFPS_H | ||
#define SEGameLoopEngineConstantGameSpeedMaximumFPS_H | ||
|
||
#include "SEGameLoopEngineInterface.h" | ||
|
||
// | ||
//Realization of "Constant Game Speed with Maximum FPS" | ||
//http://dewitters.koonsolo.com/gameloop.html | ||
// | ||
class SEGameLoopEngineConstantGameSpeedMaximumFPS: public SEGameLoopEngineInterface | ||
{ | ||
public: | ||
SEGameLoopEngineConstantGameSpeedMaximumFPS(void); | ||
virtual ~SEGameLoopEngineConstantGameSpeedMaximumFPS(void); | ||
|
||
virtual void Run(); | ||
}; | ||
|
||
|
||
#endif SEGameLoopEngineConstantGameSpeedMaximumFPS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include "SEGameLoopEngineInterface.h" | ||
|
||
SEGameLoopEngineInterface::SEGameLoopEngineInterface(void) | ||
{ | ||
} | ||
|
||
SEGameLoopEngineInterface::~SEGameLoopEngineInterface(void) | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
#ifndef SEGameLoopEngineInterface_H | ||
#define SEGameLoopEngineInterface_H | ||
|
||
#include "SEIncludeLibrary.h" | ||
|
||
class SEGameLoopEngineInterface; | ||
|
||
typedef shared_ptr<SEGameLoopEngineInterface> SEGameLoopEngineInterfacePtr; | ||
|
||
class SEGameLoopEngineInterface | ||
{ | ||
public: | ||
SEGameLoopEngineInterface(void); | ||
virtual ~SEGameLoopEngineInterface(void); | ||
|
||
virtual void Run()=0; | ||
}; | ||
|
||
|
||
#endif SEGameLoopEngineInterface_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.