Small fix

This commit is contained in:
itqop 2024-05-15 13:26:17 +03:00
parent 587ce37b75
commit 9339e572a0
2 changed files with 31 additions and 40 deletions

View File

@ -10,8 +10,6 @@ void Game::onCreate(int screenW, int screenH)
isCreativeCamera = true; isCreativeCamera = true;
updateWindowMetrics(screenW, screenH); updateWindowMetrics(screenW, screenH);
//create 2D renderer
renderer2d.create(); renderer2d.create();
font.createFromFile(RESOURCES_PATH "roboto_black.ttf"); 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}); 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"); arrowTexture.loadFromFile(RESOURCES_PATH "arrow.png");
skyBox.create(); skyBox.create();
@ -134,10 +129,6 @@ void Game::onUpdate(float deltaTime, const GameInput &input)
camera->getViewDirection())) camera->getViewDirection()))
{ {
auto b = chunkManager.getBlockRaw(rayEnd); auto b = chunkManager.getBlockRaw(rayEnd);
if(b)
{
//std::cout << *b << "\n";
}
if(input.getKey(GameInput::RIGHT_CLICK).isReleased()) if(input.getKey(GameInput::RIGHT_CLICK).isReleased())
{ {

View File

@ -18,7 +18,7 @@
GameInput input; 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)
@ -28,10 +28,10 @@ void keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods
input.setKeyPress(k); input.setKeyPress(k);
} }
else else
if (action == GLFW_RELEASE) if (action == GLFW_RELEASE)
{ {
input.setKeyRelease(k); input.setKeyRelease(k);
} }
}; };
if (key == GLFW_KEY_W || key == GLFW_KEY_UP) if (key == GLFW_KEY_W || key == GLFW_KEY_UP)
@ -80,7 +80,7 @@ void keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods
} }
}; };
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) 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); input.setKeyPress(GameInput::LEFT_CLICK);
} }
else else
if (action == GLFW_RELEASE) if (action == GLFW_RELEASE)
{ {
input.setKeyRelease(GameInput::LEFT_CLICK); input.setKeyRelease(GameInput::LEFT_CLICK);
} }
} }
@ -104,15 +104,15 @@ void mouseCallback(GLFWwindow* window, int key, int action, int mods)
input.setKeyPress(GameInput::RIGHT_CLICK); input.setKeyPress(GameInput::RIGHT_CLICK);
} }
else else
if (action == GLFW_RELEASE) if (action == GLFW_RELEASE)
{ {
input.setKeyRelease(GameInput::RIGHT_CLICK); input.setKeyRelease(GameInput::RIGHT_CLICK);
} }
} }
} }
void windowFocusCallback(GLFWwindow* window, int focused) void windowFocusCallback(GLFWwindow *window, int focused)
{ {
if (!focused) if (!focused)
{ {
@ -120,7 +120,7 @@ void windowFocusCallback(GLFWwindow* window, int focused)
} }
} }
void windowSizeCallback(GLFWwindow* window, int x, int y) void windowSizeCallback(GLFWwindow *window, int x, int y)
{ {
input.resetInputsToZero(); input.resetInputsToZero();
@ -132,13 +132,13 @@ int main()
#ifdef PLATFORM_WIN32 #ifdef PLATFORM_WIN32
#ifdef _MSC_VER #ifdef _MSC_VER
#if INTERNAL_BUILD #if INTERNAL_BUILD
{ {
AllocConsole(); AllocConsole();
auto f1 = freopen("conin$", "r", stdin); auto f1 = freopen("conin$", "r", stdin);
auto f2 = freopen("conout$", "w", stdout); auto f2 = freopen("conout$", "w", stdout);
auto f3 = freopen("conout$", "w", stderr); auto f3 = freopen("conout$", "w", stderr);
std::cout.sync_with_stdio(); std::cout.sync_with_stdio();
} }
#endif #endif
#endif #endif
#endif #endif
@ -177,11 +177,11 @@ int main()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
#pragma region movement #pragma region movement
long newTime = clock(); long newTime = clock();
float deltaTime = (float)(newTime - lastTime) / CLOCKS_PER_SEC; float deltaTime = (float)(newTime - lastTime) / CLOCKS_PER_SEC;
lastTime = clock(); lastTime = clock();
#pragma endregion #pragma endregion
double xMouse, yMouse; double xMouse, yMouse;
glfwGetCursorPos(wind, &xMouse, &yMouse); glfwGetCursorPos(wind, &xMouse, &yMouse);