mirror of
https://github.com/love2d/love.git
synced 2026-08-20 04:30:09 +02:00
Added meter parameter to newWorld
This commit is contained in:
@@ -8,6 +8,7 @@ LOVE 0.7.0
|
|||||||
* Added Font:getWrap.
|
* Added Font:getWrap.
|
||||||
* Added identity field to love.conf.
|
* Added identity field to love.conf.
|
||||||
* Added love.quit callback.
|
* Added love.quit callback.
|
||||||
|
* Added extra meter parameter to love.physics.newWorld.
|
||||||
* Enabled love.filesystem.FileData.
|
* Enabled love.filesystem.FileData.
|
||||||
* Fixed bug where the debug module was not an upvalue of the error handlers. (you can now override debug)
|
* Fixed bug where the debug module was not an upvalue of the error handlers. (you can now override debug)
|
||||||
* Fixed bug where love.audio.pause and friends were acting on everything, not just the passed Source.
|
* Fixed bug where love.audio.pause and friends were acting on everything, not just the passed Source.
|
||||||
|
|||||||
@@ -39,6 +39,14 @@ namespace box2d
|
|||||||
return "love.physics.box2d";
|
return "love.physics.box2d";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
World * Physics::newWorld(float lx, float ly, float ux, float uy, float gx, float gy, bool sleep, int meter)
|
||||||
|
{
|
||||||
|
b2AABB aabb;
|
||||||
|
aabb.lowerBound.Set(lx, ly);
|
||||||
|
aabb.upperBound.Set(ux, uy);
|
||||||
|
return new World(aabb, b2Vec2(gx, gy), sleep, meter);
|
||||||
|
}
|
||||||
|
|
||||||
World * Physics::newWorld(float lx, float ly, float ux, float uy, float gx, float gy, bool sleep)
|
World * Physics::newWorld(float lx, float ly, float ux, float uy, float gx, float gy, bool sleep)
|
||||||
{
|
{
|
||||||
b2AABB aabb;
|
b2AABB aabb;
|
||||||
|
|||||||
@@ -50,6 +50,19 @@ namespace box2d
|
|||||||
// Implements Module.
|
// Implements Module.
|
||||||
const char * getName() const;
|
const char * getName() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new World.
|
||||||
|
* @param lx Lower bound on the x-axis.
|
||||||
|
* @param ly Lower bound on the y-axis.
|
||||||
|
* @param ux Upper bound on the x-axis.
|
||||||
|
* @param uy Upper bound on the y-axis.
|
||||||
|
* @param gx Gravity along x-axis.
|
||||||
|
* @param gy Gravity along y-axis.
|
||||||
|
* @param sleep Whether the World allows sleep.
|
||||||
|
* @param meter The scale in px/m.
|
||||||
|
**/
|
||||||
|
World * newWorld(float lx, float ly, float ux, float uy, float gx, float gy, bool sleep, int meter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new World.
|
* Creates a new World.
|
||||||
* @param lx Lower bound on the x-axis.
|
* @param lx Lower bound on the x-axis.
|
||||||
|
|||||||
@@ -102,8 +102,8 @@ namespace box2d
|
|||||||
world->SetContactListener(this);
|
world->SetContactListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
World::World(b2AABB aabb, b2Vec2 gravity, bool sleep)
|
World::World(b2AABB aabb, b2Vec2 gravity, bool sleep, int meter)
|
||||||
: meter(DEFAULT_METER)
|
: meter(meter)
|
||||||
{
|
{
|
||||||
world = new b2World(scaleDown(aabb), scaleDown(gravity), sleep);
|
world = new b2World(scaleDown(aabb), scaleDown(gravity), sleep);
|
||||||
world->SetContactListener(this);
|
world->SetContactListener(this);
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ namespace box2d
|
|||||||
* @param sleep True if the bodies should be able to sleep,
|
* @param sleep True if the bodies should be able to sleep,
|
||||||
* false otherwise.
|
* false otherwise.
|
||||||
**/
|
**/
|
||||||
World(b2AABB aabb, b2Vec2 gravity, bool sleep);
|
World(b2AABB aabb, b2Vec2 gravity, bool sleep, int meter = DEFAULT_METER);
|
||||||
|
|
||||||
virtual ~World();
|
virtual ~World();
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,20 @@ namespace box2d
|
|||||||
luax_newtype(L, "World", PHYSICS_WORLD_T, (void*)w);
|
luax_newtype(L, "World", PHYSICS_WORLD_T, (void*)w);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
else if (top == 8)
|
||||||
|
{
|
||||||
|
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 = lua_toboolean(L, 7);
|
||||||
|
int meter = (int)luaL_checknumber(L, 8);
|
||||||
|
World * w = instance->newWorld(lx, ly, ux, uy, gx, gy, sleep, meter);
|
||||||
|
luax_newtype(L, "World", PHYSICS_WORLD_T, (void*)w);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return luaL_error(L, "Incorrect number of parameters");
|
return luaL_error(L, "Incorrect number of parameters");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user