Created a moveObject function in the Level class.
This commit is contained in:
parent
b3f11542d2
commit
698d917d4c
7
level.cc
7
level.cc
@ -62,6 +62,7 @@ void Level::load() {
|
|||||||
.beginClass<Level>("Level")
|
.beginClass<Level>("Level")
|
||||||
.addFunction("deleteObject", &Level::deleteObject)
|
.addFunction("deleteObject", &Level::deleteObject)
|
||||||
.addFunction("getObjectCount", &Level::getObjectCount)
|
.addFunction("getObjectCount", &Level::getObjectCount)
|
||||||
|
.addFunction("moveObject", &Level::moveObject)
|
||||||
.endClass();
|
.endClass();
|
||||||
//Push the level to Lua as a global variable
|
//Push the level to Lua as a global variable
|
||||||
luabridge::push(L, this);
|
luabridge::push(L, this);
|
||||||
@ -493,7 +494,11 @@ int Level::getObjectCount(){
|
|||||||
return objects.size();
|
return objects.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Level::moveObject(int objectIndex, float strength, float xPos, float yPos, float zPos){
|
||||||
|
glm::vec3 position = glm::vec3(xPos, yPos, zPos);
|
||||||
|
physics.removePositionConstraint(objectIndex);
|
||||||
|
physics.addPositionConstraint(objectIndex, strength, position);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
1
level.hh
1
level.hh
@ -32,6 +32,7 @@ class Level {
|
|||||||
std::vector<Object*>* getObjects();
|
std::vector<Object*>* getObjects();
|
||||||
void deleteObject(int objectIndex);
|
void deleteObject(int objectIndex);
|
||||||
int getObjectCount();
|
int getObjectCount();
|
||||||
|
void moveObject(int objectIndex, float strength, float xPos, float yPos, float zPos);
|
||||||
private:
|
private:
|
||||||
void errorCheck(tinyxml2::XMLError error);
|
void errorCheck(tinyxml2::XMLError error);
|
||||||
std::string levelNum;
|
std::string levelNum;
|
||||||
|
@ -36,7 +36,7 @@ void Physics::removePositionConstraint(int bodyIndice)
|
|||||||
{
|
{
|
||||||
for(unsigned i = 0; i < allPositionConstraints.size(); i++)
|
for(unsigned i = 0; i < allPositionConstraints.size(); i++)
|
||||||
{
|
{
|
||||||
if(allPositionConstraints[i].body == bodies[i] )
|
if(allPositionConstraints[i].body == bodies[bodyIndice])
|
||||||
{
|
{
|
||||||
allPositionConstraints.erase(allPositionConstraints.begin()+i);
|
allPositionConstraints.erase(allPositionConstraints.begin()+i);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user