Merge branch 'SQC19_Booster' into online_boosts
This commit is contained in:
commit
68d03c1eac
@ -131,6 +131,7 @@
|
|||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="booster.h" />
|
||||||
<ClInclude Include="array2d.h" />
|
<ClInclude Include="array2d.h" />
|
||||||
<ClInclude Include="array3d.h" />
|
<ClInclude Include="array3d.h" />
|
||||||
<ClInclude Include="blockinfo.h" />
|
<ClInclude Include="blockinfo.h" />
|
||||||
@ -147,6 +148,7 @@
|
|||||||
<ClInclude Include="world.h" />
|
<ClInclude Include="world.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="booster.cpp" />
|
||||||
<ClCompile Include="blockinfo.cpp" />
|
<ClCompile Include="blockinfo.cpp" />
|
||||||
<ClCompile Include="boostinfo.cpp" />
|
<ClCompile Include="boostinfo.cpp" />
|
||||||
<ClCompile Include="bullet.cpp" />
|
<ClCompile Include="bullet.cpp" />
|
||||||
|
@ -54,6 +54,9 @@
|
|||||||
<ClInclude Include="transformation.h">
|
<ClInclude Include="transformation.h">
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="booster.h">
|
||||||
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="boostinfo.h">
|
<ClInclude Include="boostinfo.h">
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@ -83,6 +86,9 @@
|
|||||||
<ClCompile Include="transformation.cpp">
|
<ClCompile Include="transformation.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="booster.cpp">
|
||||||
|
<Filter>Fichiers sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="boostinfo.cpp">
|
<ClCompile Include="boostinfo.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
38
SQCSim-common/booster.cpp
Normal file
38
SQCSim-common/booster.cpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#include "booster.h"
|
||||||
|
|
||||||
|
Booster::Booster()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Booster::Booster(Vector3f tpos, BOOST_TYPE ttype)
|
||||||
|
{
|
||||||
|
pos = tpos;
|
||||||
|
type = ttype;
|
||||||
|
available = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Booster::~Booster()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3f Booster::GetPosition()
|
||||||
|
{
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_TYPE Booster::GetType()
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Booster::GetAvailability()
|
||||||
|
{
|
||||||
|
return available;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Booster::SetAvailability(bool value)
|
||||||
|
{
|
||||||
|
available = value;
|
||||||
|
}
|
||||||
|
|
20
SQCSim-common/booster.h
Normal file
20
SQCSim-common/booster.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#ifndef BOOSTER_H__
|
||||||
|
#define BOOSTER_H__
|
||||||
|
#include "define.h"
|
||||||
|
#include "vector3.h"
|
||||||
|
|
||||||
|
class Booster {
|
||||||
|
public:
|
||||||
|
Booster();
|
||||||
|
Booster(Vector3f tpos, BOOST_TYPE ttype);
|
||||||
|
~Booster();
|
||||||
|
Vector3f GetPosition();
|
||||||
|
BOOST_TYPE GetType();
|
||||||
|
bool GetAvailability();
|
||||||
|
void SetAvailability(bool value);
|
||||||
|
private:
|
||||||
|
Vector3f pos;
|
||||||
|
BOOST_TYPE type;
|
||||||
|
bool available;
|
||||||
|
};
|
||||||
|
#endif
|
@ -31,10 +31,11 @@
|
|||||||
#define TEXTURE_SIZE 512
|
#define TEXTURE_SIZE 512
|
||||||
#define MAX_BULLETS 512
|
#define MAX_BULLETS 512
|
||||||
|
|
||||||
|
#define NB_BOOST 2
|
||||||
#define TIME_SPEED_BOOST 10 //secondes
|
#define TIME_SPEED_BOOST 10 //secondes
|
||||||
#define TIME_DAMAGE_BOOST 10 //secondes
|
#define TIME_DAMAGE_BOOST 10 //secondes
|
||||||
#define TIME_INVINCIBLE_BOOST 4 //secondes
|
#define TIME_INVINCIBLE_BOOST 4 //secondes
|
||||||
#define STRENGTH_SPEED_BOOST 10 //Pourcentage
|
#define STRENGTH_SPEED_BOOST 1000 //Pourcentage
|
||||||
#define BULLET_TIME .2 //secondes
|
#define BULLET_TIME .2 //secondes
|
||||||
|
|
||||||
#define SYNC_ACC 600 // ms
|
#define SYNC_ACC 600 // ms
|
||||||
|
@ -68,8 +68,8 @@ Vector3f Player::GetInput(bool front, bool back, bool left, bool right, bool jum
|
|||||||
delta.x *= .6f;
|
delta.x *= .6f;
|
||||||
delta.z *= .6f;
|
delta.z *= .6f;
|
||||||
|
|
||||||
if ((jump || shoot ) && !m_airborne) {
|
if ((jump || shoot) && !m_airborne) {
|
||||||
delta.y += jump? .32f: shoot? .1f : 0.f;
|
delta.y += jump ? .32f : shoot ? .1f : 0.f;
|
||||||
m_airborne = true;
|
m_airborne = true;
|
||||||
}
|
}
|
||||||
if (boostspeed)
|
if (boostspeed)
|
||||||
@ -84,7 +84,7 @@ Vector3f Player::GetInput(bool front, bool back, bool left, bool right, bool jum
|
|||||||
return delta;
|
return delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::Sound Player::ApplyPhysics(Vector3f input, World* world, float elapsedTime) {
|
Player::Sound Player::ApplyPhysics(Vector3f input, World* world, float elapsedTime, Booster booster_table[]) {
|
||||||
Player::Sound snd = Player::Sound::NOSOUND;
|
Player::Sound snd = Player::Sound::NOSOUND;
|
||||||
static float timing = 0.f;
|
static float timing = 0.f;
|
||||||
/* Gestion de collisions */
|
/* Gestion de collisions */
|
||||||
@ -184,33 +184,50 @@ Player::Sound Player::ApplyPhysics(Vector3f input, World* world, float elapsedTi
|
|||||||
else isStep = false;
|
else isStep = false;
|
||||||
m_POV = m_position.y;
|
m_POV = m_position.y;
|
||||||
m_POV += m_airborne ? 0 : (sin(bobbingtime) - 0.5f) * (abs(m_velocity.x) + abs(m_velocity.z)) * .2f;
|
m_POV += m_airborne ? 0 : (sin(bobbingtime) - 0.5f) * (abs(m_velocity.x) + abs(m_velocity.z)) * .2f;
|
||||||
|
TakeBooster(booster_table, elapsedTime);
|
||||||
RemoveBooster(elapsedTime);
|
RemoveBooster(elapsedTime);
|
||||||
return snd;
|
return snd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::ApplyTransformation(Transformation& transformation, bool rel, bool rot) const {
|
void Player::ApplyTransformation(Transformation& transformation, bool rel, bool rot) const {
|
||||||
|
|
||||||
transformation.ApplyRotation(-m_rotX, 1, 0, 0);
|
transformation.ApplyRotation(-m_rotX, 1, 0, 0);
|
||||||
transformation.ApplyRotation(-m_rotY, 0, 1, 0);
|
transformation.ApplyRotation(-m_rotY, 0, 1, 0);
|
||||||
if (rel) transformation.ApplyTranslation(-GetPOV());
|
if (rel) transformation.ApplyTranslation(-GetPOV());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::GetBooster(Booster boosttype)
|
void Player::TakeBooster(Booster booster_table[], float elapsedtime)
|
||||||
{
|
{
|
||||||
if (boosttype == SPEED)
|
Vector3f playerpos = GetPosition();
|
||||||
|
for (int i = 0; i < sizeof(booster_table); i++)
|
||||||
|
{
|
||||||
|
Vector3f pos = booster_table[i].GetPosition();
|
||||||
|
if (abs(playerpos.x - pos.x) <= 0.5f && abs(playerpos.y - pos.y) <= 1.0f && abs(playerpos.z - pos.z) <= 0.5f && booster_table[i].GetAvailability() == true)
|
||||||
|
{
|
||||||
|
GetBooster(booster_table[i].GetType(), elapsedtime);
|
||||||
|
booster_table[i].SetAvailability(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::GetBooster(BOOST_TYPE boosttype, float elapsedtime)
|
||||||
|
{
|
||||||
|
if (boosttype == BTYPE_SPEED)
|
||||||
{
|
{
|
||||||
boostspeed = true;
|
boostspeed = true;
|
||||||
timeboostspeed = 0;
|
timeboostspeed = 0;
|
||||||
}
|
}
|
||||||
if (boosttype == HEAL)
|
if (boosttype == BTYPE_HEAL)
|
||||||
{
|
{
|
||||||
m_hp = 100;
|
m_hp = 1.0f;
|
||||||
}
|
}
|
||||||
if (boosttype == DAMAGE)
|
if (boosttype == BTYPE_DAMAGE)
|
||||||
{
|
{
|
||||||
boostdamage = true;
|
boostdamage = true;
|
||||||
timeboostdamage = 0;
|
timeboostdamage = 0;
|
||||||
}
|
}
|
||||||
if (boosttype == INVINCIBLE)
|
if (boosttype == BTYPE_INVINCIBLE)
|
||||||
{
|
{
|
||||||
boostinvincible = true;
|
boostinvincible = true;
|
||||||
boostinvincible = 0;
|
boostinvincible = 0;
|
||||||
@ -221,19 +238,17 @@ void Player::RemoveBooster(float elapsedtime)
|
|||||||
if (boostspeed)
|
if (boostspeed)
|
||||||
{
|
{
|
||||||
timeboostspeed += elapsedtime;
|
timeboostspeed += elapsedtime;
|
||||||
if (timeboostspeed >= TIME_SPEED_BOOST)
|
if (timeboostspeed >= TIME_SPEED_BOOST && boostspeed == true)
|
||||||
boostspeed = false;
|
boostspeed = false;
|
||||||
}
|
}
|
||||||
if (boostdamage)
|
if (boostdamage)
|
||||||
{
|
{
|
||||||
timeboostdamage += elapsedtime;
|
if (timeboostdamage >= TIME_DAMAGE_BOOST && boostdamage == true)
|
||||||
if (timeboostdamage >= TIME_DAMAGE_BOOST)
|
|
||||||
boostdamage = false;
|
boostdamage = false;
|
||||||
}
|
}
|
||||||
if (boostinvincible)
|
if (boostinvincible)
|
||||||
{
|
{
|
||||||
timeboostinvincible += elapsedtime;
|
if (timeboostinvincible >= TIME_INVINCIBLE_BOOST && boostinvincible == true)
|
||||||
if (timeboostinvincible >= TIME_INVINCIBLE_BOOST)
|
|
||||||
boostinvincible = false;
|
boostinvincible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "transformation.h"
|
#include "transformation.h"
|
||||||
#include "vector3.h"
|
#include "vector3.h"
|
||||||
|
#include "booster.h"
|
||||||
|
#include "define.h"
|
||||||
|
|
||||||
|
|
||||||
class World;
|
class World;
|
||||||
@ -11,7 +13,7 @@ class World;
|
|||||||
class Player {
|
class Player {
|
||||||
public:
|
public:
|
||||||
enum Sound { NOSOUND, STEP, FALL };
|
enum Sound { NOSOUND, STEP, FALL };
|
||||||
enum Booster { SPEED, HEAL, DAMAGE, INVINCIBLE };
|
//enum BoosterType { SPEED, HEAL, DAMAGE, INVINCIBLE };
|
||||||
|
|
||||||
Player(const Vector3f& position, float rotX = 0, float rotY = 0);
|
Player(const Vector3f& position, float rotX = 0, float rotY = 0);
|
||||||
~Player();
|
~Player();
|
||||||
@ -19,8 +21,9 @@ public:
|
|||||||
void TurnLeftRight(float value, float sensitivity);
|
void TurnLeftRight(float value, float sensitivity);
|
||||||
void TurnTopBottom(float value, float sensitivity);
|
void TurnTopBottom(float value, float sensitivity);
|
||||||
Vector3f GetInput(bool front, bool back, bool left, bool right, bool jump, bool dash, float elapsedTime);
|
Vector3f GetInput(bool front, bool back, bool left, bool right, bool jump, bool dash, float elapsedTime);
|
||||||
Sound ApplyPhysics(Vector3f input, World* world, float elapsedTime);
|
Sound ApplyPhysics(Vector3f input, World* world, float elapsedTime, Booster booster_table[]);
|
||||||
void GetBooster(Booster boosttype);
|
void TakeBooster(Booster booster_table[], float elapsedTime);
|
||||||
|
void GetBooster(BOOST_TYPE boosttype, float elapsedTime);
|
||||||
void RemoveBooster(float elapsedtime);
|
void RemoveBooster(float elapsedtime);
|
||||||
void ApplyTransformation(Transformation& transformation, bool rel = true, bool rot = true) const;
|
void ApplyTransformation(Transformation& transformation, bool rel = true, bool rot = true) const;
|
||||||
|
|
||||||
@ -50,9 +53,9 @@ public:
|
|||||||
|
|
||||||
bool Eulogy = false;
|
bool Eulogy = false;
|
||||||
|
|
||||||
bool boostspeed;
|
bool boostspeed = false;
|
||||||
bool boostdamage;
|
bool boostdamage = false;
|
||||||
bool boostinvincible;
|
bool boostinvincible = false;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64_t getId() const;
|
uint64_t getId() const;
|
||||||
@ -77,7 +80,6 @@ protected:
|
|||||||
|
|
||||||
bool m_airborne;
|
bool m_airborne;
|
||||||
|
|
||||||
|
|
||||||
Vector3f InterpolatePosition(const Vector3f& vec1, const Vector3f& vec2, const Timestamp& tim1, const Timestamp& tim2, const Timestamp& now);
|
Vector3f InterpolatePosition(const Vector3f& vec1, const Vector3f& vec2, const Timestamp& tim1, const Timestamp& tim2, const Timestamp& now);
|
||||||
};
|
};
|
||||||
#endif //_PLAYER_H__
|
#endif //_PLAYER_H__
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="audio.h" />
|
<ClInclude Include="audio.h" />
|
||||||
<ClInclude Include="booster.h" />
|
|
||||||
<ClInclude Include="connector.h" />
|
<ClInclude Include="connector.h" />
|
||||||
<ClInclude Include="define.h" />
|
<ClInclude Include="define.h" />
|
||||||
<ClInclude Include="engine.h" />
|
<ClInclude Include="engine.h" />
|
||||||
@ -38,7 +37,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="audio.cpp" />
|
<ClCompile Include="audio.cpp" />
|
||||||
<ClCompile Include="booster.cpp" />
|
|
||||||
<ClCompile Include="connector.cpp" />
|
<ClCompile Include="connector.cpp" />
|
||||||
<ClCompile Include="engine.cpp" />
|
<ClCompile Include="engine.cpp" />
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
|
@ -53,9 +53,6 @@
|
|||||||
<ClInclude Include="remoteplayer.h">
|
<ClInclude Include="remoteplayer.h">
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="booster.h">
|
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="settings.h">
|
<ClInclude Include="settings.h">
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@ -103,9 +100,6 @@
|
|||||||
<ClCompile Include="remoteplayer.cpp">
|
<ClCompile Include="remoteplayer.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="booster.cpp">
|
|
||||||
<Filter>Fichiers sources</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="settings.cpp">
|
<ClCompile Include="settings.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
#include "booster.h"
|
|
||||||
|
|
||||||
void Booster::RenderBillboard(const Vector3f pos, TextureAtlas& textureAtlas, 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(8, 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);
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
#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, Shader& shader, Transformation tran);
|
|
||||||
};
|
|
||||||
#endif
|
|
@ -78,7 +78,6 @@ void Engine::LoadResource() {
|
|||||||
std::cerr << " ERREUR GLEW : " << glewGetErrorString(glewErr) << std::endl;
|
std::cerr << " ERREUR GLEW : " << glewGetErrorString(glewErr) << std::endl;
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadTexture(m_skybox.GetTexture(), TEXTURE_PATH "skybox.png", true);
|
LoadTexture(m_skybox.GetTexture(), TEXTURE_PATH "skybox.png", true);
|
||||||
LoadTexture(m_textureCrosshair, TEXTURE_PATH "cross.bmp", true);
|
LoadTexture(m_textureCrosshair, TEXTURE_PATH "cross.bmp", true);
|
||||||
LoadTexture(m_textureFont, TEXTURE_PATH "font.bmp", true);
|
LoadTexture(m_textureFont, TEXTURE_PATH "font.bmp", true);
|
||||||
@ -124,15 +123,15 @@ void Engine::LoadResource() {
|
|||||||
LoadTexture(m_textureMenuQuit, TEXTURE_PATH "menus/buttons/main/mainQuit.png", false);
|
LoadTexture(m_textureMenuQuit, TEXTURE_PATH "menus/buttons/main/mainQuit.png", false);
|
||||||
LoadTexture(m_textureMenuSingle, TEXTURE_PATH "menus/buttons/main/mainSingle.png", false);
|
LoadTexture(m_textureMenuSingle, TEXTURE_PATH "menus/buttons/main/mainSingle.png", false);
|
||||||
|
|
||||||
TextureAtlas::TextureIndex texDirtIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal2.png");
|
TextureAtlas::TextureIndex texDirtIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal2.png"); //0
|
||||||
TextureAtlas::TextureIndex texIceIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal3.png");
|
TextureAtlas::TextureIndex texIceIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal3.png"); //1
|
||||||
TextureAtlas::TextureIndex texGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "grass.png");
|
TextureAtlas::TextureIndex texGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "grass.png"); //2
|
||||||
TextureAtlas::TextureIndex texMetalIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "dirt.png");
|
TextureAtlas::TextureIndex texMetalIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "dirt.png"); //3
|
||||||
TextureAtlas::TextureIndex texGreenGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "greengrass.png");
|
TextureAtlas::TextureIndex texGreenGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "greengrass.png"); //4
|
||||||
TextureAtlas::TextureIndex texBoostHeal = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterVert.png");
|
TextureAtlas::TextureIndex texBoostHeal = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterVert.png"); //5
|
||||||
TextureAtlas::TextureIndex texBoostDmg = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterRouge.png");
|
TextureAtlas::TextureIndex texBoostDmg = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterRouge.png"); //6
|
||||||
TextureAtlas::TextureIndex texBoostSpd = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterBleu.png");
|
TextureAtlas::TextureIndex texBoostSpd = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterBleu.png"); //7
|
||||||
TextureAtlas::TextureIndex texBoostInv = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterJaune.png");
|
TextureAtlas::TextureIndex texBoostInv = m_textureAtlas.AddTexture(BOOSTER_TEXTURE_PATH "BoosterJaune.png"); //8
|
||||||
|
|
||||||
//AJOUTER LES TEXTURES DANS L'ORDRE DE L'ÉNUM
|
//AJOUTER LES TEXTURES DANS L'ORDRE DE L'ÉNUM
|
||||||
|
|
||||||
@ -1308,6 +1307,8 @@ void Engine::Render(float elapsedTime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_gamestate == GameState::PAUSE) {
|
if (m_gamestate == GameState::PAUSE) {
|
||||||
|
booster_table[0] = Booster({ 215, 15, 195 }, BTYPE_SPEED);
|
||||||
|
booster_table[1] = Booster({ 213, 15, 195 }, BTYPE_HEAL);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
@ -1349,7 +1350,7 @@ void Engine::Render(float elapsedTime) {
|
|||||||
|
|
||||||
static bool leftright = false;
|
static bool leftright = false;
|
||||||
if (pollTime >= .005f) {
|
if (pollTime >= .005f) {
|
||||||
Player::Sound snd = m_player.ApplyPhysics(m_player.GetInput(m_keyW, m_keyS, m_keyA, m_keyD, m_keySpace, (bloc == BTYPE_LAST && bulletTime <= 0.f && m_mouseL), elapsedTime), &m_world, elapsedTime);
|
Player::Sound snd = m_player.ApplyPhysics(m_player.GetInput(m_keyW, m_keyS, m_keyA, m_keyD, m_keySpace, (bloc == BTYPE_LAST && bulletTime <= 0.f && m_mouseL), elapsedTime), &m_world, elapsedTime, booster_table);
|
||||||
switch (snd) {
|
switch (snd) {
|
||||||
case Player::Sound::STEP:
|
case Player::Sound::STEP:
|
||||||
if (leftright)
|
if (leftright)
|
||||||
@ -1428,10 +1429,19 @@ void Engine::Render(float elapsedTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_world.Update(m_bullets, m_player.GetPosition(), m_blockinfo);
|
m_world.Update(m_bullets, m_player.GetPosition(), m_blockinfo);
|
||||||
m_renderer.UpdateMesh(&m_world, m_player.GetPosition(), m_blockinfo);
|
m_renderer.UpdateMesh(&m_world, m_player.GetPosition(), m_blockinfo);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_CULL_FACE);
|
||||||
|
for (Booster booster : booster_table) {
|
||||||
|
m_renderer.RenderBooster(m_textureAtlas, m_shader01, all, m_player, booster);
|
||||||
|
}
|
||||||
|
glEnable(GL_CULL_FACE);
|
||||||
|
|
||||||
|
if (m_isSkybox) m_renderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas);
|
||||||
|
|
||||||
|
//glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||||
|
//m_remotePlayer.Render(m_textureAtlas, m_shader01, all, elapsedTime);
|
||||||
|
|
||||||
m_renderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas);
|
m_renderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "../SQCSim-common/world.h"
|
#include "../SQCSim-common/world.h"
|
||||||
#include "../SQCSim-common/transformation.h"
|
#include "../SQCSim-common/transformation.h"
|
||||||
#include "../SQCSim-common/player.h"
|
#include "../SQCSim-common/player.h"
|
||||||
|
#include "../SQCSim-common/booster.h"
|
||||||
#include "define.h"
|
#include "define.h"
|
||||||
#include "openglcontext.h"
|
#include "openglcontext.h"
|
||||||
#include "texture.h"
|
#include "texture.h"
|
||||||
@ -24,13 +25,15 @@
|
|||||||
#include "connector.h"
|
#include "connector.h"
|
||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
#include "remoteplayer.h"
|
#include "remoteplayer.h"
|
||||||
#include "booster.h"
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
class Engine : public OpenglContext {
|
class Engine : public OpenglContext {
|
||||||
public:
|
public:
|
||||||
Engine();
|
Engine();
|
||||||
virtual ~Engine();
|
virtual ~Engine();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
virtual void DeInit();
|
virtual void DeInit();
|
||||||
virtual void LoadResource();
|
virtual void LoadResource();
|
||||||
@ -39,8 +42,8 @@ public:
|
|||||||
virtual void KeyPressEvent(unsigned char key);
|
virtual void KeyPressEvent(unsigned char key);
|
||||||
virtual void KeyReleaseEvent(unsigned char key);
|
virtual void KeyReleaseEvent(unsigned char key);
|
||||||
virtual void MouseMoveEvent(int x, int y);
|
virtual void MouseMoveEvent(int x, int y);
|
||||||
virtual void MousePressEvent(const MOUSE_BUTTON &button, int x, int y);
|
virtual void MousePressEvent(const MOUSE_BUTTON& button, int x, int y);
|
||||||
virtual void MouseReleaseEvent(const MOUSE_BUTTON &button, int x, int y);
|
virtual void MouseReleaseEvent(const MOUSE_BUTTON& button, int x, int y);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int GetFps(float elapsedTime) const;
|
int GetFps(float elapsedTime) const;
|
||||||
@ -56,6 +59,7 @@ private:
|
|||||||
void KillNotification(Player killer, Player killed);
|
void KillNotification(Player killer, Player killed);
|
||||||
|
|
||||||
void DisplayNotification(std::string message);
|
void DisplayNotification(std::string message);
|
||||||
|
|
||||||
void DisplayCrosshair();
|
void DisplayCrosshair();
|
||||||
void DisplayPovGun();
|
void DisplayPovGun();
|
||||||
void DisplayCurrentItem();
|
void DisplayCurrentItem();
|
||||||
@ -103,10 +107,9 @@ private:
|
|||||||
|
|
||||||
Renderer m_renderer = Renderer();
|
Renderer m_renderer = Renderer();
|
||||||
|
|
||||||
Booster m_booster = Booster();
|
Booster booster_table[NB_BOOST];
|
||||||
BlockInfo* m_blockinfo[BTYPE_LAST];
|
BlockInfo* m_blockinfo[BTYPE_LAST];
|
||||||
BoostInfo* m_boostinfo[BTYPE_BOOST_LAST];
|
BoostInfo* m_boostinfo[BTYPE_BOOST_LAST];
|
||||||
|
|
||||||
GameState m_gamestate = GameState::SPLASH;
|
GameState m_gamestate = GameState::SPLASH;
|
||||||
|
|
||||||
Shader m_shader01;
|
Shader m_shader01;
|
||||||
@ -169,9 +172,12 @@ private:
|
|||||||
float m_splashTime = 2.0f;
|
float m_splashTime = 2.0f;
|
||||||
float m_scale;
|
float m_scale;
|
||||||
float m_time = 0;
|
float m_time = 0;
|
||||||
|
|
||||||
float m_titleX = 0;
|
float m_titleX = 0;
|
||||||
float m_titleY = 0;
|
float m_titleY = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int m_renderCount = 0;
|
int m_renderCount = 0;
|
||||||
int m_countdown = COUNTDOWN;
|
int m_countdown = COUNTDOWN;
|
||||||
int m_nbReductionChunk = 4;
|
int m_nbReductionChunk = 4;
|
||||||
@ -186,7 +192,7 @@ private:
|
|||||||
|
|
||||||
bool m_selectedOptAudioMainBar = false;
|
bool m_selectedOptAudioMainBar = false;
|
||||||
bool m_selectedOptAudioMusicBar = false;
|
bool m_selectedOptAudioMusicBar = false;
|
||||||
bool m_selectedOptAudioSfxBar = false;
|
bool m_selectedOptAudioSfxBar = false;
|
||||||
bool m_selectedGameplaySensitivityBar = false;
|
bool m_selectedGameplaySensitivityBar = false;
|
||||||
|
|
||||||
bool m_damage = false;
|
bool m_damage = false;
|
||||||
@ -220,9 +226,10 @@ private:
|
|||||||
bool m_singleReady = false;
|
bool m_singleReady = false;
|
||||||
bool m_multiReady = false;
|
bool m_multiReady = false;
|
||||||
|
|
||||||
|
|
||||||
bool m_key1 = false;
|
bool m_key1 = false;
|
||||||
bool m_key2 = false;
|
bool m_key2 = false;
|
||||||
|
|
||||||
bool m_keyK = false;
|
bool m_keyK = false;
|
||||||
bool m_keyL = false;
|
bool m_keyL = false;
|
||||||
bool m_keyW = false;
|
bool m_keyW = false;
|
||||||
@ -244,7 +251,7 @@ private:
|
|||||||
float m_mousemy = 0;
|
float m_mousemy = 0;
|
||||||
|
|
||||||
bool m_networkgame = false;
|
bool m_networkgame = false;
|
||||||
|
|
||||||
Connector m_conn;
|
Connector m_conn;
|
||||||
std::deque<netprot::ChunkMod*> m_chunkmod_manifest;
|
std::deque<netprot::ChunkMod*> m_chunkmod_manifest;
|
||||||
std::chrono::high_resolution_clock::time_point m_startTime;
|
std::chrono::high_resolution_clock::time_point m_startTime;
|
||||||
@ -258,4 +265,4 @@ private:
|
|||||||
std::string m_messageNotification = "";
|
std::string m_messageNotification = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ENGINE_H__
|
#endif // ENGINE_H__
|
@ -120,7 +120,7 @@ void Renderer::RenderWorld(World* origin, int& rendercount, const Vector3f& play
|
|||||||
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
||||||
|
|
||||||
unsigned int sx, sy, cx, cy;
|
unsigned int sx, sy, cx, cy;
|
||||||
origin->GetScope(sx,sy);
|
origin->GetScope(sx, sy);
|
||||||
|
|
||||||
for (int index = 0; index < rendercount; ++index) {
|
for (int index = 0; index < rendercount; ++index) {
|
||||||
int chx = (renderManifest[index].x - sx) * CHUNK_SIZE_X, chy = (renderManifest[index].z - sy) * CHUNK_SIZE_Z;
|
int chx = (renderManifest[index].x - sx) * CHUNK_SIZE_X, chy = (renderManifest[index].z - sy) * CHUNK_SIZE_Z;
|
||||||
@ -129,9 +129,9 @@ void Renderer::RenderWorld(World* origin, int& rendercount, const Vector3f& play
|
|||||||
glLoadMatrixf(world.GetMatrix().GetInternalValues());
|
glLoadMatrixf(world.GetMatrix().GetInternalValues());
|
||||||
float blcolor = renderManifest[index].y / (VIEW_DISTANCE / 50.f);
|
float blcolor = renderManifest[index].y / (VIEW_DISTANCE / 50.f);
|
||||||
glBlendColor(blcolor, blcolor, blcolor, 1.f);
|
glBlendColor(blcolor, blcolor, blcolor, 1.f);
|
||||||
origin->ChunkAt(chx, 1, chy)->GetPosition(cx,cy);
|
origin->ChunkAt(chx, 1, chy)->GetPosition(cx, cy);
|
||||||
if (m_meshes.Get(cx - sx, cy - sy))
|
if (m_meshes.Get(cx - sx, cy - sy))
|
||||||
m_meshes.Get(cx - sx, cy -sy)->Render();
|
m_meshes.Get(cx - sx, cy - sy)->Render();
|
||||||
world.ApplyTranslation(-chx, 0, -chy);
|
world.ApplyTranslation(-chx, 0, -chy);
|
||||||
}
|
}
|
||||||
shader.Disable();
|
shader.Disable();
|
||||||
@ -147,7 +147,7 @@ void Renderer::UpdateMesh(World* origin, const Vector3f& player, BlockInfo* bloc
|
|||||||
int threads = 0;
|
int threads = 0;
|
||||||
std::future<Mesh*> updateThList[THREADS_UPDATE_CHUNKS];
|
std::future<Mesh*> updateThList[THREADS_UPDATE_CHUNKS];
|
||||||
|
|
||||||
unsigned int mx = 0 , my = 0, sx, sy;
|
unsigned int mx = 0, my = 0, sx, sy;
|
||||||
|
|
||||||
origin->GetScope(sx, sy);
|
origin->GetScope(sx, sy);
|
||||||
|
|
||||||
@ -244,27 +244,75 @@ 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)
|
void Renderer::RenderBooster(TextureAtlas& textureAtlas, Shader& shader, Transformation tran, Player player, Booster booster)
|
||||||
{
|
{
|
||||||
//float x = pos.x;
|
if (booster.GetAvailability() == true)
|
||||||
//float y = pos.y;
|
{
|
||||||
//float z = pos.z;
|
float width = 1.f;
|
||||||
//float width = 1.0f;
|
float height = 1.f;
|
||||||
//float height = 1.0f;
|
|
||||||
|
|
||||||
//float u, v, w, h;
|
Vector3f DiffCam = booster.GetPosition() - player.GetPosition();
|
||||||
//shader.Use();
|
Vector3f UpCam = Vector3f(0.f, 1.f, 0.f);
|
||||||
//textureAtlas.Bind();
|
|
||||||
//textureAtlas.TextureIndexToCoord(idx, u, v, w, h);
|
|
||||||
|
|
||||||
//glLoadMatrixf(tran.GetMatrix().GetInternalValues());
|
Vector3f CrossA = DiffCam.Cross(UpCam);
|
||||||
//glBegin(GL_QUADS);
|
Vector3f CrossB = DiffCam.Cross(CrossA);
|
||||||
//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);
|
CrossA.Normalize();
|
||||||
//glTexCoord2f(u + w, v + h); glVertex3f(x + width / 2., y, z); //glVertex3f(v2.x, v2.y, v2.z); //glVertex3f(50, 0, 0);
|
CrossB.Normalize();
|
||||||
//glTexCoord2f(u, v + h); glVertex3f(x - width / 2., y, z); //glVertex3f(v1.x, v1.y, v1.z);// glVertex3f(0, 0, 0);
|
|
||||||
//glEnd();
|
Vector3f playerPosition = booster.GetPosition() + Vector3f(0.f, -.75f, 0.f);
|
||||||
//shader.Disable();
|
|
||||||
|
Vector3f v2 = (playerPosition + CrossA * 0.5 * width + CrossB * 0.5 * height);
|
||||||
|
Vector3f v1 = (playerPosition - CrossA * 0.5 * width + CrossB * 0.5 * height);
|
||||||
|
Vector3f v3 = (playerPosition + CrossA * 0.5 * width - CrossB * 0.5 * height);
|
||||||
|
Vector3f v4 = (playerPosition - CrossA * 0.5 * width - CrossB * 0.5 * height);
|
||||||
|
|
||||||
|
int index;
|
||||||
|
BOOST_TYPE type = booster.GetType();
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case BTYPE_HEAL:
|
||||||
|
index = 5;
|
||||||
|
break;
|
||||||
|
case BTYPE_DAMAGE:
|
||||||
|
index = 6;
|
||||||
|
break;
|
||||||
|
case BTYPE_SPEED:
|
||||||
|
index = 7;
|
||||||
|
break;
|
||||||
|
case BTYPE_INVINCIBLE:
|
||||||
|
index = 8;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
index = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
float u, v, w, h;
|
||||||
|
|
||||||
|
shader.Use();
|
||||||
|
textureAtlas.Bind();
|
||||||
|
textureAtlas.TextureIndexToCoord(index, u, v, w, h);
|
||||||
|
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
|
|
||||||
|
glLoadMatrixf(tran.GetMatrix().GetInternalValues());
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glTexCoord2f(u, v); glVertex3f(v1.x, v1.y, v1.z);
|
||||||
|
glTexCoord2f(u + w, v); glVertex3f(v2.x, v2.y, v2.z);
|
||||||
|
glTexCoord2f(u + w, v + h); glVertex3f(v3.x, v3.y, v3.z);
|
||||||
|
glTexCoord2f(u, v + h); glVertex3f(v4.x, v4.y, v4.z);
|
||||||
|
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR);
|
||||||
|
glBlendEquation(GL_FUNC_SUBTRACT);
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
|
shader.Disable();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ public:
|
|||||||
|
|
||||||
void UpdateMesh(World* origin, const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]);
|
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 RenderBooster(TextureAtlas& textureAtlas, Shader& shader, Transformation tran, Player player, Booster booster);
|
||||||
|
|
||||||
void RenderWorld(World* origin, int& rendercount, const Vector3f& player_pos, const Vector3f& player_dir, Transformation world, Shader& shader, TextureAtlas& atlas) const;
|
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(Player* player, Transformation tran) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user