Made all the examples Emscripten friendly.

cWindow::Display( bool clear = false ) now doesn't Clear by default.
Fixed a bug in cSprite::GetAABB().
This commit is contained in:
Martín Lucas Golini
2013-11-14 02:30:46 -03:00
parent d40a10a07c
commit 2e016791da
10 changed files with 314 additions and 270 deletions

View File

@@ -5,9 +5,6 @@ The physics module is a OOP wrapper for Chipmunk Physics.
To understand the conceptos of space, body, shapes, etc you can read the
Chipmunk documentation:
http://chipmunk-physics.net/release/ChipmunkLatest-Docs/
*/
typedef cb::Callback0<void> SceneCb;
@@ -608,6 +605,27 @@ void PhysicsDestroy() {
mDemo[ mCurDemo ].destroy();
}
void MainLoop()
{
mWindow->Clear();
KM->Update();
if ( KM->IsKeyDown( KEY_ESCAPE ) ) {
mWindow->Close();
}
PhysicsUpdate();
if ( KM->IsKeyUp( KEY_LEFT ) || KM->IsKeyUp( KEY_A ) ) {
ChangeDemo( mCurDemo - 1 );
} else if ( KM->IsKeyUp( KEY_RIGHT ) || KM->IsKeyUp( KEY_D ) ) {
ChangeDemo( mCurDemo + 1 );
}
mWindow->Display();
}
EE_MAIN_FUNC int main (int argc, char * argv [])
{
mWindow = cEngine::instance()->CreateWindow( WindowSettings( 1024, 768, "eepp - Physics" ), ContextSettings( true ) );
@@ -619,23 +637,7 @@ EE_MAIN_FUNC int main (int argc, char * argv [])
PhysicsCreate();
while ( mWindow->Running() ) {
KM->Update();
if ( KM->IsKeyDown( KEY_ESCAPE ) ) {
mWindow->Close();
}
PhysicsUpdate();
if ( KM->IsKeyUp( KEY_LEFT ) ) {
ChangeDemo( mCurDemo - 1 );
} else if ( KM->IsKeyUp( KEY_RIGHT ) ) {
ChangeDemo( mCurDemo + 1 );
}
mWindow->Display();
}
mWindow->RunMainLoop( &MainLoop );
PhysicsDestroy();
}