księżyc generuje sie jako satelita ziemi, kolizja z ksiezycem i sloncem
This commit is contained in:
parent
476427bce3
commit
83173bfbdd
@ -8,6 +8,7 @@
|
||||
#include "Shader_Loader.h"
|
||||
#include "Render_Utils.h"
|
||||
#include "Texture.h"
|
||||
//#include "../SpriteRenderer.h"
|
||||
|
||||
#include "Box.cpp"
|
||||
#include <assimp/Importer.hpp>
|
||||
@ -47,6 +48,8 @@ namespace texture {
|
||||
|
||||
GLuint grid;
|
||||
|
||||
GLuint gameOverSprite;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -55,6 +58,8 @@ GLuint programSun;
|
||||
GLuint programTex;
|
||||
GLuint programSkyBox;
|
||||
GLuint programSpaceShip;
|
||||
GLuint programSprite;
|
||||
|
||||
Core::Shader_Loader shaderLoader;
|
||||
|
||||
Core::RenderContext shipContext;
|
||||
@ -72,6 +77,7 @@ GLuint VAO,VBO;
|
||||
float aspectRatio = 1.f;
|
||||
unsigned int textureID;
|
||||
|
||||
bool gameOver = false;
|
||||
|
||||
|
||||
struct Planet {
|
||||
@ -84,8 +90,19 @@ struct Planet {
|
||||
GLuint normalTexture;
|
||||
};
|
||||
|
||||
struct Satellite {
|
||||
glm::vec3 currentPos;
|
||||
glm::vec3 modelScale;
|
||||
float rotationSpeed; // ruch obrotowy
|
||||
float orbitSpeed; // ruch obiegowy
|
||||
float orbitRadius;
|
||||
GLuint texture;
|
||||
GLuint normalTexture;
|
||||
Planet parentPlanet;
|
||||
};
|
||||
|
||||
std::vector<Planet> planets;
|
||||
std::vector<Satellite> satellites;
|
||||
|
||||
glm::mat4 createCameraMatrix()
|
||||
{
|
||||
@ -288,7 +305,8 @@ void initializePlanets() {
|
||||
planets.push_back(Planet{ glm::vec3(12.5f, 0, 0), glm::vec3(0.7f), 2.4f, 1.0f / 10, 12.5f, texture::saturn, texture::saturnNormal });
|
||||
planets.push_back(Planet{ glm::vec3(15.f, 0, 0), glm::vec3(1.f), 1.7f, 1.0f / 15, 15.f, texture::uranus, texture::uranusNormal });
|
||||
planets.push_back(Planet{ glm::vec3(20.f, 0, 0), glm::vec3(1.f), 1.2f, 1.0f / 24, 20.f, texture::neptune, texture::neptuneNormal });
|
||||
|
||||
planets.push_back(Planet{ glm::vec3(0, 0, 0), glm::vec3(1.f), 0.f, 0.f, 0.f, texture::sun, texture::sun });
|
||||
satellites.push_back(Satellite{ glm::vec3(5.0f, 0, 0), glm::vec3(0.055f), 1.f / 2, 1.0f / 2, 0.8f, texture::moon, texture::asteroidNormal, planets[2] });
|
||||
}
|
||||
|
||||
void printPlanetPos() {
|
||||
@ -344,10 +362,20 @@ void renderScene(GLFWwindow* window)
|
||||
|
||||
}
|
||||
|
||||
drawObjectTexture(sphereContext,
|
||||
for (auto& satellite : satellites) {
|
||||
glm::mat4 modelMatrix = glm::eulerAngleY(time * satellite.parentPlanet.orbitSpeed)
|
||||
* glm::translate(glm::vec3(satellite.parentPlanet.orbitRadius, 0, 0))
|
||||
* glm::eulerAngleY(time * satellite.rotationSpeed)
|
||||
* glm::translate(glm::vec3(satellite.orbitRadius, 0, 0))
|
||||
* glm::scale(glm::vec3(satellite.modelScale));
|
||||
drawObjectTexture(sphereContext, modelMatrix, satellite.texture, satellite.normalTexture);
|
||||
satellite.currentPos = glm::vec3(modelMatrix * glm::vec4(0, 0, 0, 1.0f));
|
||||
}
|
||||
|
||||
/*drawObjectTexture(sphereContext,
|
||||
glm::eulerAngleY(time * planets[2].orbitSpeed) * glm::translate(glm::vec3(planets[2].orbitRadius, 0, 0)) * glm::eulerAngleY(time * 0.5f) * glm::translate(glm::vec3(0.8f, 0, 0)) * glm::scale(glm::vec3(0.055f)),
|
||||
texture::moon,
|
||||
texture::asteroidNormal);
|
||||
texture::asteroidNormal);*/
|
||||
|
||||
// obliczanie orientacji statku
|
||||
glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
|
||||
@ -469,6 +497,10 @@ void init(GLFWwindow* window)
|
||||
|
||||
}
|
||||
|
||||
void gameOverScreen(GLFWwindow* window) {
|
||||
// jakies game over dla jego
|
||||
}
|
||||
|
||||
void shutdown(GLFWwindow* window)
|
||||
{
|
||||
shaderLoader.DeleteProgram(program);
|
||||
@ -520,13 +552,24 @@ void renderLoop(GLFWwindow* window) {
|
||||
{
|
||||
processInput(window);
|
||||
renderScene(window);
|
||||
int index = 0;
|
||||
|
||||
for (auto& planet : planets) {
|
||||
|
||||
if (checkCollision(spaceshipPos, planet.currentPos, planet.modelScale)) {
|
||||
//placeholder
|
||||
std::cout << "Kolizja statku z planeta " << planet.texture << std::endl;
|
||||
gameOver = true;
|
||||
std::cout << "Kolizja statku z planeta " << index << std::endl;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
for (auto& satellite : satellites) {
|
||||
|
||||
if (checkCollision(spaceshipPos, satellite.currentPos, satellite.modelScale)) {
|
||||
//placeholder
|
||||
std::cout << "Kolizja statku z satelita " << index << std::endl;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
|
||||
|
||||
@ -539,6 +582,9 @@ void renderLoop(GLFWwindow* window) {
|
||||
timeOfLastUpdate = glfwGetTime();
|
||||
}
|
||||
|
||||
if (gameOver) {
|
||||
gameOverScreen(window);
|
||||
}
|
||||
glfwPollEvents();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user