SQC-15_online #1
@ -131,6 +131,7 @@
|
||||
<ClInclude Include="array2d.h" />
|
||||
<ClInclude Include="array3d.h" />
|
||||
<ClInclude Include="blockinfo.h" />
|
||||
<ClInclude Include="boostinfo.h" />
|
||||
<ClInclude Include="bullet.h" />
|
||||
<ClInclude Include="chunk.h" />
|
||||
<ClInclude Include="define.h" />
|
||||
@ -144,6 +145,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="blockinfo.cpp" />
|
||||
<ClCompile Include="boostinfo.cpp" />
|
||||
<ClCompile Include="bullet.cpp" />
|
||||
<ClCompile Include="chunk.cpp" />
|
||||
<ClCompile Include="netprotocol.cpp" />
|
||||
|
@ -54,6 +54,9 @@
|
||||
<ClInclude Include="transformation.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="boostinfo.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="world.cpp">
|
||||
@ -80,5 +83,8 @@
|
||||
<ClCompile Include="transformation.cpp">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="boostinfo.cpp">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
32
SQCSim-common/boostinfo.cpp
Normal file
32
SQCSim-common/boostinfo.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include "boostinfo.h"
|
||||
#include <iostream>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
29
SQCSim-common/boostinfo.h
Normal file
29
SQCSim-common/boostinfo.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef BOOSTINFO_H__
|
||||
#define BOOSTINFO_H__
|
||||
|
||||
#include <string>
|
||||
#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__
|
@ -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
|
||||
|
@ -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; }
|
||||
|
@ -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__
|
||||
|
||||
|
@ -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__
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user