Fixed love.keyboard.setKeyRepeat, fixed issues with Body:getWhatever, and made the save directory settable.

This commit is contained in:
rude
2009-10-29 22:34:54 +01:00
parent 0e671c34d5
commit 435fc43f68
9 changed files with 164 additions and 66 deletions
+40 -26
View File
@@ -58,14 +58,18 @@ namespace box2d
return world->scaleUp(body->GetPosition().y);
}
int Body::getPosition(lua_State * L)
void Body::getPosition(float & x_o, float & y_o)
{
return pushVector(L, world->scaleUp(body->GetPosition()));
b2Vec2 v = world->scaleUp(body->GetPosition());
x_o = v.x;
y_o = v.y;
}
int Body::getLinearVelocity(lua_State * L)
void Body::getLinearVelocity(float & x_o, float & y_o)
{
return pushVector(L, world->scaleUp(body->GetLinearVelocity()));
b2Vec2 v = world->scaleUp(body->GetLinearVelocity());
x_o = v.x;
y_o = v.y;
}
float Body::getAngle()
@@ -73,14 +77,18 @@ namespace box2d
return body->GetAngle();
}
int Body::getWorldCenter(lua_State * L)
void Body::getWorldCenter(float & x_o, float & y_o)
{
return pushVector(L, world->scaleUp(body->GetWorldCenter()));
b2Vec2 v = world->scaleUp(body->GetWorldCenter());
x_o = v.x;
y_o = v.y;
}
int Body::getLocalCenter(lua_State * L)
void Body::getLocalCenter(float & x_o, float & y_o)
{
return pushVector(L, world->scaleUp(body->GetLocalCenter()));
b2Vec2 v = world->scaleUp(body->GetLocalCenter());
x_o = v.x;
y_o = v.y;
}
float Body::getAngularVelocity() const
@@ -187,40 +195,46 @@ namespace box2d
body->SetMass(&massData);
}
int Body::getWorldPoint(lua_State * L)
void Body::getWorldPoint(float x, float y, float & x_o, float & y_o)
{
b2Vec2 v = world->scaleDown(getVector(L));
return pushVector(L, world->scaleUp(body->GetWorldPoint(v)));
b2Vec2 v = world->scaleUp(body->GetWorldPoint(world->scaleDown(b2Vec2(x, y))));
x_o = v.x;
y_o = v.y;
}
int Body::getWorldVector(lua_State * L)
void Body::getWorldVector(float x, float y, float & x_o, float & y_o)
{
b2Vec2 v = world->scaleDown(getVector(L));
return pushVector(L, world->scaleUp(body->GetWorldVector(v)));
b2Vec2 v = world->scaleUp(body->GetWorldVector(world->scaleDown(b2Vec2(x, y))));
x_o = v.x;
y_o = v.y;
}
int Body::getLocalPoint(lua_State * L)
void Body::getLocalPoint(float x, float y, float & x_o, float & y_o)
{
b2Vec2 v = world->scaleDown(getVector(L));
return pushVector(L, world->scaleUp(body->GetLocalPoint(v)));
b2Vec2 v = world->scaleUp(body->GetLocalPoint(world->scaleDown(b2Vec2(x, y))));
x_o = v.x;
y_o = v.y;
}
int Body::getLocalVector(lua_State * L)
void Body::getLocalVector(float x, float y, float & x_o, float & y_o)
{
b2Vec2 v = world->scaleDown(getVector(L));
return pushVector(L, world->scaleUp(body->GetLocalVector(v)));
b2Vec2 v = world->scaleUp(body->GetLocalVector(world->scaleDown(b2Vec2(x, y))));
x_o = v.x;
y_o = v.y;
}
int Body::getLinearVelocityFromWorldPoint(lua_State * L)
void Body::getLinearVelocityFromWorldPoint(float x, float y, float & x_o, float & y_o)
{
b2Vec2 v = world->scaleDown(getVector(L));
return pushVector(L, world->scaleUp(body->GetLinearVelocityFromWorldPoint(v)));
b2Vec2 v = world->scaleUp(body->GetLinearVelocityFromWorldPoint(world->scaleDown(b2Vec2(x, y))));
x_o = v.x;
y_o = v.y;
}
int Body::getLinearVelocityFromLocalPoint(lua_State * L)
void Body::getLinearVelocityFromLocalPoint(float x, float y, float & x_o, float & y_o)
{
b2Vec2 v = world->scaleDown(getVector(L));
return pushVector(L, world->scaleUp(body->GetLinearVelocityFromLocalPoint(v)));
b2Vec2 v = world->scaleUp(body->GetLinearVelocityFromLocalPoint(world->scaleDown(b2Vec2(x, y))));
x_o = v.x;
y_o = v.y;
}
bool Body::isBullet() const
+13 -14
View File
@@ -22,6 +22,7 @@
#define LOVE_PHYSICS_BOX2D_BODY_H
// LOVE
#include <common/math.h>
#include <common/runtime.h>
#include <common/Object.h>
@@ -93,17 +94,15 @@ namespace box2d
/**
* Gets the current position of the Body.
* @returns The current x-position.
* @returns The current y-position.
* @returns The current position.
**/
int getPosition(lua_State * L);
void getPosition(float & x_o, float & y_o);
/**
* Gets the velocity in the current center of mass.
* @returns The x-component of the velocity.
* @returns The y-component of the velocity.
* @returns The velocity in the current center of mass.
**/
int getLinearVelocity(lua_State * L);
void getLinearVelocity(float & x_o, float & y_o);
/**
* The current center of mass for the Body in world
@@ -111,7 +110,7 @@ namespace box2d
* @returns The x-component of the point.
* @returns The y-component of the point.
**/
int getWorldCenter(lua_State * L);
void getWorldCenter(float & x_o, float & y_o);
/**
* The current center of mass for the Body in local
@@ -119,7 +118,7 @@ namespace box2d
* @returns The x-component of the point.
* @returns The y-component of the point.
**/
int getLocalCenter(lua_State * L);
void getLocalCenter(float & x_o, float & y_o);
/**
* Get the current Body spin. (Angular velocity).
@@ -233,7 +232,7 @@ namespace box2d
* @returns The x-coordinate of the point in world coordinates.
* @returns The y-coordinate of the point in world coordinates.
**/
int getWorldPoint(lua_State * L);
void getWorldPoint(float x, float y, float & x_o, float & y_o);
/**
* Transforms a vector (x, y) from local coordinates
@@ -243,7 +242,7 @@ namespace box2d
* @returns The x-coordinate of the vector in world coordinates.
* @returns The y-coordinate of the vector in world coordinates.
**/
int getWorldVector(lua_State * L);
void getWorldVector(float x, float y, float & x_o, float & y_o);
/**
* Transforms a point (x, y) from world coordinates
@@ -253,7 +252,7 @@ namespace box2d
* @returns The x-coordinate of the point in local coordinates.
* @returns The y-coordinate of the point in local coordinates.
**/
int getLocalPoint(lua_State * L);
void getLocalPoint(float x, float y, float & x_o, float & y_o);
/**
* Transforms a vector (x, y) from world coordinates
@@ -263,7 +262,7 @@ namespace box2d
* @returns The x-coordinate of the vector in local coordinates.
* @returns The y-coordinate of the vector in local coordinates.
**/
int getLocalVector(lua_State * L);
void getLocalVector(float x, float y, float & x_o, float & y_o);
/**
* Gets the velocity on the Body for the given world point.
@@ -272,7 +271,7 @@ namespace box2d
* @returns The x-component of the velocity vector.
* @returns The y-component of the velocity vector.
**/
int getLinearVelocityFromWorldPoint(lua_State * L);
void getLinearVelocityFromWorldPoint(float x, float y, float & x_o, float & y_o);
/**
* Gets the velocity on the Body for the given local point.
@@ -281,7 +280,7 @@ namespace box2d
* @returns The x-component of the velocity vector.
* @returns The y-component of the velocity vector.
**/
int getLinearVelocityFromLocalPoint(lua_State * L);
void getLinearVelocityFromLocalPoint(float x, float y, float & x_o, float & y_o);
/**
* Returns true if the Body is a bullet, false otherwise.
+82 -10
View File
@@ -55,25 +55,49 @@ namespace box2d
int w_Body_getPosition(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
return t->getPosition(L);
float x_o, y_o;
t->getPosition(x_o, y_o);
lua_pushnumber(L, x_o);
lua_pushnumber(L, y_o);
return 2;
}
int w_Body_getLinearVelocity(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
return t->getLinearVelocity(L);
float x_o, y_o;
t->getLinearVelocity(x_o, y_o);
lua_pushnumber(L, x_o);
lua_pushnumber(L, y_o);
return 2;
}
int w_Body_getWorldCenter(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
return t->getWorldCenter(L);
float x_o, y_o;
t->getWorldCenter(x_o, y_o);
lua_pushnumber(L, x_o);
lua_pushnumber(L, y_o);
return 2;
}
int w_Body_getLocalCenter(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
return t->getLocalCenter(L);
float x_o, y_o;
t->getLocalCenter(x_o, y_o);
lua_pushnumber(L, x_o);
lua_pushnumber(L, y_o);
return 2;
}
int w_Body_getAngularVelocity(lua_State * L)
@@ -228,37 +252,85 @@ namespace box2d
int w_Body_getWorldPoint(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
return t->getWorldPoint(L);
float x = (float)luaL_checknumber(L, 2);
float y = (float)luaL_checknumber(L, 3);
float x_o, y_o;
t->getWorldPoint(x, y, x_o, y_o);
lua_pushnumber(L, x_o);
lua_pushnumber(L, y_o);
return 2;
}
int w_Body_getWorldVector(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
return t->getWorldVector(L);
float x = (float)luaL_checknumber(L, 2);
float y = (float)luaL_checknumber(L, 3);
float x_o, y_o;
t->getWorldVector(x, y, x_o, y_o);
lua_pushnumber(L, x_o);
lua_pushnumber(L, y_o);
return 2;
}
int w_Body_getLocalPoint(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
return t->getLocalPoint(L);
float x = (float)luaL_checknumber(L, 2);
float y = (float)luaL_checknumber(L, 3);
float x_o, y_o;
t->getLocalPoint(x, y, x_o, y_o);
lua_pushnumber(L, x_o);
lua_pushnumber(L, y_o);
return 2;
}
int w_Body_getLocalVector(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
return t->getLocalVector(L);
float x = (float)luaL_checknumber(L, 2);
float y = (float)luaL_checknumber(L, 3);
float x_o, y_o;
t->getLocalVector(x, y, x_o, y_o);
lua_pushnumber(L, x_o);
lua_pushnumber(L, y_o);
return 2;
}
int w_Body_getLinearVelocityFromWorldPoint(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
return t->getLinearVelocityFromWorldPoint(L);
float x = (float)luaL_checknumber(L, 2);
float y = (float)luaL_checknumber(L, 3);
float x_o, y_o;
t->getLinearVelocityFromWorldPoint(x, y, x_o, y_o);
lua_pushnumber(L, x_o);
lua_pushnumber(L, y_o);
return 2;
}
int w_Body_getLinearVelocityFromLocalPoint(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
return t->getLinearVelocityFromLocalPoint(L);
float x = (float)luaL_checknumber(L, 2);
float y = (float)luaL_checknumber(L, 3);
float x_o, y_o;
t->getLinearVelocityFromLocalPoint(x, y, x_o, y_o);
lua_pushnumber(L, x_o);
lua_pushnumber(L, y_o);
return 2;
}
int w_Body_isBullet(lua_State * L)