From 9fa4f2829bdcf04c66ed1079341c52d4ed79d471 Mon Sep 17 00:00:00 2001
From: Frederic Leger <57264593+freeedleger@users.noreply.github.com>
Date: Mon, 30 Oct 2023 14:03:10 -0400
Subject: [PATCH 1/4] add boostinfo
---
SQCSim-common/SQCSim-common.vcxproj | 2 +
SQCSim-common/SQCSim-common.vcxproj.filters | 6 +++
SQCSim-common/boostinfo.cpp | 32 +++++++++++++
SQCSim-common/boostinfo.h | 29 ++++++++++++
SQCSim-common/define.h | 7 +++
SQCSim-common/player.cpp | 51 ++++++++++++++++++++-
SQCSim-common/player.h | 10 +++-
SQCSim2021/define.h | 1 +
SQCSim2021/engine.cpp | 4 ++
9 files changed, 140 insertions(+), 2 deletions(-)
create mode 100644 SQCSim-common/boostinfo.cpp
create mode 100644 SQCSim-common/boostinfo.h
diff --git a/SQCSim-common/SQCSim-common.vcxproj b/SQCSim-common/SQCSim-common.vcxproj
index 991cd1d..5f319ac 100644
--- a/SQCSim-common/SQCSim-common.vcxproj
+++ b/SQCSim-common/SQCSim-common.vcxproj
@@ -131,6 +131,7 @@
+
@@ -144,6 +145,7 @@
+
diff --git a/SQCSim-common/SQCSim-common.vcxproj.filters b/SQCSim-common/SQCSim-common.vcxproj.filters
index 26c6c05..45814cf 100644
--- a/SQCSim-common/SQCSim-common.vcxproj.filters
+++ b/SQCSim-common/SQCSim-common.vcxproj.filters
@@ -54,6 +54,9 @@
Fichiers d%27en-tête
+
+ Fichiers d%27en-tête
+
@@ -80,5 +83,8 @@
Fichiers sources
+
+ Fichiers sources
+
\ No newline at end of file
diff --git a/SQCSim-common/boostinfo.cpp b/SQCSim-common/boostinfo.cpp
new file mode 100644
index 0000000..9b54626
--- /dev/null
+++ b/SQCSim-common/boostinfo.cpp
@@ -0,0 +1,32 @@
+#include "boostinfo.h"
+#include
+
+BoostInfo::BoostInfo(BoostType type, const std::string& name, float u, float v, float s, int dur) : m_type(type), m_name(name), m_u(u), m_v(v), m_s(s), m_durability(dur)
+{
+}
+
+BoostInfo::~BoostInfo()
+{
+}
+
+BoostType BoostInfo::GetType() const
+{
+ return m_type;
+}
+
+void BoostInfo::GetTexture(float& u, float& v, float& s)
+{
+ u = m_u;
+ v = m_v;
+ s = m_s;
+}
+
+void BoostInfo::Show() const
+{
+ std::cout << "Type: " << m_type << std::endl;
+ std::cout << "Nom: " << m_name << std::endl;
+ std::cout << "Durabilite: " << m_durability << std::endl;
+ std::cout << "Coordonnees Texture: " << m_u << ", " << m_v << ", " << m_s << std::endl;
+}
+
+
diff --git a/SQCSim-common/boostinfo.h b/SQCSim-common/boostinfo.h
new file mode 100644
index 0000000..e76d1ed
--- /dev/null
+++ b/SQCSim-common/boostinfo.h
@@ -0,0 +1,29 @@
+#ifndef BOOSTINFO_H__
+#define BOOSTINFO_H__
+
+#include
+#include "define.h"
+
+class BoostInfo
+{
+public:
+ BoostInfo(BoostType type, const std::string& name, float u, float v, float s, int dur);
+ ~BoostInfo();
+
+ BoostType GetType() const;
+
+ void GetTexture(float& u, float& v, float& s);
+
+ void Show() const;
+
+private:
+ BoostType m_type;
+ float m_u;
+ float m_v;
+ float m_s;
+ std::string m_name;
+ int m_durability;
+
+};
+
+#endif // BOOSTINFO_H__
diff --git a/SQCSim-common/define.h b/SQCSim-common/define.h
index f65bc2b..337a9be 100644
--- a/SQCSim-common/define.h
+++ b/SQCSim-common/define.h
@@ -29,8 +29,15 @@
#define TEXTURE_SIZE 512
#define MAX_BULLETS 512
+#define TIME_SPEED_BOOST 10 //secondes
+#define TIME_DAMAGE_BOOST 10 //secondes
+#define TIME_INVINCIBLE_BOOST 4 //secondes
+#define STRENGTH_SPEED_BOOST 10 //Pourcentage
+
typedef uint8_t BlockType;
+typedef uint8_t BoostType;
enum BLOCK_TYPE { BTYPE_AIR, BTYPE_DIRT, BTYPE_GRASS, BTYPE_METAL, BTYPE_ICE, BTYPE_LAST };
+enum BOOST_TYPE { BTYPE_SPEED, BTYPE_HEAL, BTYPE_DAMAGE, BTYPE_INVINCIBLE };
typedef uint64_t Timestamp;
#ifdef _WIN32
diff --git a/SQCSim-common/player.cpp b/SQCSim-common/player.cpp
index 9fe810c..66b6c0a 100644
--- a/SQCSim-common/player.cpp
+++ b/SQCSim-common/player.cpp
@@ -59,6 +59,11 @@ Vector3f Player::GetInput(bool front, bool back, bool left, bool right, bool jum
delta.y += jump? .32f: shoot? .1f : 0.f;
m_airborne = true;
}
+ if (boostspeed)
+ {
+ delta.x += STRENGTH_SPEED_BOOST / 100 * delta.x;
+ delta.z += STRENGTH_SPEED_BOOST / 100 * delta.z;
+ }
if (shoot) // Recoil!
TurnTopBottom(-1);
@@ -180,7 +185,7 @@ Player::Sound Player::ApplyPhysics(Vector3f input, World* world, float elapsedTi
else isStep = false;
m_POV = m_position.y;
m_POV += m_airborne ? 0 : (sin(bobbingtime) - 0.5f) * (abs(m_velocity.x) + abs(m_velocity.z)) * .2f;
-
+ RemoveBooster(elapsedTime);
return snd;
}
@@ -190,6 +195,50 @@ void Player::ApplyTransformation(Transformation& transformation, bool rel) const
if (rel) transformation.ApplyTranslation(-GetPOV());
}
+void Player::GetBooster(Booster boosttype)
+{
+ if (boosttype == SPEED)
+ {
+ boostspeed = true;
+ timeboostspeed = 0;
+ }
+ if (boosttype == HEAL)
+ {
+ m_hp = 100;
+ }
+ if (boosttype == DAMAGE)
+ {
+ boostdamage = true;
+ timeboostdamage = 0;
+ }
+ if (boosttype == INVINCIBLE)
+ {
+ boostinvincible = true;
+ boostinvincible = 0;
+ }
+}
+void Player::RemoveBooster(float elapsedtime)
+{
+ if (boostspeed)
+ {
+ timeboostspeed += elapsedtime;
+ if (timeboostspeed >= TIME_SPEED_BOOST)
+ boostspeed = false;
+ }
+ if (boostdamage)
+ {
+ timeboostdamage += elapsedtime;
+ if (timeboostdamage >= TIME_DAMAGE_BOOST)
+ boostdamage = false;
+ }
+ if (boostinvincible)
+ {
+ timeboostinvincible += elapsedtime;
+ if (timeboostinvincible >= TIME_INVINCIBLE_BOOST)
+ boostinvincible = false;
+ }
+}
+
Vector3f Player::GetPosition() const { return Vector3f(m_position.x + CHUNK_SIZE_X * WORLD_SIZE_X / 2, m_position.y, m_position.z + CHUNK_SIZE_Z * WORLD_SIZE_Y / 2); }
Vector3f Player::GetVelocity() const { return m_velocity; }
diff --git a/SQCSim-common/player.h b/SQCSim-common/player.h
index e439fa2..1a98d6d 100644
--- a/SQCSim-common/player.h
+++ b/SQCSim-common/player.h
@@ -10,6 +10,7 @@ class World;
class Player {
public:
enum Sound { NOSOUND, STEP, FALL };
+ enum Booster { SPEED, HEAL, DAMAGE, INVINCIBLE };
Player(const Vector3f& position, float rotX = 0, float rotY = 0);
void TurnLeftRight(float value);
@@ -17,7 +18,8 @@ public:
Vector3f GetInput(bool front, bool back, bool left, bool right, bool jump, bool dash, float elapsedTime);
Sound ApplyPhysics(Vector3f input, World* world, float elapsedTime);
void ApplyTransformation(Transformation& transformation, bool rel = true) const;
-
+ void GetBooster(Booster boosttype);
+ void RemoveBooster(float elapsedtime);
Vector3f GetPosition() const;
Vector3f GetDirection() const;
Vector3f GetVelocity() const;
@@ -36,10 +38,16 @@ private:
float m_rotX = 0;
float m_rotY = 0;
float m_POV;
+ float timeboostspeed;
+ float timeboostdamage;
+ float timeboostinvincible;
float m_hp;
bool m_airborne;
+ bool boostspeed;
+ bool boostdamage;
+ bool boostinvincible;
};
#endif //_PLAYER_H__
diff --git a/SQCSim2021/define.h b/SQCSim2021/define.h
index 67c49c3..2abfe0c 100644
--- a/SQCSim2021/define.h
+++ b/SQCSim2021/define.h
@@ -35,5 +35,6 @@
#define AUDIO_PATH "./media/audio/"
#define CHUNK_PATH "./media/chunks/"
#define MENU_ITEM_PATH "./media/menu_items/"
+#define BOOSTER_TEXTURE_PATH "./media/textures/Booster"
#endif // DEFINE_H__
diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp
index a5939e6..daa4123 100644
--- a/SQCSim2021/engine.cpp
+++ b/SQCSim2021/engine.cpp
@@ -305,6 +305,10 @@ void Engine::LoadResource() {
TextureAtlas::TextureIndex texIceIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal2.png");
TextureAtlas::TextureIndex texGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "grass.png");
TextureAtlas::TextureIndex texMetalIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "dirt.png");
+ TextureAtlas::TextureIndex texBoostHeal = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterMauve.png");
+ TextureAtlas::TextureIndex texBoostDmg = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterRouge.png");
+ TextureAtlas::TextureIndex texBoostSpd = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterBleu.png");
+ TextureAtlas::TextureIndex texBoostInv = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterJaune.png");
if (!m_textureAtlas.Generate(TEXTURE_SIZE, false)) {
std::cout << " Unable to generate texture atlas ..." << std::endl;
From 5f3b5b3777fd06c80141fae9df8f91199f00abca Mon Sep 17 00:00:00 2001
From: Claudel-D-Roy <112507354+Claudel-D-Roy@users.noreply.github.com>
Date: Mon, 30 Oct 2023 14:19:55 -0400
Subject: [PATCH 2/4] BoosterVert
---
.../media/textures/Booster/BoosterVert.png | Bin 0 -> 10589 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 SQCSim2021/media/textures/Booster/BoosterVert.png
diff --git a/SQCSim2021/media/textures/Booster/BoosterVert.png b/SQCSim2021/media/textures/Booster/BoosterVert.png
new file mode 100644
index 0000000000000000000000000000000000000000..b731b74e4deecf271b112be3309d794f04b40246
GIT binary patch
literal 10589
zcmZX4c|27A_rGd1qr^zQ=KiM(lp+6E~p
zsZD?ECmxlOS|eV4Q0rkz>*xMt_$6~?|EXXpsk5ZjXU&!j2LL9jQyu?9Jr>|Y4LcX)
zE#=^SDL5in>lih}>tcY`@qmC!ubzCnDkY^Q^#>6+9)5qa@66r7%D)`Hy-laKJ@&&-
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
zNS3ADfe}Ujlo?Uh@(j7F@YGWf%i$Ub?5|{S-9w%A+(VIzzh&^d)&oc)Ml6azhkR9p
zKT}a`Btwn|Bl9Q}&HeWL>y~hXu*8K`3Ic1lks+6u40{t@t#ZUwo#||qi0l}Tc-WCycLlD2!~Sb9#ON0el9JkH_ut?{sT(hUulw#{
XsvQ!wa~}+il={QbiCAp^C*!{WQ0#M;
literal 0
HcmV?d00001
From 559a8efc1918989e04396a31ecf0bd465b52072b Mon Sep 17 00:00:00 2001
From: Frederic Leger <57264593+freeedleger@users.noreply.github.com>
Date: Mon, 30 Oct 2023 14:32:20 -0400
Subject: [PATCH 3/4] ajout texture
---
SQCSim-common/define.h | 2 +-
SQCSim2021/engine.cpp | 9 +++++++++
SQCSim2021/engine.h | 2 ++
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/SQCSim-common/define.h b/SQCSim-common/define.h
index 337a9be..5ed4b13 100644
--- a/SQCSim-common/define.h
+++ b/SQCSim-common/define.h
@@ -37,7 +37,7 @@
typedef uint8_t BlockType;
typedef uint8_t BoostType;
enum BLOCK_TYPE { BTYPE_AIR, BTYPE_DIRT, BTYPE_GRASS, BTYPE_METAL, BTYPE_ICE, BTYPE_LAST };
-enum BOOST_TYPE { BTYPE_SPEED, BTYPE_HEAL, BTYPE_DAMAGE, BTYPE_INVINCIBLE };
+enum BOOST_TYPE { BTYPE_SPEED, BTYPE_HEAL, BTYPE_DAMAGE, BTYPE_INVINCIBLE, BTYPE_BOOST_LAST };
typedef uint64_t Timestamp;
#ifdef _WIN32
diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp
index bacea3b..018c5e5 100644
--- a/SQCSim2021/engine.cpp
+++ b/SQCSim2021/engine.cpp
@@ -378,6 +378,15 @@ void Engine::LoadResource() {
m_blockinfo[BTYPE_METAL] = new BlockInfo(BTYPE_METAL, "Metal", u, v, s, 1);
m_textureAtlas.TextureIndexToCoord(texIceIndex, u, v, s, s);
m_blockinfo[BTYPE_ICE] = new BlockInfo(BTYPE_ICE, "Ice", u, v, s, 1);
+ m_textureAtlas.TextureIndexToCoord(texBoostHeal, u, v, s, s);
+ m_boostinfo[BTYPE_HEAL] = new BoostInfo(BTYPE_HEAL, "Heal", u, v, s, 1);
+ m_textureAtlas.TextureIndexToCoord(texBoostDmg, u, v, s, s);
+ m_boostinfo[BTYPE_DAMAGE] = new BoostInfo(BTYPE_DAMAGE, "Dmg", u, v, s, 1);
+ m_textureAtlas.TextureIndexToCoord(texBoostSpd, u, v, s, s);
+ m_boostinfo[BTYPE_SPEED] = new BoostInfo(BTYPE_SPEED, "Spd", u, v, s, 1);
+ m_textureAtlas.TextureIndexToCoord(texIceIndex, u, v, s, s);
+ m_boostinfo[BTYPE_INVINCIBLE] = new BoostInfo(BTYPE_INVINCIBLE, "Inv", u, v, s, 1);
+
std::cout << " Loading and compiling shaders ..." << std::endl;
if (!m_shader01.Load(SHADER_PATH "shader01.vert", SHADER_PATH "shader01.frag", true)) {
diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h
index 0ed8b39..4f4f67f 100644
--- a/SQCSim2021/engine.h
+++ b/SQCSim2021/engine.h
@@ -5,6 +5,7 @@
#include
#include "../SQCSim-common/array2d.h"
#include "../SQCSim-common/blockinfo.h"
+#include "../SQCSim-common/boostinfo.h"
#include "../SQCSim-common/bullet.h"
#include "../SQCSim-common/chunk.h"
#include "../SQCSim-common/world.h"
@@ -61,6 +62,7 @@ private:
Connector m_conn;
Shader m_shader01;
BlockInfo* m_blockinfo[BTYPE_LAST];
+ BoostInfo* m_boostinfo[BTYPE_BOOST_LAST];
TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST);
World m_world = World();
From 8769aa9e38a7e150e10fbd675831a3a7ad00c90e Mon Sep 17 00:00:00 2001
From: Frederic Leger <57264593+freeedleger@users.noreply.github.com>
Date: Mon, 20 Nov 2023 15:40:43 -0500
Subject: [PATCH 4/4] booster affiche
affiche simplement un carre rouge pour l'instant et ne se ramasse pas encore
---
SQCSim2021/SQCSim2021.vcxproj | 2 ++
SQCSim2021/SQCSim2021.vcxproj.filters | 6 ++++
SQCSim2021/booster.cpp | 46 +++++++++++++++++++++++++++
SQCSim2021/booster.h | 14 ++++++++
SQCSim2021/define.h | 2 +-
SQCSim2021/engine.cpp | 3 +-
SQCSim2021/engine.h | 4 +++
SQCSim2021/remoteplayer.h | 1 -
SQCSim2021/renderer.cpp | 32 ++++++++++++++++++-
SQCSim2021/renderer.h | 6 ++++
10 files changed, 112 insertions(+), 4 deletions(-)
create mode 100644 SQCSim2021/booster.cpp
create mode 100644 SQCSim2021/booster.h
diff --git a/SQCSim2021/SQCSim2021.vcxproj b/SQCSim2021/SQCSim2021.vcxproj
index 7f1334e..3aec273 100644
--- a/SQCSim2021/SQCSim2021.vcxproj
+++ b/SQCSim2021/SQCSim2021.vcxproj
@@ -20,6 +20,7 @@
+
@@ -36,6 +37,7 @@
+
diff --git a/SQCSim2021/SQCSim2021.vcxproj.filters b/SQCSim2021/SQCSim2021.vcxproj.filters
index 5c8a864..8246b5c 100644
--- a/SQCSim2021/SQCSim2021.vcxproj.filters
+++ b/SQCSim2021/SQCSim2021.vcxproj.filters
@@ -53,6 +53,9 @@
Fichiers d%27en-tête
+
+ Fichiers d%27en-tête
+
@@ -97,5 +100,8 @@
Fichiers sources
+
+ Fichiers sources
+
\ No newline at end of file
diff --git a/SQCSim2021/booster.cpp b/SQCSim2021/booster.cpp
new file mode 100644
index 0000000..cfef393
--- /dev/null
+++ b/SQCSim2021/booster.cpp
@@ -0,0 +1,46 @@
+#include "booster.h";
+
+void Booster::RenderBillboard(const Vector3f pos, TextureAtlas& textureAtlas, TextureAtlas::TextureIndex idx, Shader& shader, Transformation tran)
+{
+ //
+ //Vector3f playerToQuad = m_player.GetPosition() - m_position;
+ //playerToQuad.Normalize();
+ //Vector3f targetPosition = m_player.GetPosition() + playerToQuad * 10.0f;
+ //Matrix4f rotationMatrix;
+ //rotationMatrix.SetLookAt(m_position, targetPosition, Vector3f(0, 1, 0));
+ //glMultMatrixf(rotationMatrix.GetInternalValues());
+ float x = pos.x;
+ float y = pos.y;
+ float z = pos.z;
+ float width = 1.0f;
+ float height = 1.0f;
+ //Pt override les collisions.. a ce point la je sais pas quoi faire
+
+ //Matrix4 mat4 = tran.GetMatrix();
+ //mat4 VP = pMatrix * vMatrix;
+ //Vector3f CameraRight = Vector3f(mat4.Get11(), mat4.Get21(), mat4.Get31());
+ //Vector3f CameraUp = Vector3f(mat4.Get12(), mat4.Get22(), mat4.Get32());
+
+ //Vector3f v1 = (m_position + CameraRight * 0.5 * width + CameraUp * -0.5 * width);
+ //Vector3f v2 = (m_position + CameraRight * 0.5 * width + CameraUp * 0.5 * width);
+ //Vector3f v4 = (m_position + CameraRight * -0.5 * width + CameraUp * -0.5 * width);
+ //Vector3f v3 = (m_position + CameraRight * -0.5 * width + CameraUp * 0.5 * width);
+
+ //tran.ApplyTranslation(m_position);
+ float u, v, w, h;
+ //glDisable(GL_DEPTH_TEST);
+ shader.Use();
+ textureAtlas.Bind();
+ textureAtlas.TextureIndexToCoord(idx, u, v, w, h);
+ //glLoadIdentity();
+ glLoadMatrixf(tran.GetMatrix().GetInternalValues());
+ glBegin(GL_QUADS);
+ glTexCoord2f(u, v); glVertex3f(x - width / 2., y - height, z); //glVertex3f(v4.x, v4.y, v4.z);//glVertex3f(0, 50, 0);
+ glTexCoord2f(u + w, v); glVertex3f(x + width / 2., y - height, z); //glVertex3f(v3.x, v3.y, v3.z); //glVertex3f(50,50, 0);
+ glTexCoord2f(u + w, v + h); glVertex3f(x + width / 2., y, z); //glVertex3f(v2.x, v2.y, v2.z); //glVertex3f(50, 0, 0);
+ glTexCoord2f(u, v + h); glVertex3f(x - width / 2., y, z); //glVertex3f(v1.x, v1.y, v1.z);// glVertex3f(0, 0, 0);
+ glEnd();
+ shader.Disable();
+ //tran.ApplyTranslation(-m_position);
+ //glEnable(GL_DEPTH_TEST);
+}
\ No newline at end of file
diff --git a/SQCSim2021/booster.h b/SQCSim2021/booster.h
new file mode 100644
index 0000000..b9ff3b6
--- /dev/null
+++ b/SQCSim2021/booster.h
@@ -0,0 +1,14 @@
+#ifndef BOOSTER_H__
+#define BOOSTER_H__
+#include "define.h"
+#include "textureatlas.h"
+#include "shader.h"
+#include "../SQCSim-common/vector3.h"
+#include "../SQCSim-common/transformation.h"
+
+
+class Booster {
+public:
+ void RenderBillboard(const Vector3f pos, TextureAtlas& textureAtlas, TextureAtlas::TextureIndex idx, Shader& shader, Transformation tran);
+};
+#endif
diff --git a/SQCSim2021/define.h b/SQCSim2021/define.h
index 9ce9bd2..4d67655 100644
--- a/SQCSim2021/define.h
+++ b/SQCSim2021/define.h
@@ -34,6 +34,6 @@
#define AUDIO_PATH "./media/audio/"
#define CHUNK_PATH "./media/chunks/"
#define MENU_ITEM_PATH "./media/menu_items/"
-#define BOOSTER_TEXTURE_PATH "./media/textures/Booster"
+#define BOOSTER_TEXTURE_PATH "./media/textures/Booster/"
#endif // DEFINE_H__
diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp
index 6d3cc95..9c8b201 100644
--- a/SQCSim2021/engine.cpp
+++ b/SQCSim2021/engine.cpp
@@ -448,7 +448,7 @@ void Engine::LoadResource() {
TextureAtlas::TextureIndex texIceIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal2.png");
TextureAtlas::TextureIndex texGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "grass.png");
TextureAtlas::TextureIndex texMetalIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "dirt.png");
- TextureAtlas::TextureIndex texBoostHeal = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterMauve.png");
+ TextureAtlas::TextureIndex texBoostHeal = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterVert.png");
TextureAtlas::TextureIndex texBoostDmg = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterRouge.png");
TextureAtlas::TextureIndex texBoostSpd = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterBleu.png");
TextureAtlas::TextureIndex texBoostInv = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterJaune.png");
@@ -1160,6 +1160,7 @@ void Engine::Render(float elapsedTime) {
m_renderer.UpdateMesh(&m_world, m_player.GetPosition(), m_blockinfo);
glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
m_remotePlayer.Render(m_textureAtlas, m_shader01, all, elapsedTime);
+ m_booster.RenderBillboard({ 120,20,120 }, m_textureAtlas, texBoostHeal, m_shader01, all);
if (m_isSkybox) m_renderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas);
diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h
index 23b62da..f5754aa 100644
--- a/SQCSim2021/engine.h
+++ b/SQCSim2021/engine.h
@@ -23,6 +23,7 @@
#include "connector.h"
#include "renderer.h"
#include "remoteplayer.h"
+#include "booster.h"
class Engine : public OpenglContext {
@@ -74,6 +75,7 @@ private:
World m_world = World();
Renderer m_renderer = Renderer();
+ Booster m_booster = Booster();
Texture m_textureCrosshair;
Texture m_textureFont;
@@ -85,6 +87,8 @@ private:
Texture m_textureMultiText;
Texture m_textureTitle;
+ TextureAtlas::TextureIndex texBoostHeal;
+
Skybox m_skybox;
Audio m_audio = Audio(AUDIO_PATH "start.wav");
diff --git a/SQCSim2021/remoteplayer.h b/SQCSim2021/remoteplayer.h
index 6050356..36eb275 100644
--- a/SQCSim2021/remoteplayer.h
+++ b/SQCSim2021/remoteplayer.h
@@ -8,7 +8,6 @@
#include "texture.h"
#include "openglcontext.h"
#include "vertexbuffer.h"
-#include "texture.h"
#include "../SQCSim-common/matrix4.h"
class RemotePlayer : public Player {
diff --git a/SQCSim2021/renderer.cpp b/SQCSim2021/renderer.cpp
index d2b9b30..3e5fc97 100644
--- a/SQCSim2021/renderer.cpp
+++ b/SQCSim2021/renderer.cpp
@@ -1,4 +1,9 @@
#include "renderer.h"
+#include
+#include
+
+#include
+#include
Renderer::Renderer() {
m_meshes.Reset(nullptr);
@@ -131,7 +136,8 @@ void Renderer::RenderWorld(World* origin, int& rendercount, const Vector3f& play
}
shader.Disable();
glStencilFunc(GL_GREATER, 1, 0xFF);
-};
+}
+
void Renderer::UpdateMesh(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]) {
int cx = player.x;
@@ -238,6 +244,30 @@ void Renderer::UpdateMesh(World* origin, const Vector3f& player, BlockInfo* bloc
}
}
+void Renderer::RenderBillboard(const Vector3f pos, TextureAtlas textureAtlas, TextureAtlas::TextureIndex idx, Shader& shader, Transformation tran)
+{
+ //float x = pos.x;
+ //float y = pos.y;
+ //float z = pos.z;
+ //float width = 1.0f;
+ //float height = 1.0f;
+
+ //float u, v, w, h;
+ //shader.Use();
+ //textureAtlas.Bind();
+ //textureAtlas.TextureIndexToCoord(idx, u, v, w, h);
+
+ //glLoadMatrixf(tran.GetMatrix().GetInternalValues());
+ //glBegin(GL_QUADS);
+ //glTexCoord2f(u, v); glVertex3f(x - width / 2., y - height, z); //glVertex3f(v4.x, v4.y, v4.z);//glVertex3f(0, 50, 0);
+ //glTexCoord2f(u + w, v); glVertex3f(x + width / 2., y - height, z); //glVertex3f(v3.x, v3.y, v3.z); //glVertex3f(50,50, 0);
+ //glTexCoord2f(u + w, v + h); glVertex3f(x + width / 2., y, z); //glVertex3f(v2.x, v2.y, v2.z); //glVertex3f(50, 0, 0);
+ //glTexCoord2f(u, v + h); glVertex3f(x - width / 2., y, z); //glVertex3f(v1.x, v1.y, v1.z);// glVertex3f(0, 0, 0);
+ //glEnd();
+ //shader.Disable();
+}
+
+
void Renderer::RenderPlayer(Player* player, Transformation tran) const {
}
diff --git a/SQCSim2021/renderer.h b/SQCSim2021/renderer.h
index 0289baf..5a13709 100644
--- a/SQCSim2021/renderer.h
+++ b/SQCSim2021/renderer.h
@@ -9,6 +9,9 @@
#include "textureatlas.h"
#include "shader.h"
#include "remoteplayer.h"
+#include "openglcontext.h"
+#include "vertexbuffer.h"
+#include "../SQCSim-common/matrix4.h"
class Renderer {
private:
@@ -16,6 +19,7 @@ private:
TextureAtlas* m_playertext = nullptr;
Shader* m_playershader = nullptr;
+ bool test = true;
public:
Renderer();
@@ -25,6 +29,8 @@ public:
void UpdateMesh(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]);
+ void RenderBillboard(const Vector3f pos, TextureAtlas textureAtlas, TextureAtlas::TextureIndex idx, Shader& shader, Transformation tran);
+
void RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation world, Shader& shader, TextureAtlas& atlas) const;
void RenderPlayer(Player* player, Transformation tran) const;
void RenderPlayer(RemotePlayer* rplayer, const Vector3f& player_pos, const Vector3f& player_dir) const;