diff --git a/data/levels/scripts/openSecondDoor1.lua b/data/levels/scripts/openSecondDoor1.lua index 15e7308..14085cb 100644 --- a/data/levels/scripts/openSecondDoor1.lua +++ b/data/levels/scripts/openSecondDoor1.lua @@ -25,6 +25,11 @@ function trigger(objectToChange) global.triggeredOpenSecondDoor1Undo = false end + local xPos = -6.5 + local yPos = 25.0 + local zPos = 54.5 + level:preloadLightPosition(xPos, yPos, zPos) + level:addLightByParameters(0.2, 0.9, 0.0, 4.0, -1.5, 3.0, 0.8) print("openSecondDoor1") end end @@ -41,6 +46,7 @@ function triggerUndo(objectToChange) global.triggeredOpenSecondDoor2 = false global.triggeredOpenSecondDoor3 = false global.triggeredOpenSecondDoor4 = false + level:deleteFourLights() global.triggeredOpenSecondDoor1Undo = true print("openSecondDoor1Undo") diff --git a/data/levels/scripts/openSecondDoor2.lua b/data/levels/scripts/openSecondDoor2.lua index b7ca74b..63cbb83 100644 --- a/data/levels/scripts/openSecondDoor2.lua +++ b/data/levels/scripts/openSecondDoor2.lua @@ -25,6 +25,11 @@ function trigger(objectToChange) global.triggeredOpenSecondDoor2Undo = false end + local xPos = -53.5 + local yPos = 25.0 + local zPos = 26.5 + level:preloadLightPosition(xPos, yPos, zPos) + level:addLightByParameters(0.2, 0.9, 0.0, 4.0, -1.5, 3.0, 0.8) print("openSecondDoor2") end end @@ -41,6 +46,7 @@ function triggerUndo(objectToChange) global.triggeredOpenSecondDoor2 = false global.triggeredOpenSecondDoor3 = false global.triggeredOpenSecondDoor4 = false + level:deleteFourLights() global.triggeredOpenSecondDoor2Undo = true print("openSecondDoor2Undo") diff --git a/data/levels/scripts/openSecondDoor3.lua b/data/levels/scripts/openSecondDoor3.lua index 16f2116..302bd92 100644 --- a/data/levels/scripts/openSecondDoor3.lua +++ b/data/levels/scripts/openSecondDoor3.lua @@ -25,6 +25,11 @@ function trigger(objectToChange) global.triggeredOpenSecondDoor3Undo = false end + local xPos = -6.5 + local yPos = 25.0 + local zPos = 26.5 + level:preloadLightPosition(xPos, yPos, zPos) + level:addLightByParameters(0.2, 0.9, 0.0, 4.0, -1.5, 3.0, 0.8) print("openSecondDoor3") end end @@ -41,6 +46,7 @@ function triggerUndo(objectToChange) global.triggeredOpenSecondDoor2 = false global.triggeredOpenSecondDoor3 = false global.triggeredOpenSecondDoor4 = false + level:deleteFourLights() global.triggeredOpenSecondDoor3Undo = true print("openSecondDoor3Undo") diff --git a/data/levels/scripts/openSecondDoor4.lua b/data/levels/scripts/openSecondDoor4.lua index e1143b2..6150e9e 100644 --- a/data/levels/scripts/openSecondDoor4.lua +++ b/data/levels/scripts/openSecondDoor4.lua @@ -34,6 +34,11 @@ function trigger(objectToChange) end end + local xPos = -53.5 + local yPos = 25.0 + local zPos = 54.5 + level:preloadLightPosition(xPos, yPos, zPos) + level:addLightByParameters(0.2, 0.9, 0.0, 4.0, -1.5, 3.0, 0.8) print("openSecondDoor4") end end @@ -50,6 +55,7 @@ function triggerUndo(objectToChange) global.triggeredOpenSecondDoor2 = false global.triggeredOpenSecondDoor3 = false global.triggeredOpenSecondDoor4 = false + level:deleteFourLights() global.triggeredOpenSecondDoor4Undo = true print("openSecondDoor4Undo") diff --git a/level.cc b/level.cc index d0a4c3b..76332f7 100644 --- a/level.cc +++ b/level.cc @@ -43,6 +43,9 @@ void Level::load() { .addFunction("setSunDirection", &Level::setSunDirection) .addFunction("forceMove", &Level::forceMove) .addFunction("activateEndgame", &Level::activateEndgame) + .addFunction("preloadLightPosition", &Level::preloadLightPosition) + .addFunction("addLightByParameters", &Level::addLightByParameters) + .addFunction("deleteFourLights", &Level::deleteFourLights) .endClass(); //Push the level to Lua as a global variable luabridge::push(luaState, this); @@ -259,6 +262,23 @@ void Level::addLight(Light light) { this->lights.push_back(light); } +void Level::preloadLightPosition(float xPos, float yPos, float zPos){ + nextLightPosition = glm::vec3(xPos, yPos, zPos); +} + +void Level::addLightByParameters(float redColour, float greenColour, float blueColour, float intensity, float flameYOffset, float flameHeight, float flameWidth){ + glm::vec3 colour = glm::vec3(redColour, greenColour, blueColour); + this->lights.push_back(Light(nextLightPosition, colour, intensity, flameYOffset, flameHeight, flameWidth)); +} + +void Level::deleteFourLights(){ + int indice = lights.size()-4; + lights.erase(lights.begin() + indice); + lights.erase(lights.begin() + indice); + lights.erase(lights.begin() + indice); + lights.erase(lights.begin() + indice); +} + void Level::addTrigger(Trigger trigger) { this->triggers.push_back(trigger); } diff --git a/level.hh b/level.hh index f494211..f9fd910 100644 --- a/level.hh +++ b/level.hh @@ -55,6 +55,9 @@ class Level { unsigned int getPhysicsObjectsVectorSize(); void setCameraCenter(Object* object); void addLight(Light light); + void preloadLightPosition(float xPos, float yPos, float zPos); + void addLightByParameters(float redColour, float greenColour, float blueColour, float intensity, float flameYOffset, float flameHeight, float flameWidth); + void deleteFourLights(); void addTrigger(Trigger trigger); lua_State* getLuaState(); Terrain* getTerrain(); @@ -81,6 +84,7 @@ class Level { float skydomeSize; float strength; std::string xmlFilePath; + glm::vec3 nextLightPosition; }; #endif