added doPhysics()
git-svn-id: svn://anubis/anaglym/trunk@48 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
fccfb572e2
commit
6a52215247
24
ag.cc
24
ag.cc
@ -24,10 +24,6 @@ namespace ag
|
||||
{ "println", println },
|
||||
{ "loadModel", loadModel },
|
||||
{ "loadStaticModel", loadStaticModel },
|
||||
#if 0
|
||||
{ "videoStart", videoStart },
|
||||
{ "videoStop", videoStop },
|
||||
#endif
|
||||
{ "sleep", sleep },
|
||||
{ "startFrame", startFrame },
|
||||
{ "endFrame", endFrame },
|
||||
@ -163,20 +159,6 @@ namespace ag
|
||||
loadModelSpecify(L, true);
|
||||
}
|
||||
|
||||
#if 0
|
||||
int videoStart(lua_State * L)
|
||||
{
|
||||
g_engine->getVideo()->start();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int videoStop(lua_State * L)
|
||||
{
|
||||
g_engine->getVideo()->stop();
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int sleep(lua_State * L)
|
||||
{
|
||||
int argc = lua_gettop(L);
|
||||
@ -218,6 +200,12 @@ namespace ag
|
||||
return 1;
|
||||
}
|
||||
|
||||
int doPhysics(lua_State * L)
|
||||
{
|
||||
g_engine->doPhysics();
|
||||
return 0;
|
||||
}
|
||||
|
||||
namespace object
|
||||
{
|
||||
static Engine::Object * getObject(lua_State * L, int index)
|
||||
|
3
ag.h
3
ag.h
@ -11,13 +11,12 @@ namespace ag
|
||||
int println(lua_State * L);
|
||||
int loadModel(lua_State * L);
|
||||
int loadStaticModel(lua_State * L);
|
||||
int videoStart(lua_State * L);
|
||||
int videoStop(lua_State * L);
|
||||
int sleep(lua_State * L);
|
||||
int startFrame(lua_State * L);
|
||||
int endFrame(lua_State * L);
|
||||
int setCamera(lua_State * L);
|
||||
int elapsedTime(lua_State * L);
|
||||
int doPhysics(lua_State * L);
|
||||
|
||||
namespace object
|
||||
{
|
||||
|
15
anaglym.cc
15
anaglym.cc
@ -267,7 +267,7 @@ Uint32 Engine::updateCallback(Uint32 interval)
|
||||
void Engine::run()
|
||||
{
|
||||
/* register a screen redrawing SDL event */
|
||||
SDL_AddTimer(20, &updateCallback, this);
|
||||
SDL_AddTimer(25, &updateCallback, this);
|
||||
|
||||
SDL_Event event;
|
||||
while (SDL_WaitEvent(&event))
|
||||
@ -333,3 +333,16 @@ void Engine::Object::getPosition(double * x, double * y, double * z)
|
||||
*z = pos[2];
|
||||
}
|
||||
}
|
||||
|
||||
void Engine::doPhysics()
|
||||
{
|
||||
static Uint32 last_updated = 0;
|
||||
Uint32 current_ticks = SDL_GetTicks();
|
||||
if (last_updated > 0)
|
||||
{
|
||||
Uint32 msec_steps = current_ticks - last_updated;
|
||||
for (int i = 0; i < msec_steps; i++)
|
||||
m_world.step();
|
||||
}
|
||||
last_updated = current_ticks;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user