From 9339e572a0a94e14ba04c4290666e14a6ae7102a Mon Sep 17 00:00:00 2001 From: itqop Date: Wed, 15 May 2024 13:26:17 +0300 Subject: [PATCH] Small fix --- src/game.cpp | 9 -------- src/main.cpp | 62 ++++++++++++++++++++++++++-------------------------- 2 files changed, 31 insertions(+), 40 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 76a9a58..19e6279 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -10,8 +10,6 @@ void Game::onCreate(int screenW, int screenH) isCreativeCamera = true; updateWindowMetrics(screenW, screenH); - - //create 2D renderer renderer2d.create(); font.createFromFile(RESOURCES_PATH "roboto_black.ttf"); @@ -21,9 +19,6 @@ void Game::onCreate(int screenW, int screenH) chunkManager.setGridSize(10, glm::vec2{camera->getPosition().x, camera->getPosition().z}); - //std::cout << chunkManager.bottomCorner.x << " " << chunkManager.bottomCorner.y << "\n"; - //std::cout << chunkManager.topCorner.x << " " << chunkManager.topCorner.y << "\n"; - arrowTexture.loadFromFile(RESOURCES_PATH "arrow.png"); skyBox.create(); @@ -134,10 +129,6 @@ void Game::onUpdate(float deltaTime, const GameInput &input) camera->getViewDirection())) { auto b = chunkManager.getBlockRaw(rayEnd); - if(b) - { - //std::cout << *b << "\n"; - } if(input.getKey(GameInput::RIGHT_CLICK).isReleased()) { diff --git a/src/main.cpp b/src/main.cpp index c298717..aab1b6d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,20 +18,20 @@ GameInput input; -void keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods) +void keyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) { - auto setKey = [&action](GameInput::keys k) + auto setKey = [&action](GameInput::keys k) { if (action == GLFW_PRESS) { input.setKeyPress(k); } else - if (action == GLFW_RELEASE) - { - input.setKeyRelease(k); - } + if (action == GLFW_RELEASE) + { + input.setKeyRelease(k); + } }; if (key == GLFW_KEY_W || key == GLFW_KEY_UP) @@ -74,13 +74,13 @@ void keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods setKey(GameInput::P); } - if (key == GLFW_KEY_ESCAPE) + if (key == GLFW_KEY_ESCAPE) { exit(0); } }; -void mouseCallback(GLFWwindow* window, int key, int action, int mods) +void mouseCallback(GLFWwindow *window, int key, int action, int mods) { if (key == GLFW_MOUSE_BUTTON_LEFT) @@ -90,10 +90,10 @@ void mouseCallback(GLFWwindow* window, int key, int action, int mods) input.setKeyPress(GameInput::LEFT_CLICK); } else - if (action == GLFW_RELEASE) - { - input.setKeyRelease(GameInput::LEFT_CLICK); - } + if (action == GLFW_RELEASE) + { + input.setKeyRelease(GameInput::LEFT_CLICK); + } } @@ -104,15 +104,15 @@ void mouseCallback(GLFWwindow* window, int key, int action, int mods) input.setKeyPress(GameInput::RIGHT_CLICK); } else - if (action == GLFW_RELEASE) - { - input.setKeyRelease(GameInput::RIGHT_CLICK); - } + if (action == GLFW_RELEASE) + { + input.setKeyRelease(GameInput::RIGHT_CLICK); + } } } -void windowFocusCallback(GLFWwindow* window, int focused) +void windowFocusCallback(GLFWwindow *window, int focused) { if (!focused) { @@ -120,9 +120,9 @@ void windowFocusCallback(GLFWwindow* window, int focused) } } -void windowSizeCallback(GLFWwindow* window, int x, int y) +void windowSizeCallback(GLFWwindow *window, int x, int y) { - + input.resetInputsToZero(); } @@ -132,13 +132,13 @@ int main() #ifdef PLATFORM_WIN32 #ifdef _MSC_VER #if INTERNAL_BUILD - { - AllocConsole(); - auto f1 = freopen("conin$", "r", stdin); - auto f2 = freopen("conout$", "w", stdout); - auto f3 = freopen("conout$", "w", stderr); - std::cout.sync_with_stdio(); - } +{ + AllocConsole(); + auto f1 = freopen("conin$", "r", stdin); + auto f2 = freopen("conout$", "w", stdout); + auto f3 = freopen("conout$", "w", stderr); + std::cout.sync_with_stdio(); +} #endif #endif #endif @@ -160,14 +160,14 @@ int main() glfwSetInputMode(wind, GLFW_CURSOR, GLFW_CURSOR_DISABLED); permaAssertComment(gladLoadGL(), "err initializing glad"); - + gl2d::init(); - + try { Game game(w, h); - + long lastTime = clock(); while (!glfwWindowShouldClose(wind)) @@ -177,11 +177,11 @@ int main() glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); -#pragma region movement + #pragma region movement long newTime = clock(); float deltaTime = (float)(newTime - lastTime) / CLOCKS_PER_SEC; lastTime = clock(); -#pragma endregion + #pragma endregion double xMouse, yMouse; glfwGetCursorPos(wind, &xMouse, &yMouse);