booster fonctionnel
manque la distribution booster sur la map
This commit is contained in:
parent
2364fb9c1f
commit
f2c5f8b636
@ -35,7 +35,7 @@
|
|||||||
#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 .1
|
#define BULLET_TIME .1
|
||||||
|
|
||||||
typedef uint8_t BlockType;
|
typedef uint8_t BlockType;
|
||||||
|
@ -198,7 +198,7 @@ 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);
|
TakeBooster(booster_table, elapsedTime);
|
||||||
RemoveBooster(elapsedTime);
|
RemoveBooster(elapsedTime);
|
||||||
return snd;
|
return snd;
|
||||||
}
|
}
|
||||||
@ -212,20 +212,22 @@ void Player::ApplyTransformation(Transformation& transformation, bool rel, bool
|
|||||||
if (rel) transformation.ApplyTranslation(-GetPOV());
|
if (rel) transformation.ApplyTranslation(-GetPOV());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::TakeBooster(Booster booster_table[])
|
void Player::TakeBooster(Booster booster_table[], float elapsedtime)
|
||||||
{
|
{
|
||||||
|
Vector3f playerpos = GetPosition();
|
||||||
for (int i = 0; i < sizeof(booster_table); i++)
|
for (int i = 0; i < sizeof(booster_table); i++)
|
||||||
{
|
{
|
||||||
Vector3f pos = booster_table[i].GetPosition();
|
Vector3f pos = booster_table[i].GetPosition();
|
||||||
if (abs((m_position.x + m_position.y + m_position.z) - (pos.x + pos.y +pos.z)) <= 0.5f && booster_table[i].GetAvailability() == true)
|
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());
|
GetBooster(booster_table[i].GetType(), elapsedtime);
|
||||||
booster_table[i].SetAvailability(false);
|
booster_table[i].SetAvailability(false);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::GetBooster(BOOST_TYPE boosttype)
|
void Player::GetBooster(BOOST_TYPE boosttype, float elapsedtime)
|
||||||
{
|
{
|
||||||
if (boosttype == BTYPE_SPEED)
|
if (boosttype == BTYPE_SPEED)
|
||||||
{
|
{
|
||||||
@ -234,7 +236,7 @@ void Player::GetBooster(BOOST_TYPE boosttype)
|
|||||||
}
|
}
|
||||||
if (boosttype == BTYPE_HEAL)
|
if (boosttype == BTYPE_HEAL)
|
||||||
{
|
{
|
||||||
m_hp = 100;
|
m_hp = 1.0f;
|
||||||
}
|
}
|
||||||
if (boosttype == BTYPE_DAMAGE)
|
if (boosttype == BTYPE_DAMAGE)
|
||||||
{
|
{
|
||||||
@ -252,19 +254,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,8 @@ public:
|
|||||||
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, Booster booster_table[]);
|
Sound ApplyPhysics(Vector3f input, World* world, float elapsedTime, Booster booster_table[]);
|
||||||
void TakeBooster(Booster booster_table[]);
|
void TakeBooster(Booster booster_table[], float elapsedTime);
|
||||||
void GetBooster(BOOST_TYPE boosttype);
|
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;
|
||||||
|
|
||||||
@ -72,9 +72,9 @@ protected:
|
|||||||
float m_hp;
|
float m_hp;
|
||||||
|
|
||||||
bool m_airborne;
|
bool m_airborne;
|
||||||
bool boostspeed;
|
bool boostspeed = false;
|
||||||
bool boostdamage;
|
bool boostdamage = false;
|
||||||
bool boostinvincible;
|
bool boostinvincible = false;
|
||||||
|
|
||||||
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);
|
||||||
};
|
};
|
||||||
|
@ -1304,6 +1304,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();
|
||||||
|
|
||||||
@ -1325,8 +1327,6 @@ void Engine::Render(float elapsedTime) {
|
|||||||
static float pollTime = 0;
|
static float pollTime = 0;
|
||||||
static float bulletTime = 0;
|
static float bulletTime = 0;
|
||||||
static BlockType bloc = 1;
|
static BlockType bloc = 1;
|
||||||
booster_table[0] = Booster({ 215, 15, 195 }, BTYPE_SPEED);
|
|
||||||
booster_table[1] = Booster({ 213, 15, 195 }, BTYPE_HEAL);
|
|
||||||
|
|
||||||
if (elapsedTime > 0.1f) return;
|
if (elapsedTime > 0.1f) return;
|
||||||
|
|
||||||
@ -1429,7 +1429,6 @@ void Engine::Render(float elapsedTime) {
|
|||||||
m_renderer.UpdateMesh(&m_world, m_player.GetPosition(), m_blockinfo);
|
m_renderer.UpdateMesh(&m_world, m_player.GetPosition(), m_blockinfo);
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
for (Booster booster : booster_table) {
|
for (Booster booster : booster_table) {
|
||||||
glClear(GL_STENCIL_BUFFER_BIT);
|
|
||||||
m_renderer.RenderBooster(m_textureAtlas, m_shader01, all, m_player, booster);
|
m_renderer.RenderBooster(m_textureAtlas, m_shader01, all, m_player, booster);
|
||||||
}
|
}
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user