From 82a1d0ce8af32ea09361990c0c4d4f92a6c2fddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Ry=C5=BCek?= Date: Fri, 1 Mar 2024 16:57:15 +0100 Subject: [PATCH] zatrzymanie statku po kolizji --- projekt_grk/src/ex_7_1.hpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/projekt_grk/src/ex_7_1.hpp b/projekt_grk/src/ex_7_1.hpp index d691cec..53caafc 100644 --- a/projekt_grk/src/ex_7_1.hpp +++ b/projekt_grk/src/ex_7_1.hpp @@ -8,7 +8,6 @@ #include "Shader_Loader.h" #include "Render_Utils.h" #include "Texture.h" -//#include "../SpriteRenderer.h" #include "Box.cpp" #include @@ -58,7 +57,6 @@ GLuint programSun; GLuint programTex; GLuint programSkyBox; GLuint programSpaceShip; -GLuint programSprite; Core::Shader_Loader shaderLoader; @@ -79,6 +77,8 @@ unsigned int textureID; bool gameOver = false; +float angleSpeed = 0.005f; +float moveSpeed = 0.0025f; struct Planet { glm::vec3 currentPos; @@ -104,6 +104,8 @@ struct Satellite { std::vector planets; std::vector satellites; + + glm::mat4 createCameraMatrix() { glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir,glm::vec3(0.f,1.f,0.f))); @@ -398,6 +400,8 @@ void renderScene(GLFWwindow* window) ); glUseProgram(0); + + glfwSwapBuffers(window); } void framebuffer_size_callback(GLFWwindow* window, int width, int height) @@ -497,8 +501,10 @@ void init(GLFWwindow* window) } + void gameOverScreen(GLFWwindow* window) { - // jakies game over dla jego + moveSpeed = 0; + angleSpeed = 0; } void shutdown(GLFWwindow* window) @@ -512,8 +518,8 @@ void processInput(GLFWwindow* window) glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f))); glm::vec3 spaceshipUp = glm::vec3(0.f, 1.f, 0.f); - float angleSpeed = 0.005f; - float moveSpeed = 0.0025f; + //float angleSpeed = 0.005f; + //float moveSpeed = 0.0025f; if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) { glfwSetWindowShouldClose(window, true); } @@ -543,8 +549,8 @@ void processInput(GLFWwindow* window) void renderLoop(GLFWwindow* window) { - - double timeOfLastUpdate = glfwGetTime(); + + float timeOfLastUpdate = glfwGetTime(); int loopCount = 0; int interval = 2500; @@ -567,6 +573,7 @@ void renderLoop(GLFWwindow* window) { if (checkCollision(spaceshipPos, satellite.currentPos, satellite.modelScale)) { //placeholder + gameOver = true; std::cout << "Kolizja statku z satelita " << index << std::endl; } ++index; @@ -585,6 +592,7 @@ void renderLoop(GLFWwindow* window) { if (gameOver) { gameOverScreen(window); } + glfwPollEvents(); } }