zatrzymanie statku po kolizji

This commit is contained in:
Kamil Ryżek 2024-03-01 16:57:15 +01:00
parent 83173bfbdd
commit 82a1d0ce8a

View File

@ -8,7 +8,6 @@
#include "Shader_Loader.h"
#include "Render_Utils.h"
#include "Texture.h"
//#include "../SpriteRenderer.h"
#include "Box.cpp"
#include <assimp/Importer.hpp>
@ -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<Planet> planets;
std::vector<Satellite> 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();
}
}