Compare commits
No commits in common. "f28de5f2bee73db7e1613bc1258d7ae43713ae23" and "630438b1bc1df6768f6c11bb8e36d8bc4ec08b43" have entirely different histories.
f28de5f2be
...
630438b1bc
Binary file not shown.
@ -61,6 +61,7 @@ public:
|
||||
bool checkCollisionWithGameEntities(std::vector<GameEntity*>& gameEntities, glm::mat4 bulletModelMatrix, float attackerDmg) {
|
||||
for (const auto& entity : gameEntities) {
|
||||
glm::mat4 entityModelMatrix = entity->getModelMatrix();
|
||||
|
||||
if (checkAABBCollision(bulletModelMatrix, entityModelMatrix)) {
|
||||
entity->applyDamage(attackerDmg);
|
||||
return true;
|
||||
|
@ -82,9 +82,6 @@ public:
|
||||
this->dmg = this->initDMG;
|
||||
return;
|
||||
}
|
||||
void heal() override {
|
||||
this->currentHP = this->currentHP + 5.0f;
|
||||
}
|
||||
private:
|
||||
void requestShoot(float time) {
|
||||
if (canShoot(time)) {
|
||||
|
@ -10,12 +10,11 @@ public:
|
||||
float initDMG;
|
||||
|
||||
GameEntity(float currentHP, float maxHP, float initialDmg)
|
||||
: currentHP(currentHP), maxHP(maxHP), dmg(initialDmg), initDMG(initialDmg)
|
||||
: currentHP(currentHP), maxHP(maxHP), dmg(initialDmg),initDMG(initialDmg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
virtual void applyDamage(float attackerDmg) {
|
||||
currentHP = currentHP - attackerDmg;
|
||||
};
|
||||
@ -28,6 +27,5 @@ public:
|
||||
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;
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -394,12 +394,4 @@ public:
|
||||
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>
|
||||
|
@ -22,8 +22,6 @@
|
||||
#include "../GameUtils.h"
|
||||
#include "../SpriteRenderer.h"
|
||||
#include "../Enemy.h"
|
||||
#include "../Heart.h"
|
||||
#include "../Nitro.h"
|
||||
|
||||
#include "../ParticleSystem.h"
|
||||
#include "Camera.h"
|
||||
@ -56,8 +54,6 @@ namespace texture {
|
||||
GLuint earthTexture;
|
||||
GLuint asteroidTexture;
|
||||
GLuint asteroidNormal;
|
||||
GLuint heartTexture;
|
||||
GLuint boosterTexture;
|
||||
}
|
||||
|
||||
struct TextureTuple {
|
||||
@ -86,8 +82,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;
|
||||
|
||||
@ -242,46 +236,6 @@ 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() {
|
||||
int textureIndex = rand() % planetTextures.size();
|
||||
TextureTuple selectedTextures = planetTextures[textureIndex];
|
||||
@ -326,13 +280,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);
|
||||
@ -384,7 +333,7 @@ void renderScene(GLFWwindow* window)
|
||||
|
||||
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);
|
||||
|
||||
|
||||
@ -416,7 +365,7 @@ void createAsteroids() {
|
||||
float maxDistanceFromCenter = 26.f;
|
||||
float rotationSpeed = 0.05f;
|
||||
float scale = 0.002f;
|
||||
int numAsteroids = 80;
|
||||
int numAsteroids = 160;
|
||||
float distanceIncrement = 2.f / (minDistanceFromCenter + 1);
|
||||
|
||||
for (int j = -1; j < 2; j++) {
|
||||
@ -464,31 +413,20 @@ 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));
|
||||
|
||||
//obiekty do ktorych bedzie sprawdzana kolizja dla pociskow enemy
|
||||
gameEntities.push_back(spaceship);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void loadPlanetsAndSunTextures() {
|
||||
planetTextures.clear();
|
||||
|
||||
@ -566,8 +504,6 @@ void init(GLFWwindow* window)
|
||||
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.
Before Width: | Height: | Size: 13 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.8 KiB |
Loading…
Reference in New Issue
Block a user