diff --git a/build/.emptydirectory b/build/.gitkeep similarity index 100% rename from build/.emptydirectory rename to build/.gitkeep diff --git a/src/gamelogic.cpp b/src/gamelogic.cpp index 62ce8ce..5b8c282 100644 --- a/src/gamelogic.cpp +++ b/src/gamelogic.cpp @@ -53,10 +53,10 @@ glm::vec3 ballDirection(1, 1, 0.2f); CommandLineOptions options; -bool hasStarted = false; -bool hasLost = false; +bool hasStarted = false; +bool hasLost = false; bool jumpedToNextFrame = false; -bool isPaused = false; +bool isPaused = false; bool mouseLeftPressed = false; bool mouseLeftReleased = false; @@ -131,14 +131,14 @@ void initGame(GLFWwindow* window, CommandLineOptions gameOptions) { rootNode->children.push_back(padNode); rootNode->children.push_back(ballNode); - boxNode->vertexArrayObjectID = boxVAO; - boxNode->VAOIndexCount = box.indices.size(); + boxNode->vertexArrayObjectID = boxVAO; + boxNode->VAOIndexCount = box.indices.size(); - padNode->vertexArrayObjectID = padVAO; - padNode->VAOIndexCount = pad.indices.size(); + padNode->vertexArrayObjectID = padVAO; + padNode->VAOIndexCount = pad.indices.size(); ballNode->vertexArrayObjectID = ballVAO; - ballNode->VAOIndexCount = sphere.indices.size(); + ballNode->VAOIndexCount = sphere.indices.size(); @@ -182,7 +182,7 @@ void updateFrame(GLFWwindow* window) { mouseRightReleased = mouseRightPressed; mouseRightPressed = false; } - + if(!hasStarted) { if (mouseLeftPressed) { if (options.enableMusic) { @@ -296,7 +296,8 @@ void updateFrame(GLFWwindow* window) { if ( ballPosition.x < padLeftX || ballPosition.x > padRightX || ballPosition.z < padFrontZ - || ballPosition.z > padBackZ) { + || ballPosition.z > padBackZ + ) { hasLost = true; if (options.enableMusic) { sound->stop(); @@ -313,7 +314,7 @@ void updateFrame(GLFWwindow* window) { // Some math to make the camera move in a nice way float lookRotation = -0.6 / (1 + exp(-5 * (padPositionX-0.5))) + 0.3; - glm::mat4 cameraTransform = + glm::mat4 cameraTransform = glm::rotate(0.3f + 0.2f * float(-padPositionZ*padPositionZ), glm::vec3(1, 0, 0)) * glm::rotate(lookRotation, glm::vec3(0, 1, 0)) * glm::translate(-cameraPosition); @@ -327,9 +328,9 @@ void updateFrame(GLFWwindow* window) { ballNode->scale = glm::vec3(ballRadius); ballNode->rotation = { 0, totalElapsedTime*2, 0 }; - padNode->position = { - boxNode->position.x - (boxDimensions.x/2) + (padDimensions.x/2) + (1 - padPositionX) * (boxDimensions.x - padDimensions.x), - boxNode->position.y - (boxDimensions.y/2) + (padDimensions.y/2), + padNode->position = { + boxNode->position.x - (boxDimensions.x/2) + (padDimensions.x/2) + (1 - padPositionX) * (boxDimensions.x - padDimensions.x), + boxNode->position.y - (boxDimensions.y/2) + (padDimensions.y/2), boxNode->position.z - (boxDimensions.z/2) + (padDimensions.z/2) + (1 - padPositionZ) * (boxDimensions.z - padDimensions.z) }; diff --git a/src/main.cpp b/src/main.cpp index 20e77ac..0cbc3ff 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,11 +40,7 @@ GLFWwindow* initialise() glfwWindowHint(GLFW_SAMPLES, windowSamples); // MSAA // Create window using GLFW - GLFWwindow* window = glfwCreateWindow(windowWidth, - windowHeight, - windowTitle.c_str(), - nullptr, - nullptr); + GLFWwindow* window = glfwCreateWindow(windowWidth, windowHeight, windowTitle.c_str(), nullptr, nullptr); // Ensure the window is set up correctly if (!window) @@ -71,8 +67,8 @@ GLFWwindow* initialise() int main(int argc, const char* argb[]) { arrrgh::parser parser("glowbox", "Small breakout like juggling game"); - const auto& showHelp = parser.add("help", "Show this help message.", 'h', arrrgh::Optional, false); - const auto& enableMusic = parser.add("enable-music", "Play background music while the game is playing", 'm', arrrgh::Optional, false); + const auto& showHelp = parser.add("help", "Show this help message.", 'h', arrrgh::Optional, false); + const auto& enableMusic = parser.add("enable-music", "Play background music while the game is playing", 'm', arrrgh::Optional, false); const auto& enableAutoplay = parser.add("autoplay", "Let the game play itself automatically. Useful for testing.", 'a', arrrgh::Optional, false); // If you want to add more program arguments, define them here, @@ -96,7 +92,7 @@ int main(int argc, const char* argb[]) } CommandLineOptions options; - options.enableMusic = enableMusic.value(); + options.enableMusic = enableMusic.value(); options.enableAutoplay = enableAutoplay.value(); // Initialise window using GLFW diff --git a/src/utilities/imageLoader.hpp b/src/utilities/imageLoader.hpp index 5f3099f..033cd73 100644 --- a/src/utilities/imageLoader.hpp +++ b/src/utilities/imageLoader.hpp @@ -5,8 +5,9 @@ #include typedef struct PNGImage { - unsigned int width, height; + unsigned int width; + unsigned int height; std::vector pixels; } PNGImage; -PNGImage loadPNGFile(std::string fileName); \ No newline at end of file +PNGImage loadPNGFile(std::string fileName); diff --git a/src/utilities/shader.hpp b/src/utilities/shader.hpp index 69cfe22..0fec2fe 100644 --- a/src/utilities/shader.hpp +++ b/src/utilities/shader.hpp @@ -17,7 +17,9 @@ namespace Gloom class Shader { public: - Shader() { mProgram = glCreateProgram(); } + Shader() { + mProgram = glCreateProgram(); + } // Public member functions void activate() { glUseProgram(mProgram); }