Compare commits
10 Commits
enemies_pl
...
master
Author | SHA1 | Date | |
---|---|---|---|
e3b66ef977 | |||
|
3dc84f2df1 | ||
f28de5f2be | |||
|
abf896ce6d | ||
|
a49a76f8ef | ||
|
1421b90c66 | ||
630438b1bc | |||
de54348411 | |||
|
d949505204 | ||
ebbda6e21e |
BIN
Opis_Projektu.pdf
Normal file
43
README.md
Normal 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
|
||||||
|
|
@ -61,7 +61,6 @@ public:
|
|||||||
bool checkCollisionWithGameEntities(std::vector<GameEntity*>& gameEntities, glm::mat4 bulletModelMatrix, float attackerDmg) {
|
bool checkCollisionWithGameEntities(std::vector<GameEntity*>& gameEntities, glm::mat4 bulletModelMatrix, float attackerDmg) {
|
||||||
for (const auto& entity : gameEntities) {
|
for (const auto& entity : gameEntities) {
|
||||||
glm::mat4 entityModelMatrix = entity->getModelMatrix();
|
glm::mat4 entityModelMatrix = entity->getModelMatrix();
|
||||||
|
|
||||||
if (checkAABBCollision(bulletModelMatrix, entityModelMatrix)) {
|
if (checkAABBCollision(bulletModelMatrix, entityModelMatrix)) {
|
||||||
entity->applyDamage(attackerDmg);
|
entity->applyDamage(attackerDmg);
|
||||||
return true;
|
return true;
|
||||||
|
@ -82,6 +82,9 @@ public:
|
|||||||
this->dmg = this->initDMG;
|
this->dmg = this->initDMG;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
void heal() override {
|
||||||
|
this->currentHP = this->currentHP + 5.0f;
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
void requestShoot(float time) {
|
void requestShoot(float time) {
|
||||||
if (canShoot(time)) {
|
if (canShoot(time)) {
|
||||||
|
@ -15,6 +15,7 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void applyDamage(float attackerDmg) {
|
virtual void applyDamage(float attackerDmg) {
|
||||||
currentHP = currentHP - attackerDmg;
|
currentHP = currentHP - attackerDmg;
|
||||||
};
|
};
|
||||||
@ -27,5 +28,6 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
virtual void respawn() = 0;
|
virtual void respawn() = 0;
|
||||||
|
virtual void heal() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
55
grk/project/Heart.h
Normal 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
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
@ -16,6 +16,8 @@ private:
|
|||||||
glm::mat4 positionMatrix;
|
glm::mat4 positionMatrix;
|
||||||
GLuint textureID;
|
GLuint textureID;
|
||||||
GLuint normalMapID;
|
GLuint normalMapID;
|
||||||
|
float startEulerYRotation = 0.f;
|
||||||
|
float startYMovement = 0.f;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Planet(GameObject* center, float distanceFromCenter, float rotationSpeed, float scale, Core::RenderContext sphereContext, GLuint textureID, GLuint normalMapID) {
|
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);
|
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));
|
glm::mat4 modelMatrix = positionMatrix * glm::scale(glm::vec3(scale));
|
||||||
Core::drawObjectPBRTexture(sphereContext, modelMatrix, textureID, normalMapID, 0.7, 0.0, program);
|
Core::drawObjectPBRTexture(sphereContext, modelMatrix, textureID, normalMapID, 0.7, 0.0, program);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setStarteulerYRotation(float radians) {
|
||||||
|
startEulerYRotation = radians;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setStartYMovement(float value) {
|
||||||
|
startYMovement = value;
|
||||||
|
}
|
||||||
};
|
};
|
@ -229,17 +229,17 @@ public:
|
|||||||
if (turbo == 0.0f) {
|
if (turbo == 0.0f) {
|
||||||
shiftState = GLFW_RELEASE;
|
shiftState = GLFW_RELEASE;
|
||||||
moveSpeed = 0.05f * deltaTime * 60;
|
moveSpeed = 0.05f * deltaTime * 60;
|
||||||
setPerticlesParameters(100.f, 0.0001f);
|
setPerticlesParameters(100.f, 0.000001f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
moveSpeed *= 2;
|
moveSpeed *= 2;
|
||||||
setPerticlesParameters(200.f, 0.00005f);
|
setPerticlesParameters(200.f, 0.0000005f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setPerticlesParameters(100.f, 0.0001f);
|
setPerticlesParameters(100.f, 0.000001f);
|
||||||
turbo = glm::min(turboMAX, turbo + 0.001f * deltaTime * 60);
|
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;
|
cameraPosHUDBar = spaceshipPos - 1.f * spaceshipDir + glm::vec3(0, 1, 0) * 0.2f;
|
||||||
|
|
||||||
cameraDir = spaceshipDir;
|
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) {
|
if (leftParticle != nullptr && rightParticle != nullptr) {
|
||||||
leftParticle->sourcePosition = spaceshipPos + perpendicularVector - (0.25f * spaceshipDir);
|
leftParticle->sourcePosition = spaceshipPos + perpendicularVector - (0.25f * spaceshipDir);
|
||||||
rightParticle->sourcePosition = spaceshipPos - perpendicularVector - (0.25f * spaceshipDir);
|
rightParticle->sourcePosition = spaceshipPos - perpendicularVector - (0.25f * spaceshipDir);
|
||||||
@ -394,4 +394,12 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void heal() override {
|
||||||
|
this->currentHP = this->currentHP + 3.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
void turboBoost() {
|
||||||
|
this->turbo = this->turboMAX;
|
||||||
|
}
|
||||||
};
|
};
|
@ -32,6 +32,8 @@
|
|||||||
<ClInclude Include="GameEntity.h" />
|
<ClInclude Include="GameEntity.h" />
|
||||||
<ClInclude Include="GameObject.h" />
|
<ClInclude Include="GameObject.h" />
|
||||||
<ClInclude Include="GameUtils.h" />
|
<ClInclude Include="GameUtils.h" />
|
||||||
|
<ClInclude Include="Heart.h" />
|
||||||
|
<ClInclude Include="Nitro.h" />
|
||||||
<ClInclude Include="ParticleSystem.h" />
|
<ClInclude Include="ParticleSystem.h" />
|
||||||
<ClInclude Include="Planet.h" />
|
<ClInclude Include="Planet.h" />
|
||||||
<ClInclude Include="Spaceship.h" />
|
<ClInclude Include="Spaceship.h" />
|
||||||
|
@ -131,6 +131,12 @@
|
|||||||
<ClInclude Include="GameEntity.h">
|
<ClInclude Include="GameEntity.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Heart.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Nitro.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="shaders\shader_8_sun.vert">
|
<None Include="shaders\shader_8_sun.vert">
|
||||||
|
1453
grk/project/models/Asteroid.obj
Normal file
@ -6,11 +6,10 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <random>
|
||||||
#include "Shader_Loader.h"
|
#include "Shader_Loader.h"
|
||||||
#include "Render_Utils.h"
|
#include "Render_Utils.h"
|
||||||
#include "texture.h"
|
#include "texture.h"
|
||||||
|
|
||||||
#include "Box.cpp"
|
#include "Box.cpp"
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
@ -23,6 +22,8 @@
|
|||||||
#include "../GameUtils.h"
|
#include "../GameUtils.h"
|
||||||
#include "../SpriteRenderer.h"
|
#include "../SpriteRenderer.h"
|
||||||
#include "../Enemy.h"
|
#include "../Enemy.h"
|
||||||
|
#include "../Heart.h"
|
||||||
|
#include "../Nitro.h"
|
||||||
|
|
||||||
#include "../ParticleSystem.h"
|
#include "../ParticleSystem.h"
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
@ -45,6 +46,7 @@ namespace models {
|
|||||||
Core::RenderContext spaceshipContext;
|
Core::RenderContext spaceshipContext;
|
||||||
Core::RenderContext sphereContext;
|
Core::RenderContext sphereContext;
|
||||||
Core::RenderContext cubeContext;
|
Core::RenderContext cubeContext;
|
||||||
|
Core::RenderContext asteroid;
|
||||||
}
|
}
|
||||||
namespace texture {
|
namespace texture {
|
||||||
GLuint cubemapTexture;
|
GLuint cubemapTexture;
|
||||||
@ -52,6 +54,10 @@ namespace texture {
|
|||||||
GLuint spaceshipNormal;
|
GLuint spaceshipNormal;
|
||||||
GLuint spriteTexture;
|
GLuint spriteTexture;
|
||||||
GLuint earthTexture;
|
GLuint earthTexture;
|
||||||
|
GLuint asteroidTexture;
|
||||||
|
GLuint asteroidNormal;
|
||||||
|
GLuint heartTexture;
|
||||||
|
GLuint boosterTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TextureTuple {
|
struct TextureTuple {
|
||||||
@ -80,6 +86,8 @@ std::list<Planet*> planets;
|
|||||||
Sun* sun;
|
Sun* sun;
|
||||||
GLuint VAO,VBO;
|
GLuint VAO,VBO;
|
||||||
|
|
||||||
|
std::vector<Nitro*> nitros;
|
||||||
|
std::vector<Heart*> hearts;
|
||||||
std::vector<Enemy*> enemies;
|
std::vector<Enemy*> enemies;
|
||||||
std::vector<GameEntity*> gameEntities;
|
std::vector<GameEntity*> gameEntities;
|
||||||
|
|
||||||
@ -234,6 +242,46 @@ 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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() {
|
TextureTuple getRandomPlanetTexture() {
|
||||||
int textureIndex = rand() % planetTextures.size();
|
int textureIndex = rand() % planetTextures.size();
|
||||||
TextureTuple selectedTextures = planetTextures[textureIndex];
|
TextureTuple selectedTextures = planetTextures[textureIndex];
|
||||||
@ -278,8 +326,13 @@ void renderScene(GLFWwindow* window)
|
|||||||
glUseProgram(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
std::vector<GameEntity*> gameEntities(enemies.begin(), enemies.end());
|
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);
|
spaceship->renderBullets(glfwGetTime(), program, gameEntities);
|
||||||
|
|
||||||
|
|
||||||
drawObjectPBR(models::sphereContext,
|
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::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);
|
glm::vec3(0.5, 0.5, 0.5), 0.7, 0.0, program);
|
||||||
@ -331,7 +384,7 @@ void renderScene(GLFWwindow* window)
|
|||||||
|
|
||||||
renderHUD(window);
|
renderHUD(window);
|
||||||
renderEnemies();
|
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);
|
//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);
|
||||||
|
|
||||||
|
|
||||||
@ -351,6 +404,32 @@ void createSuns() {
|
|||||||
createGalaxy(glm::vec3(0.f, 50.f, 200.f));
|
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) {
|
void createGalaxy(glm::vec3 galaxyPosition) {
|
||||||
float planetsSizes[] = { 1.f, 1.5f, 0.8f, 1.2f, 0.2f };
|
float planetsSizes[] = { 1.f, 1.5f, 0.8f, 1.2f, 0.2f };
|
||||||
GLuint sunTexId = sunTexturesIds[0];
|
GLuint sunTexId = sunTexturesIds[0];
|
||||||
@ -364,6 +443,7 @@ void createGalaxy(glm::vec3 galaxyPosition) {
|
|||||||
float planetSizes4[] = { 1.f, 0.5f };
|
float planetSizes4[] = { 1.f, 0.5f };
|
||||||
GLuint sunTexId4 = sunTexturesIds[3];
|
GLuint sunTexId4 = sunTexturesIds[3];
|
||||||
createSolarSystem(galaxyPosition + glm::vec3(100, 20, -50), sunTexId4, 5, planetsSizes3, 2, 25.f, 0.2f);
|
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) {
|
void createSolarSystem(glm::vec3 sunPos, GLuint sunTexId, float sunScale, float* planetSizes, int numberOfPlanets, float planetsDistance, float planetSpeedCoef) {
|
||||||
@ -384,20 +464,31 @@ 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::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,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::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));
|
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) {
|
for (int i = 0; i < ENEMY_COUNT; ++i) {
|
||||||
|
|
||||||
glm::mat4 randomModelMatrix = generateRandomMatrix(glm::mat4(1.0f));
|
glm::mat4 randomModelMatrix = generateRandomMatrix(glm::mat4(1.0f));
|
||||||
enemies.push_back(new Enemy(100.0f, 100.0f, randomModelMatrix, 1.0f, 8.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
|
//obiekty do ktorych bedzie sprawdzana kolizja dla pociskow enemy
|
||||||
gameEntities.push_back(spaceship);
|
gameEntities.push_back(spaceship);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void loadPlanetsAndSunTextures() {
|
void loadPlanetsAndSunTextures() {
|
||||||
planetTextures.clear();
|
planetTextures.clear();
|
||||||
|
|
||||||
@ -455,6 +546,7 @@ void init(GLFWwindow* window)
|
|||||||
loadModelToContext("./models/sphere.obj", models::sphereContext);
|
loadModelToContext("./models/sphere.obj", models::sphereContext);
|
||||||
loadModelToContext("./models/cube.obj", models::cubeContext);
|
loadModelToContext("./models/cube.obj", models::cubeContext);
|
||||||
Core::loadModelToContext("./models/sphere.obj", GameUtils::getInstance()->sphereContext);
|
Core::loadModelToContext("./models/sphere.obj", GameUtils::getInstance()->sphereContext);
|
||||||
|
Core::loadModelToContext("./models/Asteroid.obj", models::asteroid);
|
||||||
|
|
||||||
texture::spriteTexture = Core::LoadTexture("textures/blinky1.png");
|
texture::spriteTexture = Core::LoadTexture("textures/blinky1.png");
|
||||||
|
|
||||||
@ -472,6 +564,10 @@ void init(GLFWwindow* window)
|
|||||||
texture::spaceshipTexture = Core::LoadTexture("./textures/spaceship/Material.001_Base_color.jpg");
|
texture::spaceshipTexture = Core::LoadTexture("./textures/spaceship/Material.001_Base_color.jpg");
|
||||||
texture::spaceshipNormal = Core::LoadTexture("./textures/spaceship/Material.001_Normal_DirectX.jpg");
|
texture::spaceshipNormal = Core::LoadTexture("./textures/spaceship/Material.001_Normal_DirectX.jpg");
|
||||||
texture::earthTexture = Core::LoadTexture("./textures/planets/8k_earth_daymap.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();
|
spaceship->createParticles();
|
||||||
createSuns();
|
createSuns();
|
||||||
|
BIN
grk/project/textures/asteroids/asteroidnn.png
Normal file
After Width: | Height: | Size: 5.8 MiB |
BIN
grk/project/textures/asteroids/asteroidtx.jpg
Normal file
After Width: | Height: | Size: 941 KiB |
BIN
grk/project/textures/boooster.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
grk/project/textures/heart.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
images/asteroidy.png
Normal file
After Width: | Height: | Size: 2.2 MiB |
BIN
images/galaktyki.png
Normal file
After Width: | Height: | Size: 356 KiB |
BIN
images/hp.png
Normal file
After Width: | Height: | Size: 1.6 MiB |
BIN
images/normal_map.png
Normal file
After Width: | Height: | Size: 2.2 MiB |
BIN
images/sprite.png
Normal file
After Width: | Height: | Size: 1.1 MiB |
BIN
images/sprite_dmg.png
Normal file
After Width: | Height: | Size: 58 KiB |
BIN
images/strzelanie.png
Normal file
After Width: | Height: | Size: 283 KiB |
BIN
images/turbo.png
Normal file
After Width: | Height: | Size: 448 KiB |