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

55 lines
1.5 KiB
C
Raw Normal View History

2017-05-16 05:02:08 +00:00
#include "api/lovr.h"
#include "physics/physics.h"
2017-05-16 05:03:01 +00:00
int l_lovrWorldGetGravity(lua_State* L) {
World* world = luax_checktype(L, 1, World);
float x, y, z;
lovrWorldGetGravity(world, &x, &y, &z);
lua_pushnumber(L, x);
lua_pushnumber(L, y);
lua_pushnumber(L, z);
return 3;
}
int l_lovrWorldSetGravity(lua_State* L) {
World* world = luax_checktype(L, 1, World);
float x = luaL_checknumber(L, 2);
float y = luaL_checknumber(L, 3);
float z = luaL_checknumber(L, 4);
lovrWorldSetGravity(world, x, y, z);
return 0;
}
int l_lovrWorldGetLinearDamping(lua_State* L) {
World* world = luax_checktype(L, 1, World);
float damping, threshold;
lovrWorldGetLinearDamping(world, &damping, &threshold);
lua_pushnumber(L, damping);
lua_pushnumber(L, threshold);
return 2;
}
int l_lovrWorldSetLinearDamping(lua_State* L) {
World* world = luax_checktype(L, 1, World);
float damping = luaL_checknumber(L, 2);
float threshold = luaL_optnumber(L, 3, .01);
lovrWorldSetLinearDamping(world, damping, threshold);
return 0;
}
2017-05-16 05:04:05 +00:00
int l_lovrWorldUpdate(lua_State* L) {
World* world = luax_checktype(L, 1, World);
float dt = luaL_checknumber(L, 2);
lovrWorldUpdate(world, dt);
return 0;
}
2017-05-16 05:02:08 +00:00
const luaL_Reg lovrWorld[] = {
2017-05-16 05:03:01 +00:00
{ "getGravity", l_lovrWorldGetGravity },
{ "setGravity", l_lovrWorldSetGravity },
{ "getLinearDamping", l_lovrWorldGetLinearDamping },
{ "setLinearDamping", l_lovrWorldSetLinearDamping },
2017-05-16 05:04:05 +00:00
{ "update", l_lovrWorldUpdate },
2017-05-16 05:02:08 +00:00
{ NULL, NULL }
};