mirror of
https://github.com/love2d/love.git
synced 2026-08-19 12:14:20 +02:00
love.physics.newWorld now acts like it's supposed to and adheres to the documentation
This commit is contained in:
@@ -31,29 +31,31 @@ namespace box2d
|
|||||||
|
|
||||||
int w_newWorld(lua_State * L)
|
int w_newWorld(lua_State * L)
|
||||||
{
|
{
|
||||||
if(lua_gettop(L) == 2)
|
switch(lua_gettop(L))
|
||||||
{
|
{
|
||||||
float x = (float)luaL_checknumber(L, 1);
|
case 2:
|
||||||
float y = (float)luaL_checknumber(L, 2);
|
float x = (float)luaL_checknumber(L, 1);
|
||||||
World * w = instance->newWorld(x, y);
|
float y = (float)luaL_checknumber(L, 2);
|
||||||
luax_newtype(L, "World", PHYSICS_WORLD_T, (void*)w);
|
World * w = instance->newWorld(x, y);
|
||||||
return 1;
|
luax_newtype(L, "World", PHYSICS_WORLD_T, (void*)w);
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
case 6:
|
||||||
|
case 7:
|
||||||
|
float lx = (float)luaL_checknumber(L, 1);
|
||||||
|
float ly = (float)luaL_checknumber(L, 2);
|
||||||
|
float ux = (float)luaL_checknumber(L, 3);
|
||||||
|
float uy = (float)luaL_checknumber(L, 4);
|
||||||
|
float gx = (float)luaL_checknumber(L, 5);
|
||||||
|
float gy = (float)luaL_checknumber(L, 6);
|
||||||
|
bool sleep = luax_optboolean(L, 7, true);
|
||||||
|
World * w = instance->newWorld(lx, ly, ux, uy, gx, gy, sleep);
|
||||||
|
luax_newtype(L, "World", PHYSICS_WORLD_T, (void*)w);
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return luaL_error(L, "Incorrect number of parameters");
|
||||||
}
|
}
|
||||||
else if(lua_gettop(L) == 6)
|
|
||||||
{
|
|
||||||
float lx = (float)luaL_checknumber(L, 1);
|
|
||||||
float ly = (float)luaL_checknumber(L, 2);
|
|
||||||
float ux = (float)luaL_checknumber(L, 3);
|
|
||||||
float uy = (float)luaL_checknumber(L, 4);
|
|
||||||
float gx = (float)luaL_checknumber(L, 5);
|
|
||||||
float gy = (float)luaL_checknumber(L, 6);
|
|
||||||
bool sleep = luax_toboolean(L, 7);
|
|
||||||
World * w = instance->newWorld(lx, ly, ux, uy, gx, gy, sleep);
|
|
||||||
luax_newtype(L, "World", PHYSICS_WORLD_T, (void*)w);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return luaL_error(L, "Incorrect number of parameters");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_newBody(lua_State * L)
|
int w_newBody(lua_State * L)
|
||||||
|
|||||||
Reference in New Issue
Block a user