Compare commits

..

21 Commits

Author SHA1 Message Date
e3b66ef977 Merge pull request 'final commit' (#21) from final_comit into master
Reviewed-on: #21
2024-02-08 19:54:38 +01:00
Wojtek
3dc84f2df1 final commit 2024-02-08 19:51:39 +01:00
f28de5f2be Merge pull request 'hearts' (#20) from hearts into master
Reviewed-on: #20
2024-02-08 05:10:34 +01:00
Wojtek
abf896ce6d nitroes 2 2024-02-08 04:55:27 +01:00
Wojtek
a49a76f8ef nitroes 2024-02-08 04:54:48 +01:00
Wojtek
1421b90c66 Opis projektu 2024-02-08 04:44:22 +01:00
630438b1bc Merge pull request 'enemies_placement' (#19) from enemies_placement into master
Reviewed-on: #19
2024-02-08 00:44:07 +01:00
5d2405774b Add starter enemy 2024-02-08 00:43:24 +01:00
23b1f0c124 Add constant enemies respawn when half of them is defeated 2024-02-08 00:23:07 +01:00
6737f14356 Add respawn for spaceship and enemies 2024-02-07 23:44:53 +01:00
de54348411 Merge pull request 'asteroids' (#18) from satellites into master
Reviewed-on: #18
2024-02-07 23:14:35 +01:00
Pawel Felcyn
d949505204 asteroids 2024-02-07 23:13:51 +01:00
91c2dca35b Change spaceship starting position and lower nitro consumption 2024-02-07 22:54:19 +01:00
1579e92b35 Add random location enemy generator 2024-02-07 22:46:33 +01:00
ebbda6e21e Merge pull request 'enemies_placement' (#17) from enemies_placement into master
Reviewed-on: #17
2024-02-07 16:32:08 +01:00
7c410aee09 Add turbo bar 2024-02-07 16:29:16 +01:00
598d709910 Fix healthbar is visible in maximized window 2024-02-07 16:26:33 +01:00
dc73f3b5f1 Fix hud bars are no longer moving and rotating with spaceship movement 2024-02-07 16:26:33 +01:00
6f85812a35 Change window size to 1920x1080 2024-02-07 16:26:33 +01:00
1f70717502 Merge pull request 'normal map on ship' (#15) from fix_normal_map into master
Reviewed-on: #15
2024-02-07 14:02:31 +01:00
Wojtek
ec331f322b normal map on ship 2024-02-07 13:59:41 +01:00
26 changed files with 1886 additions and 41 deletions

BIN
Opis_Projektu.pdf Normal file

Binary file not shown.

43
README.md Normal file
View File

@ -0,0 +1,43 @@
# 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

View File

@ -61,8 +61,6 @@ 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;
@ -72,7 +70,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));

View File

@ -12,15 +12,20 @@ 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)
{}
@ -70,7 +75,16 @@ 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)) {
@ -84,7 +98,8 @@ 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(spaceship->spaceshipPos - glm::vec3(modelMatrix[3]));
glm::vec3 bulletDirection = glm::normalize(glm::vec3(spaceship->getModelMatrix()[3]) - 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;

View File

@ -7,17 +7,27 @@ public:
float currentHP;
float dmg;
float maxHP;
float initDMG;
GameEntity(float currentHP, float maxHP, float initialDmg)
: currentHP(currentHP), maxHP(maxHP), dmg(initialDmg)
: currentHP(currentHP), maxHP(maxHP), dmg(initialDmg), initDMG(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;
};

55
grk/project/Heart.h Normal file
View File

@ -0,0 +1,55 @@
#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;
}
};

55
grk/project/Nitro.h Normal file
View File

@ -0,0 +1,55 @@
#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;
}
};

View File

@ -16,6 +16,8 @@ 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) {
@ -39,8 +41,16 @@ public:
}
float rotationAngle = glm::radians(time * rotationSpeed);
positionMatrix = center->getPositionMatrix() * glm::eulerAngleY(time * rotationSpeed) * glm::translate(glm::vec3(distanceFromCenter, 0, 0));
positionMatrix = center->getPositionMatrix() * glm::eulerAngleY(time * rotationSpeed + startEulerYRotation) * glm::translate(glm::vec3(distanceFromCenter, startYMovement, 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;
}
};

