1
0
Fork 0
mirror of https://github.com/bjornbytes/lovr.git synced 2024-07-11 16:33:35 +00:00
lovr/src/api/physics.c

29 lines
657 B
C
Raw Normal View History

2017-05-16 04:59:53 +00:00
#include "api/lovr.h"
#include "physics/physics.h"
int l_lovrPhysicsInit(lua_State* L) {
lua_newtable(L);
luaL_register(L, NULL, lovrPhysics);
2017-05-16 05:02:08 +00:00
luax_registertype(L, "World", lovrWorld);
2017-05-16 05:09:32 +00:00
luax_registertype(L, "Body", lovrBody);
2017-05-16 04:59:53 +00:00
lovrPhysicsInit();
return 1;
}
2017-05-16 05:02:08 +00:00
int l_lovrPhysicsNewWorld(lua_State* L) {
luax_pushtype(L, World, lovrWorldCreate());
return 1;
}
2017-05-16 05:09:32 +00:00
int l_lovrPhysicsNewBody(lua_State* L) {
World* world = luax_checktype(L, 1, World);
luax_pushtype(L, Body, lovrBodyCreate(world));
return 1;
}
2017-05-16 04:59:53 +00:00
const luaL_Reg lovrPhysics[] = {
2017-05-16 05:02:08 +00:00
{ "newWorld", l_lovrPhysicsNewWorld },
2017-05-16 05:09:32 +00:00
{ "newBody", l_lovrPhysicsNewBody },
2017-05-16 04:59:53 +00:00
{ NULL, NULL }
};