diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 7678b0f..0cbfcf6 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -10,7 +10,8 @@ "cStandard": "${default}", "cppStandard": "${default}", "intelliSenseMode": "linux-gcc-x64", - "compilerArgs": [] + "compilerArgs": [], + "configurationProvider": "ms-vscode.makefile-tools" } ], "version": 4 diff --git a/Engine/engine/match b/Engine/engine/match index 0141014..09d91bd 100755 Binary files a/Engine/engine/match and b/Engine/engine/match differ diff --git a/Engine/engine/match.cpp b/Engine/engine/match.cpp index 9556f78..90fabec 100644 --- a/Engine/engine/match.cpp +++ b/Engine/engine/match.cpp @@ -6,6 +6,11 @@ #include #include #include + +#include // I am using standart library RNG because I am lazy and wanted to create quick code snippet +// upgrade to this: https://arvid.io/2018/06/30/on-cxx-random-number-generator-quality/ whenever, if ever I feel like it +#include // for std::chrono + #include "constants.hpp" void configureGLFW() { @@ -68,12 +73,55 @@ void viewPort(GLFWwindow* window) // we call framebuffer_size_callback on every window resize } +void processInput(GLFWwindow *window) +{ + // glfwGetKey takes window and key as an input and checks is currently being pressed + // if the user pressed escape we close window + if(glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) + glfwSetWindowShouldClose(window, true); + if(glfwGetKey(window, GLFW_KEY_C) == GLFW_PRESS) + glfwSetWindowShouldClose(window, true); +} + +const float padaczkaSimulator() +{ + // Seed our Mersenne Twister using the + std::mt19937 mt{ static_cast( + std::chrono::steady_clock::now().time_since_epoch().count() + ) }; + + // Create a reusable random number generator that generates uniform numbers between 1 and 6 + std::uniform_int_distribution ten{ 1, 10 }; // for C++14, use std::uniform_int_distribution<> die6{ 1, 6 }; + + const float MT_FLOAT = static_cast (ten(mt) % 10); + return MT_FLOAT / 10; +} + void renderLoop(GLFWwindow* window) { + // glfwWindowShouldClose checks if GLFW was instructed to close while(!glfwWindowShouldClose(window)) { + // input + processInput(window); + + const float FIRST_COLOR = padaczkaSimulator(); + const float SECOND_COLOR = padaczkaSimulator(); + const float THIRD_COLOR = padaczkaSimulator(); + const float FOUR_COLOR = padaczkaSimulator(); + std::cout << FIRST_COLOR << std::endl; + glClearColor( FIRST_COLOR, SECOND_COLOR, THIRD_COLOR, FOUR_COLOR); + glClear(GL_COLOR_BUFFER_BIT); + + + // swaps buffer containing color values of each pixel in window + // there is front buffer (final image) and back buffer (where all rendering commands draw to) + // when back buffer is ready we swap it with front buffer to eliminate flickering glfwSwapBuffers(window); + + // glfwPollEvents checks if any event (like mouse/keyboard input was triggered), updates window state and calls functions (which we register via callback methods) glfwPollEvents(); + } } @@ -97,6 +145,8 @@ int main() viewPort(window); renderLoop(window); + // clean GLFW resources + glfwTerminate(); return 0; }