Compare commits
4 Commits
master
...
3f818cac54
Author | SHA1 | Date | |
---|---|---|---|
3f818cac54 | |||
95988104a1 | |||
2063395cea | |||
7543350dfd |
43
README.md
@ -1,43 +0,0 @@
|
||||
# Nazwa Projektu
|
||||
Projekt z grafiki komputerowej - Interstellar Odyssey
|
||||
|
||||
|
||||
## Opis
|
||||
Interaktywny symulator loty kosmicznego 3D. Celem naszej gry jest zwiedzanie rożnych układów słonecznych.
|
||||
Pokonywanie jak największej ilości wrogów i utrzymywanie się przy życiu za pomocą dostępnych itemków do zebrania.
|
||||
|
||||
|
||||
## Funkcje i możliwości
|
||||
-Physically Based Rendering z mapą normalnych :
|
||||
![normal_map](images/normal_map.png)
|
||||
|
||||
-Sprite Rendering razem z techniką bilboardingu:
|
||||
![sprite_rendering](images/sprite.png)
|
||||
|
||||
- Particle Generator:
|
||||
![Turbo](images/turbo.png)
|
||||
|
||||
- Skybox/Tworzenie wielu galaktyk:
|
||||
![galaktyki](images/galaktyki.png)
|
||||
|
||||
- Strzelanie
|
||||
![strzelanie](images/strzelanie.png)
|
||||
|
||||
- Pas asteroid
|
||||
![pas_asteroid](images/asteroidy.png)
|
||||
|
||||
- Otrzymywanie i zadawanie obrażeń
|
||||
![sprite_dmg](images/sprite_dmg.png)
|
||||
|
||||
- Możliwości uzupełnienia turbo i życia przez zbieranie itemków
|
||||
![hp](images/hp.png)
|
||||
|
||||
oraz dynamiczne poruszanie się statku podczas skrętów, lotów w górę i w dół oraz na ukos
|
||||
|
||||
|
||||
## Skład zespołu
|
||||
Sprite Rendering
|
||||
- Mateusz Kantorski
|
||||
- Paweł Felcyn
|
||||
- Wojciech Goralewski
|
||||
|
@ -61,6 +61,8 @@ public:
|
||||
bool checkCollisionWithGameEntities(std::vector<GameEntity*>& gameEntities, glm::mat4 bulletModelMatrix, float attackerDmg) {
|
||||
for (const auto& entity : gameEntities) {
|
||||
glm::mat4 entityModelMatrix = entity->getModelMatrix();
|
||||
|
||||
// Sprawdź kolizję AABB między pociskiem a obiektem z wektora gameEntities
|
||||
if (checkAABBCollision(bulletModelMatrix, entityModelMatrix)) {
|
||||
entity->applyDamage(attackerDmg);
|
||||
return true;
|
||||
@ -70,7 +72,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
bool checkAABBCollision(const glm::mat4& obj1ModelMatrix, const glm::mat4& obj2ModelMatrix) {
|
||||
|
||||
// Pobierz rozmiary obiektów z ich macierzy modelu
|
||||
glm::vec3 obj1Min = glm::vec3(obj1ModelMatrix * glm::vec4(-0.5f, -0.5f, -0.5f, 1.0f));
|
||||
glm::vec3 obj1Max = glm::vec3(obj1ModelMatrix * glm::vec4(0.5f, 0.5f, 0.5f, 1.0f));
|
||||
|
||||
|
@ -12,20 +12,15 @@ private:
|
||||
std::list<Bullet*> bullets;
|
||||
float lastShootTime = 0.f;
|
||||
float shootInterval = 0.3f;
|
||||
float initAggroRange;
|
||||
|
||||
public:
|
||||
glm::mat4 modelMatrix;
|
||||
float aggroRange;
|
||||
glm::mat4 initialModelMatrix;
|
||||
|
||||
|
||||
Enemy(float currHp,float initialHp, glm::mat4 initialModelMatrix, float initialDmg, float initialAggroRange)
|
||||
:
|
||||
aggroRange(initialAggroRange),
|
||||
modelMatrix(initialModelMatrix),
|
||||
initialModelMatrix(initialModelMatrix),
|
||||
initAggroRange(initialAggroRange),
|
||||
GameEntity(currHp, initialHp, initialDmg)
|
||||
{}
|
||||
|
||||
@ -75,16 +70,7 @@ public:
|
||||
{
|
||||
return modelMatrix;
|
||||
}
|
||||
void respawn() override {
|
||||
this->currentHP = this->maxHP;
|
||||
this->modelMatrix = this->initialModelMatrix;
|
||||
this->aggroRange = this->initAggroRange;
|
||||
this->dmg = this->initDMG;
|
||||
return;
|
||||
}
|
||||
void heal() override {
|
||||
this->currentHP = this->currentHP + 5.0f;
|
||||
}
|
||||
|
||||
private:
|
||||
void requestShoot(float time) {
|
||||
if (canShoot(time)) {
|
||||
@ -98,8 +84,7 @@ private:
|
||||
|
||||
void shoot(float time) {
|
||||
Spaceship* spaceship = Spaceship::getInstance();
|
||||
//glm::vec3 bulletDirection = glm::normalize(spaceship->spaceshipPos - glm::vec3(modelMatrix[3]));
|
||||
glm::vec3 bulletDirection = glm::normalize(glm::vec3(spaceship->getModelMatrix()[3]) - glm::vec3(modelMatrix[3]));
|
||||
glm::vec3 bulletDirection = glm::normalize(spaceship->spaceshipPos - glm::vec3(modelMatrix[3]));
|
||||
//bulletDirection += glm::linearRand(glm::vec3(-0.01f), glm::vec3(0.1f)); // Modyfikacja kierunku o losowy szum
|
||||
this->bullets.push_back(Bullet::createSimpleBullet(bulletDirection, this->modelMatrix[3], time));
|
||||
this->lastShootTime = time;
|
||||
|
@ -7,27 +7,17 @@ public:
|
||||
float currentHP;
|
||||
float dmg;
|
||||
float maxHP;
|
||||
float initDMG;
|
||||
|
||||
GameEntity(float currentHP, float maxHP, float initialDmg)
|
||||
: currentHP(currentHP), maxHP(maxHP), dmg(initialDmg), initDMG(initialDmg)
|
||||
: currentHP(currentHP), maxHP(maxHP), dmg(initialDmg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
virtual void applyDamage(float attackerDmg) {
|
||||
currentHP = currentHP - attackerDmg;
|
||||
};
|
||||
virtual glm::vec3 getPosition() const = 0;
|
||||
virtual glm::mat4 getModelMatrix() = 0;
|
||||
virtual bool isAlive() {
|
||||
if (this->currentHP <= 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
virtual void respawn() = 0;
|
||||
virtual void heal() = 0;
|
||||
};
|
||||
|
||||
|
@ -1,55 +0,0 @@
|
||||
#include "glm.hpp"
|
||||
#include "ext.hpp"
|
||||
#include "src/Render_Utils.h"
|
||||
#include "./GameEntity.h"
|
||||
#include "Spaceship.h"
|
||||
|
||||
#pragma once
|
||||
class Heart : public GameEntity
|
||||
{
|
||||
public:
|
||||
glm::mat4 modelMatrix;
|
||||
glm::mat4 initialModelMatrix;
|
||||
float healAmount = 10;
|
||||
bool isCollected;
|
||||
|
||||
|
||||
Heart(glm::mat4 initialModelMatrix, float healAmount)
|
||||
:
|
||||
modelMatrix(initialModelMatrix),
|
||||
initialModelMatrix(initialModelMatrix),
|
||||
healAmount(healAmount),
|
||||
isCollected(false),
|
||||
GameEntity(1, 1, 0)
|
||||
{}
|
||||
|
||||
|
||||
virtual ~Heart() = default;
|
||||
|
||||
virtual bool isAlive() {
|
||||
if (this->currentHP <= 0) {
|
||||
isCollected = true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
glm::vec3 getPosition() const override
|
||||
{
|
||||
return modelMatrix[3];
|
||||
}
|
||||
glm::mat4 getModelMatrix() override
|
||||
{
|
||||
return modelMatrix;
|
||||
}
|
||||
void respawn() override {
|
||||
this->currentHP = this->maxHP;
|
||||
this->modelMatrix = this->initialModelMatrix;
|
||||
return;
|
||||
}
|
||||
void heal() override {
|
||||
this->currentHP = this->currentHP + 5.0f;
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -1,55 +0,0 @@
|
||||
#include "glm.hpp"
|
||||
#include "ext.hpp"
|
||||
#include "src/Render_Utils.h"
|
||||
#include "./GameEntity.h"
|
||||
#include "Spaceship.h"
|
||||
|
||||
#pragma once
|
||||
class Nitro : public GameEntity
|
||||
{
|
||||
public:
|
||||
glm::mat4 modelMatrix;
|
||||
glm::mat4 initialModelMatrix;
|
||||
float healAmount = 10;
|
||||
bool isCollected;
|
||||
|
||||
|
||||
Nitro(glm::mat4 initialModelMatrix, float healAmount)
|
||||
:
|
||||
modelMatrix(initialModelMatrix),
|
||||
initialModelMatrix(initialModelMatrix),
|
||||
healAmount(healAmount),
|
||||
isCollected(false),
|
||||
GameEntity(1, 1, 0)
|
||||
{}
|
||||
|
||||
|
||||
virtual ~Nitro() = default;
|
||||
|
||||
virtual bool isAlive() {
|
||||
if (this->currentHP <= 0) {
|
||||
isCollected = true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
glm::vec3 getPosition() const override
|
||||
{
|
||||
return modelMatrix[3];
|
||||
}
|
||||
glm::mat4 getModelMatrix() override
|
||||
{
|
||||
return modelMatrix;
|
||||
}
|
||||
void respawn() override {
|
||||
this->currentHP = this->maxHP;
|
||||
this->modelMatrix = this->initialModelMatrix;
|
||||
return;
|
||||
}
|
||||
void heal() override {
|
||||
this->currentHP = this->currentHP + 5.0f;
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -16,8 +16,6 @@ private:
|
||||
glm::mat4 positionMatrix;
|
||||
GLuint textureID;
|
||||
GLuint normalMapID;
|
||||
float startEulerYRotation = 0.f;
|
||||
float startYMovement = 0.f;
|
||||
|
||||
public:
|
||||
Planet(GameObject* center, float distanceFromCenter, float rotationSpeed, float scale, Core::RenderContext sphereContext, GLuint textureID, GLuint normalMapID) {
|
||||
@ -41,16 +39,8 @@ public:
|
||||
}
|
||||
|
||||
float rotationAngle = glm::radians(time * rotationSpeed);
|
||||
positionMatrix = center->getPositionMatrix() * glm::eulerAngleY(time * rotationSpeed + startEulerYRotation) * glm::translate(glm::vec3(distanceFromCenter, startYMovement, 0));
|
||||
positionMatrix = center->getPositionMatrix() * glm::eulerAngleY(time * rotationSpeed) * glm::translate(glm::vec3(distanceFromCenter, 0, 0));
|
||||
glm::mat4 modelMatrix = positionMatrix * glm::scale(glm::vec3(scale));
|
||||
Core::drawObjectPBRTexture(sphereContext, modelMatrix, textureID, normalMapID, 0.7, 0.0, program);
|
||||
}
|
||||
|
||||
void setStarteulerYRotation(float radians) {
|
||||
startEulerYRotation = radians;
|
||||
}
|
||||
|
||||
void setStartYMovement(float value) {
|
||||
startYMovement = value;
|
||||
}
|
||||
};
|
@ -36,12 +36,12 @@ public:
|
||||
}
|
||||
|
||||
glm::vec3 color = glm::vec3(0.3, 0.3, 0.5);
|
||||
float roughness = 0.5;
|
||||
float metallic = 0.6;
|
||||
float roughness = 0.2;
|
||||
float metallic = 1.0;
|
||||
float turbo = 1.0f;
|
||||
float turboMAX = 1.0f;
|
||||
|
||||
glm::vec3 spaceshipPos = glm::vec3(4.065808f, 10.250000f, -20.189549f);
|
||||
glm::vec3 spaceshipPos /*= glm::vec3(0.065808f, 1.250000f, -2.189549f)*/;
|
||||
glm::vec3 spaceshipDir = glm::vec3(-0.490263f, 0.000000f, 0.871578f);
|
||||
|
||||
glm::vec3 spotlightPos = glm::vec3(0, 0, 0);
|
||||
@ -225,21 +225,21 @@ public:
|
||||
if (w == GLFW_PRESS) {
|
||||
if (shiftState == GLFW_PRESS) {
|
||||
|
||||
turbo = glm::max(0.0f, turbo - 0.003f * deltaTime * 60);
|
||||
turbo = glm::max(0.0f, turbo - 0.004f * deltaTime * 60);
|
||||
if (turbo == 0.0f) {
|
||||
shiftState = GLFW_RELEASE;
|
||||
moveSpeed = 0.05f * deltaTime * 60;
|
||||
setPerticlesParameters(100.f, 0.000001f);
|
||||
setPerticlesParameters(100.f, 0.0001f);
|
||||
}
|
||||
else {
|
||||
moveSpeed *= 2;
|
||||
setPerticlesParameters(200.f, 0.0000005f);
|
||||
setPerticlesParameters(200.f, 0.00005f);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
setPerticlesParameters(100.f, 0.000001f);
|
||||
setPerticlesParameters(100.f, 0.0001f);
|
||||
turbo = glm::min(turboMAX, turbo + 0.001f * deltaTime * 60);
|
||||
}
|
||||
}
|
||||
@ -274,7 +274,7 @@ public:
|
||||
cameraPosHUDBar = spaceshipPos - 1.f * spaceshipDir + glm::vec3(0, 1, 0) * 0.2f;
|
||||
|
||||
cameraDir = spaceshipDir;
|
||||
glm::vec3 perpendicularVector = 0.08f * glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.0f, 1.0f, 0.0f)));
|
||||
glm::vec3 perpendicularVector = 0.04f * glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.0f, 1.0f, 0.0f)));
|
||||
if (leftParticle != nullptr && rightParticle != nullptr) {
|
||||
leftParticle->sourcePosition = spaceshipPos + perpendicularVector - (0.25f * spaceshipDir);
|
||||
rightParticle->sourcePosition = spaceshipPos - perpendicularVector - (0.25f * spaceshipDir);
|
||||
@ -386,20 +386,4 @@ public:
|
||||
|
||||
return cameraMatrix;
|
||||
}
|
||||
|
||||
void respawn() override {
|
||||
this->currentHP = this->maxHP;
|
||||
this->turbo = this->turboMAX;
|
||||
this->spaceshipPos = glm::vec3(4.065808f, 10.250000f, -20.189549f);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void heal() override {
|
||||
this->currentHP = this->currentHP + 3.f;
|
||||
}
|
||||
|
||||
void turboBoost() {
|
||||
this->turbo = this->turboMAX;
|
||||
}
|
||||
};
|
@ -32,8 +32,6 @@
|
||||
<ClInclude Include="GameEntity.h" />
|
||||
<ClInclude Include="GameObject.h" />
|
||||
<ClInclude Include="GameUtils.h" />
|
||||
<ClInclude Include="Heart.h" />
|
||||
<ClInclude Include="Nitro.h" />
|
||||
<ClInclude Include="ParticleSystem.h" />
|
||||
<ClInclude Include="Planet.h" />
|
||||
<ClInclude Include="Spaceship.h" />
|
||||
|
@ -59,7 +59,7 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="SpriteRenderer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Source.cpp">
|
||||
<Filter>Shader Files</Filter>
|
||||
</ClCompile>
|
||||
@ -123,20 +123,14 @@
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SpriteRenderer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ParticleSystem.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GameEntity.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Heart.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Nitro.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="shaders\shader_8_sun.vert">
|
||||
@ -169,14 +163,14 @@
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="shaders\shader_sprite.vert">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="shaders\shader_tex.frag">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="shaders\shader_tex.vert">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="shaders\shader_tex.frag">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="shaders\shader_tex.vert">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="particle.frag">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
|
@ -102,17 +102,8 @@ void main()
|
||||
|
||||
vec4 texColor = texture(textureSampler, TexCoords);
|
||||
|
||||
|
||||
vec3 normalMapNormal = texture(normalSampler, TexCoords).xyz;
|
||||
normalMapNormal = normalMapNormal * 2.0 - 1.0;
|
||||
//normalMapNormal.y = -normalMapNormal.y;
|
||||
|
||||
vec3 normal = normalize(normalMapNormal * TBN );
|
||||
|
||||
//vec3 normal = normalize(texture(normalSampler, TexCoords).xyz * TBN);
|
||||
vec3 normal = normalize(texture(normalSampler, TexCoords).xyz * TBN);
|
||||
//vec3 normal = normalize(vecNormal);
|
||||
|
||||
|
||||
vec3 viewDir = normalize(cameraPos-worldPos);
|
||||
|
||||
vec3 lightDirs[4];
|
||||
|
@ -6,10 +6,11 @@
|
||||
#include <cmath>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <random>
|
||||
|
||||
#include "Shader_Loader.h"
|
||||
#include "Render_Utils.h"
|
||||
#include "texture.h"
|
||||
|
||||
#include "Box.cpp"
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/scene.h>
|
||||
@ -22,13 +23,9 @@
|
||||
#include "../GameUtils.h"
|
||||
#include "../SpriteRenderer.h"
|
||||
#include "../Enemy.h"
|
||||
#include "../Heart.h"
|
||||
#include "../Nitro.h"
|
||||
|
||||
#include "../ParticleSystem.h"
|
||||
#include "Camera.h"
|
||||
#include <random>
|
||||
|
||||
|
||||
#ifndef EX_9_1_HPP
|
||||
#define EX_9_1_HPP
|
||||
@ -46,7 +43,6 @@ namespace models {
|
||||
Core::RenderContext spaceshipContext;
|
||||
Core::RenderContext sphereContext;
|
||||
Core::RenderContext cubeContext;
|
||||
Core::RenderContext asteroid;
|
||||
}
|
||||
namespace texture {
|
||||
GLuint cubemapTexture;
|
||||
@ -54,10 +50,6 @@ namespace texture {
|
||||
GLuint spaceshipNormal;
|
||||
GLuint spriteTexture;
|
||||
GLuint earthTexture;
|
||||
GLuint asteroidTexture;
|
||||
GLuint asteroidNormal;
|
||||
GLuint heartTexture;
|
||||
GLuint boosterTexture;
|
||||
}
|
||||
|
||||
struct TextureTuple {
|
||||
@ -86,8 +78,6 @@ std::list<Planet*> planets;
|
||||
Sun* sun;
|
||||
GLuint VAO,VBO;
|
||||
|
||||
std::vector<Nitro*> nitros;
|
||||
std::vector<Heart*> hearts;
|
||||
std::vector<Enemy*> enemies;
|
||||
std::vector<GameEntity*> gameEntities;
|
||||
|
||||
@ -103,17 +93,6 @@ Spaceship* spaceship = Spaceship::getInstance();
|
||||
void createSolarSystem(glm::vec3 sunPos, GLuint sunTexId,float sunScale, float* planetSizes, int numberOfPlanets, float planetsDistance, float planetSpeedCoef);
|
||||
Core::SpriteRenderer* spriteRenderer;
|
||||
|
||||
const int ENEMY_COUNT = 20;
|
||||
std::vector<glm::vec3> referencePoints = {
|
||||
glm::vec3(0, 2, 0),
|
||||
glm::vec3(150, 5, 0),
|
||||
glm::vec3(-20, -30, 50),
|
||||
glm::vec3(100, 20, -50),
|
||||
glm::vec3(0, 52, 200),
|
||||
glm::vec3(150, 55, 200),
|
||||
glm::vec3(-20, 20, 250),
|
||||
glm::vec3(100, 70, 150)
|
||||
};
|
||||
void updateDeltaTime(float time) {
|
||||
if (lastTime < 0) {
|
||||
lastTime = time;
|
||||
@ -158,66 +137,7 @@ void renderHUD(GLFWwindow* window) {
|
||||
programSpriteBar);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
bool isFarFromReferencePoints(float x, float y, float z, const std::vector<glm::vec3>& referencePoints) {
|
||||
float minDistance = 10.0f;
|
||||
|
||||
glm::vec3 currentPoint(x, y, z);
|
||||
|
||||
auto checkDistance = [currentPoint, minDistance](const glm::vec3& referencePoint) {
|
||||
return glm::distance(currentPoint, referencePoint) > minDistance;
|
||||
};
|
||||
|
||||
for (const auto& referencePoint : referencePoints) {
|
||||
if (!checkDistance(referencePoint)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
glm::mat4 generateRandomMatrix(const glm::mat4& startMatrix) {
|
||||
std::random_device rd;
|
||||
std::mt19937 gen(rd());
|
||||
std::uniform_real_distribution<float> disX(-30.0f, 180.0f);
|
||||
std::uniform_real_distribution<float> disY(-50.0f, 60.0f);
|
||||
std::uniform_real_distribution<float> disZ(-30.0f, 210.0f);
|
||||
float randomX, randomY, randomZ;
|
||||
|
||||
do {
|
||||
randomX = disX(gen);
|
||||
randomY = disY(gen);
|
||||
randomZ = disZ(gen);
|
||||
} while (!isFarFromReferencePoints(randomX, randomY, randomZ, referencePoints));
|
||||
|
||||
glm::mat4 randomModelMatrix = glm::translate(startMatrix, glm::vec3(randomX, randomY, randomZ));
|
||||
|
||||
|
||||
return randomModelMatrix;
|
||||
}
|
||||
void renderEnemies() {
|
||||
int counter = 0;
|
||||
glUseProgram(program);
|
||||
for (const auto& enemy : enemies) {
|
||||
if (enemy->isAlive()) {
|
||||
enemy->attack(spaceship->spaceshipPos, glfwGetTime());
|
||||
enemy->renderBullets(glfwGetTime(), program, gameEntities);
|
||||
}
|
||||
else {
|
||||
counter++;
|
||||
}
|
||||
|
||||
}
|
||||
if (counter >= ENEMY_COUNT / 2) {
|
||||
for (const auto& enemy : enemies) {
|
||||
if (!enemy->isAlive()) {
|
||||
enemy->initialModelMatrix = generateRandomMatrix(enemy->getModelMatrix());
|
||||
enemy->respawn();
|
||||
enemy->aggroRange *= 1.1;
|
||||
enemy->dmg *= 1.2;
|
||||
}
|
||||
}
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
glUseProgram(programSpriteBar);
|
||||
for (const auto& enemy : enemies) {
|
||||
@ -241,47 +161,16 @@ void renderEnemies() {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void renderHeartsAndNitro() {
|
||||
//if (heart->isAlive()) {
|
||||
//spriteRenderer->DrawSprite(texture::heartTexture, heart->modelMatrix, programSprite);
|
||||
//}
|
||||
|
||||
glUseProgram(programSprite);
|
||||
for (auto it = hearts.begin(); it != hearts.end();) {
|
||||
Heart* heart = *it;
|
||||
if (heart->isAlive()) {
|
||||
spriteRenderer->DrawSprite(texture::heartTexture, heart->modelMatrix, programSprite);
|
||||
}
|
||||
|
||||
if (heart->isCollected) {
|
||||
spaceship->heal();
|
||||
it = hearts.erase(it);
|
||||
}
|
||||
else {
|
||||
++it;
|
||||
}
|
||||
glUseProgram(program);
|
||||
for (const auto& enemy : enemies) {
|
||||
if (enemy->isAlive()) {
|
||||
enemy->attack(spaceship->spaceshipPos, glfwGetTime());
|
||||
enemy->renderBullets(glfwGetTime(), program, gameEntities);
|
||||
}
|
||||
|
||||
for (auto it = nitros.begin(); it != nitros.end();) {
|
||||
Nitro* nitro = *it;
|
||||
if (nitro->isAlive()) {
|
||||
spriteRenderer->DrawSprite(texture::boosterTexture, nitro->modelMatrix, programSprite);
|
||||
}
|
||||
}
|
||||
|
||||
if (nitro->isCollected) {
|
||||
spaceship->turboBoost();
|
||||
it = nitros.erase(it);
|
||||
}
|
||||
else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
TextureTuple getRandomPlanetTexture() {
|
||||
int textureIndex = rand() % planetTextures.size();
|
||||
TextureTuple selectedTextures = planetTextures[textureIndex];
|
||||
@ -326,13 +215,8 @@ void renderScene(GLFWwindow* window)
|
||||
glUseProgram(program);
|
||||
|
||||
std::vector<GameEntity*> gameEntities(enemies.begin(), enemies.end());
|
||||
//spaceship->renderBullets(glfwGetTime(), program, gameEntities);
|
||||
|
||||
gameEntities.insert(gameEntities.end(), hearts.begin(), hearts.end());
|
||||
gameEntities.insert(gameEntities.end(), nitros.begin(), nitros.end());
|
||||
spaceship->renderBullets(glfwGetTime(), program, gameEntities);
|
||||
|
||||
|
||||
drawObjectPBR(models::sphereContext,
|
||||
glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::eulerAngleY(time) * glm::translate(glm::vec3(1.f, 0, 0)) * glm::scale(glm::vec3(0.1f)),
|
||||
glm::vec3(0.5, 0.5, 0.5), 0.7, 0.0, program);
|
||||
@ -374,17 +258,10 @@ void renderScene(GLFWwindow* window)
|
||||
glm::mat4 viewMatrix = Core::createViewMatrix(spaceship->cameraPos, spaceship->cameraDir, cameraUp);
|
||||
spaceship->renderParticles(programParticle, viewMatrix, Core::createPerspectiveMatrix(), time);
|
||||
|
||||
if(!spaceship->isAlive()){
|
||||
spaceship->respawn();
|
||||
for (const auto& enemy : enemies) {
|
||||
enemy->respawn();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
renderHUD(window);
|
||||
renderEnemies();
|
||||
renderHeartsAndNitro();
|
||||
|
||||
//drawObjectPBR(sphereContext, glm::translate(pointlightPos) * glm::scale(glm::vec3(1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(10.f, 0, 0)) * glm::scale(glm::vec3(0.3f)), glm::vec3(0.2, 0.7, 0.3), 0.3, 0.0, program);
|
||||
|
||||
|
||||
@ -404,32 +281,6 @@ void createSuns() {
|
||||
createGalaxy(glm::vec3(0.f, 50.f, 200.f));
|
||||
}
|
||||
|
||||
float generateRandomFloat(float minValue, float maxValue) {
|
||||
return minValue + static_cast <float> (rand()) / (static_cast <float> (RAND_MAX / (maxValue - minValue)));
|
||||
}
|
||||
|
||||
|
||||
void createAsteroids() {
|
||||
GameUtils* gu = GameUtils::getInstance();
|
||||
GameObject* center = gu->getSuns()->front();
|
||||
float minDistanceFromCenter = 24.f;
|
||||
float maxDistanceFromCenter = 26.f;
|
||||
float rotationSpeed = 0.05f;
|
||||
float scale = 0.002f;
|
||||
int numAsteroids = 80;
|
||||
float distanceIncrement = 2.f / (minDistanceFromCenter + 1);
|
||||
|
||||
for (int j = -1; j < 2; j++) {
|
||||
for (int i = 0; i < numAsteroids; ++i) {
|
||||
float distanceFromCenter = generateRandomFloat(minDistanceFromCenter, maxDistanceFromCenter);
|
||||
Planet* asteroid = new Planet(center, distanceFromCenter, rotationSpeed, scale, models::asteroid, texture::asteroidTexture, texture::asteroidNormal);
|
||||
asteroid->setStarteulerYRotation(distanceIncrement * i);
|
||||
asteroid->setStartYMovement(generateRandomFloat(-0.5f, 0.5f) + j);
|
||||
planets.push_back(asteroid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void createGalaxy(glm::vec3 galaxyPosition) {
|
||||
float planetsSizes[] = { 1.f, 1.5f, 0.8f, 1.2f, 0.2f };
|
||||
GLuint sunTexId = sunTexturesIds[0];
|
||||
@ -443,7 +294,6 @@ void createGalaxy(glm::vec3 galaxyPosition) {
|
||||
float planetSizes4[] = { 1.f, 0.5f };
|
||||
GLuint sunTexId4 = sunTexturesIds[3];
|
||||
createSolarSystem(galaxyPosition + glm::vec3(100, 20, -50), sunTexId4, 5, planetsSizes3, 2, 25.f, 0.2f);
|
||||
createAsteroids();
|
||||
}
|
||||
|
||||
void createSolarSystem(glm::vec3 sunPos, GLuint sunTexId, float sunScale, float* planetSizes, int numberOfPlanets, float planetsDistance, float planetSpeedCoef) {
|
||||
@ -459,36 +309,18 @@ void createSolarSystem(glm::vec3 sunPos, GLuint sunTexId, float sunScale, float*
|
||||
planets.push_back(planet);
|
||||
}
|
||||
}
|
||||
|
||||
void createEnemies() {
|
||||
|
||||
//enemies.push_back(new Enemy(100.0f,100.0f, glm::mat4(1.0f), 1.0f, 5.0f));
|
||||
//enemies.push_back(new Enemy(100.0f,100.0f, glm::translate(glm::mat4(1.0f) , glm::vec3(1.f,1.f,1.f)), 1.0f, 5.0f));
|
||||
//enemies.push_back(new Enemy(100.0f,100.0f, glm::translate(glm::mat4(1.0f), glm::vec3(-1.f, 2.f, -0.9f)), 1.0f, 5.0f));
|
||||
int j = 0;
|
||||
enemies.push_back(new Enemy(100.0f, 100.0f, glm::translate(glm::translate(glm::mat4(1.0f), spaceship->getPosition()), glm::vec3(1.f, 1.f, 2.f)), 1.0f, 5.0f));
|
||||
for (int i = 0; i < ENEMY_COUNT; ++i) {
|
||||
|
||||
glm::mat4 randomModelMatrix = generateRandomMatrix(glm::mat4(1.0f));
|
||||
enemies.push_back(new Enemy(100.0f, 100.0f, randomModelMatrix, 1.0f, 8.0f));
|
||||
|
||||
if (j % 4 == 0) {
|
||||
hearts.push_back(new Heart(glm::translate(randomModelMatrix, glm::vec3(6.f, 5.f, 8.f)), -5.0f));
|
||||
nitros.push_back(new Nitro(glm::translate(randomModelMatrix, glm::vec3(2.f, -9.f, 3.f)), 10.0f));
|
||||
}
|
||||
j = j + 1;
|
||||
}
|
||||
|
||||
hearts.push_back(new Heart(glm::translate(glm::mat4(1.0f), glm::vec3(25.f, 20.f, 25.f)), 10.0f));
|
||||
nitros.push_back(new Nitro(glm::translate(glm::mat4(1.0f), glm::vec3(20.f, 20.f, 25.f)), 10.0f));
|
||||
enemies.push_back(new Enemy(100.0f,100.0f, glm::mat4(1.0f), 1.0f, 5.0f));
|
||||
enemies.push_back(new Enemy(100.0f,100.0f, glm::translate(glm::mat4(1.0f) , glm::vec3(1.f,1.f,1.f)), 1.0f, 5.0f));
|
||||
enemies.push_back(new Enemy(100.0f,100.0f, glm::translate(glm::mat4(1.0f), glm::vec3(-1.f, 2.f, -0.9f)), 1.0f, 5.0f));
|
||||
|
||||
//obiekty do ktorych bedzie sprawdzana kolizja dla pociskow enemy
|
||||
gameEntities.push_back(spaceship);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void loadPlanetsAndSunTextures() {
|
||||
planetTextures.clear();
|
||||
|
||||
@ -546,7 +378,6 @@ void init(GLFWwindow* window)
|
||||
loadModelToContext("./models/sphere.obj", models::sphereContext);
|
||||
loadModelToContext("./models/cube.obj", models::cubeContext);
|
||||
Core::loadModelToContext("./models/sphere.obj", GameUtils::getInstance()->sphereContext);
|
||||
Core::loadModelToContext("./models/Asteroid.obj", models::asteroid);
|
||||
|
||||
texture::spriteTexture = Core::LoadTexture("textures/blinky1.png");
|
||||
|
||||
@ -564,10 +395,6 @@ void init(GLFWwindow* window)
|
||||
texture::spaceshipTexture = Core::LoadTexture("./textures/spaceship/Material.001_Base_color.jpg");
|
||||
texture::spaceshipNormal = Core::LoadTexture("./textures/spaceship/Material.001_Normal_DirectX.jpg");
|
||||
texture::earthTexture = Core::LoadTexture("./textures/planets/8k_earth_daymap.jpg");
|
||||
texture::asteroidTexture = Core::LoadTexture("./textures/asteroids/asteroidtx.jpg");
|
||||
texture::asteroidNormal = Core::LoadTexture("./textures/asteroids/asteroidnn.png");
|
||||
texture::heartTexture = Core::LoadTexture("textures/heart.png");
|
||||
texture::boosterTexture = Core::LoadTexture("textures/boooster.png");
|
||||
|
||||
spaceship->createParticles();
|
||||
createSuns();
|
||||
|
Before Width: | Height: | Size: 5.8 MiB |
Before Width: | Height: | Size: 941 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 2.2 MiB |
Before Width: | Height: | Size: 356 KiB |
BIN
images/hp.png
Before Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 2.2 MiB |
Before Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 283 KiB |
BIN
images/turbo.png
Before Width: | Height: | Size: 448 KiB |