View File

@ -36,12 +36,12 @@ public:
}
glm::vec3 color = glm::vec3(0.3, 0.3, 0.5);
float roughness = 0.2;
float metallic = 1.0;
float roughness = 0.5;
float metallic = 0.6;
float turbo = 1.0f;
float turboMAX = 1.0f;
glm::vec3 spaceshipPos /*= glm::vec3(0.065808f, 1.250000f, -2.189549f)*/;
glm::vec3 spaceshipPos = glm::vec3(4.065808f, 10.250000f, -20.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.004f * deltaTime * 60);
turbo = glm::max(0.0f, turbo - 0.003f * deltaTime * 60);
if (turbo == 0.0f) {
shiftState = GLFW_RELEASE;
moveSpeed = 0.05f * deltaTime * 60;
setPerticlesParameters(100.f, 0.0001f);
setPerticlesParameters(100.f, 0.000001f);
}
else {
moveSpeed *= 2;
setPerticlesParameters(200.f, 0.00005f);
setPerticlesParameters(200.f, 0.0000005f);
}
}
else {
setPerticlesParameters(100.f, 0.0001f);
setPerticlesParameters(100.f, 0.000001f);
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.04f * glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.0f, 1.0f, 0.0f)));
glm::vec3 perpendicularVector = 0.08f * 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,4 +386,20 @@ 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;
}
};

View File

@ -32,6 +32,8 @@
<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" />

View File

@ -131,6 +131,12 @@
<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">

File diff suppressed because it is too large Load Diff

View File

@ -102,8 +102,17 @@ void main()
vec4 texColor = texture(textureSampler, TexCoords);
vec3 normal = normalize(texture(normalSampler, TexCoords).xyz * TBN);
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(vecNormal);
vec3 viewDir = normalize(cameraPos-worldPos);
vec3 lightDirs[4];

View File

@ -6,11 +6,10 @@
#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>
@ -23,9 +22,13 @@
#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
@ -43,6 +46,7 @@ namespace models {
Core::RenderContext spaceshipContext;
Core::RenderContext sphereContext;
Core::RenderContext cubeContext;
Core::RenderContext asteroid;
}
namespace texture {
GLuint cubemapTexture;
@ -50,6 +54,10 @@ namespace texture {
GLuint spaceshipNormal;
GLuint spriteTexture;
GLuint earthTexture;
GLuint asteroidTexture;
GLuint asteroidNormal;
GLuint heartTexture;
GLuint boosterTexture;
}
struct TextureTuple {
@ -78,6 +86,8 @@ 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;
@ -93,6 +103,17 @@ 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;
@ -137,7 +158,66 @@ 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) {
@ -161,16 +241,47 @@ void renderEnemies() {
}
}
glUseProgram(program);
for (const auto& enemy : enemies) {
if (enemy->isAlive()) {
enemy->attack(spaceship->spaceshipPos, glfwGetTime());
enemy->renderBullets(glfwGetTime(), program, gameEntities);
}
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;
}
}
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];
@ -215,8 +326,13 @@ 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);
@ -258,10 +374,17 @@ 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);
@ -281,6 +404,32 @@ 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];
@ -294,6 +443,7 @@ 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) {
@ -309,18 +459,36 @@ 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));
//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));
//obiekty do ktorych bedzie sprawdzana kolizja dla pociskow enemy
gameEntities.push_back(spaceship);
}
void loadPlanetsAndSunTextures() {
planetTextures.clear();
@ -378,6 +546,7 @@ 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");
@ -395,6 +564,10 @@ 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();

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 941 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
images/asteroidy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

BIN
images/galaktyki.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 KiB

BIN
images/hp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

BIN
images/normal_map.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

BIN
images/sprite.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

BIN
images/sprite_dmg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

BIN
images/strzelanie.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 KiB

BIN
images/turbo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 448 KiB