Created a moveObject function in the Level class.
This commit is contained in:
parent
f496532126
commit
04df8bd22f
7
level.cc
7
level.cc
@ -62,6 +62,7 @@ void Level::load() {
|
||||
.beginClass<Level>("Level")
|
||||
.addFunction("deleteObject", &Level::deleteObject)
|
||||
.addFunction("getObjectCount", &Level::getObjectCount)
|
||||
.addFunction("moveObject", &Level::moveObject)
|
||||
.endClass();
|
||||
//Push the level to Lua as a global variable
|
||||
luabridge::push(L, this);
|
||||
@ -493,7 +494,11 @@ int Level::getObjectCount(){
|
||||
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();
|
||||
void deleteObject(int objectIndex);
|
||||
int getObjectCount();
|
||||
void moveObject(int objectIndex, float strength, float xPos, float yPos, float zPos);
|
||||
private:
|
||||
void errorCheck(tinyxml2::XMLError error);
|
||||
std::string levelNum;
|
||||
|
@ -34,9 +34,9 @@ void Physics::takeUpdateStep(float timeDiff)
|
||||
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user