Compare commits

...

98 Commits

Author SHA1 Message Date
MarcEricMartel
2c346139d5 Merge branch 'master' of git.frereschasseurs.studio:memartel_loc/SQCSimulator2023 2023-12-18 07:47:08 -05:00
MarcEricMartel
82747990d9
Merge pull request #43 from CegepSTH/SQC-15_online
Sqc 15 online
2023-12-16 16:56:31 -05:00
MarcEricMartel
0782f37e0a Might as well jump, JUMP! 2023-12-16 16:43:25 -05:00
MarcEricMartel
75f745efb8 Update player.cpp 2023-12-16 16:23:47 -05:00
MarcEricMartel
6efda6122d LETS TRY WITHOUT DAS JOOMP 2023-12-16 16:21:25 -05:00
MarcEricMartel
678776d6e6 Remove the dead code. 2023-12-16 16:13:20 -05:00
MarcEricMartel
4df53a5f9b Merge branch 'SQC-15_online' of https://github.com/CegepSTH/SQCSim2023 into SQC-15_online 2023-12-16 15:52:47 -05:00
MarcEricMartel
90892ce7d3 pop. 2023-12-16 15:52:39 -05:00
Claudel-D-Roy
5e1e8366ce j'push des choses 2023-12-16 15:52:27 -05:00
MarcEricMartel
7f9462881c Oops, all changes! 2023-12-16 15:27:20 -05:00
MarcEricMartel
2eacc0477b ?! 2023-12-16 15:15:25 -05:00
MarcEricMartel
745f40bc37 REVERT. 2023-12-16 15:11:48 -05:00
MarcEricMartel
ba6b383251 erratum 2023-12-16 15:05:26 -05:00
MarcEricMartel
1065357e70 Eh? 2023-12-16 15:05:06 -05:00
MarcEricMartel
4a4f353250 Merge branch 'SQC-15_online' of https://github.com/CegepSTH/SQCSim2023 into SQC-15_online 2023-12-16 14:41:07 -05:00
MarcEricMartel
63d1f997ca blob 2023-12-16 14:41:01 -05:00
Claudel-D-Roy
da94565c3e EL NIINIOOO 2023-12-16 14:41:00 -05:00
MarcEricMartel
1c2a691638 Bullet Time is slow. 2023-12-16 14:01:08 -05:00
MarcEricMartel
7803f46a6b WE ARE THE WORLD. 2023-12-16 13:14:37 -05:00
MarcEricMartel
38bab49806 Log de se faire tirer 2023-12-16 13:05:04 -05:00
MarcEricMartel
547d0fb3f8 Ça devrait crier moins 2023-12-16 12:57:04 -05:00
MarcEricMartel
dec9da6395 no more whoosh 2023-12-16 12:48:08 -05:00
MarcEricMartel
f564e37544 YYYAAAAAAARRRGGHH? 2023-12-16 12:32:54 -05:00
MarcEricMartel
ca1ab7301d Merge branch 'master' into SQC-15_online 2023-12-16 12:09:23 -05:00
Claudel-D-Roy
7a7ba94cbd Merge branch 'RepairWhoosh' 2023-12-16 12:09:04 -05:00
MarcEricMartel
ac50a044c7 Merge branch 'master' into SQC-15_online 2023-12-16 12:06:41 -05:00
MarcEricMartel
8062d8e31d lol 2023-12-16 12:05:57 -05:00
MarcEricMartel
4d278dfdea Pow pow t'es mow. 2023-12-16 12:05:14 -05:00
MarcEricMartel
da9fd2477d Update documents 2023-12-16 09:32:42 -05:00
MarcEricMartel
de8fe3c1c5 Merge branch 'master' into SQC-15_online 2023-12-15 07:13:16 -05:00
MarcEricMartel
5ee3fd143b Update engine.cpp 2023-12-15 07:11:35 -05:00
MarcEricMartel
77a982b1fa
Merge pull request #41 from CegepSTH/ConnexionVariablesMenuOptions
Connexion variables menu options
2023-12-15 07:02:09 -05:00
MarcEricMartel
e4316e7d8d Mis le son qui joue après que le volume soit changé pour les contrôles de volume 2023-12-15 06:39:18 -05:00
mduval76
935a977bdf Push options resolution fonctionnels. 2023-12-14 21:20:21 -05:00
mduval76
82bae1c21a Push background transparent pour menu options Graphics 2023-12-14 20:34:59 -05:00
mduval76
58c06f9f84 Push menu Lobby pour single player (entree du username seulement) 2023-12-14 19:33:25 -05:00
MarcEricMartel
8e77565bb4 Merge branch 'master' into SQC-15_online 2023-12-14 19:17:37 -05:00
mduval76
e5b0c742dd Push back button dans le lobbymenu 2023-12-14 18:25:15 -05:00
MarcEricMartel
1af88ba3e3 correction sfx 2023-12-14 14:02:29 -05:00
mduval76
383a19cbd2 Push mainvolume et musicvolume sliders fonctionnels. Bug sfx 2023-12-14 00:08:07 -05:00
mduval76
67270a0b21 Push options volume musique modifiable fonctionnel 2023-12-13 19:59:01 -05:00
mduval76
b101add0e7 Push sans les logs. 2023-12-13 19:13:02 -05:00
mduval76
0a0c70883b Push avec sensibilité souris - version fusionnée au master courant. 2023-12-13 19:12:22 -05:00
mduval76
879f93e2cd Validation des changements indexes... 2023-12-13 19:08:07 -05:00
mduval76
f7934be7f9 push ajustement de mp3 a wav pour sons 2023-12-13 19:02:17 -05:00
mduval76
0b4546eee9 Push sensibilite souris fonctionnelle. 2023-12-13 17:50:15 -05:00
mduval76
6ba316aa2d Push mouse sensitivity 2023-12-13 17:15:58 -05:00
Claudel-D-Roy
bb247d0afe Merge branch 'SQC-15_online' of https://github.com/CegepSTH/SQCSim2023 into SQC-15_online 2023-12-13 16:32:49 -05:00
Claudel-D-Roy
26d03ca5cc horriblé 2023-12-13 16:32:43 -05:00
MarcEricMartel
b8899b8f86 NO CHEATING! 2023-12-13 16:30:20 -05:00
MarcEricMartel
325c6b60f9 keep in sync when dead 2023-12-13 16:29:13 -05:00
MarcEricMartel
7b350fa403 Merge branch 'SQC-15_online' of https://github.com/CegepSTH/SQCSim2023 into SQC-15_online 2023-12-13 16:10:34 -05:00
MarcEricMartel
71691c55c8 Merge branch 'SQC-15_online' of https://github.com/CegepSTH/SQCSim2023 into SQC-15_online 2023-12-13 16:10:25 -05:00
MarcEricMartel
49374a7dea Let's all die! 2023-12-13 16:10:23 -05:00
Claudel-D-Roy
5a3ce00cb2 kjhg 2023-12-13 16:10:21 -05:00
Claudel-D-Roy
136f589975 Merge branch 'SQC-15_online' of https://github.com/CegepSTH/SQCSim2023 into SQC-15_online 2023-12-13 15:45:25 -05:00
Claudel-D-Roy
6d4f592278 k. 2023-12-13 15:45:17 -05:00
MarcEricMartel
37a86d42a3 lol infinite loop 2023-12-13 15:29:12 -05:00
Rynort
a08a6c7db3 Update doc_dev.docx 2023-12-13 15:25:48 -05:00
MarcEricMartel
2f3260b16a Merge branch 'SQC-15_online' of https://github.com/CegepSTH/SQCSim2023 into SQC-15_online 2023-12-13 15:23:20 -05:00
MarcEricMartel
08204934c8 No more 1. 2023-12-13 15:23:14 -05:00
Claudel-D-Roy
74875709af Merge branch 'SQC-15_online' of https://github.com/CegepSTH/SQCSim2023 into SQC-15_online 2023-12-13 15:21:36 -05:00
Claudel-D-Roy
28dc760cba potatoes 2023-12-13 15:21:23 -05:00
MarcEricMartel
c7c38ed44d Suicide is NOT the answer. 2023-12-13 15:21:19 -05:00
Claudel-D-Roy
53e0af3f94 PUSHING STUFF INTO THE VOID 2023-12-13 15:18:17 -05:00
Claudel-D-Roy
a11c52cf77 AH BEN TABARNOUCHE 2023-12-13 15:14:38 -05:00
MarcEricMartel
b1fc9d7d92 Merge branch 'SQC-15_online' of https://github.com/CegepSTH/SQCSim2023 into SQC-15_online 2023-12-13 15:04:10 -05:00
MarcEricMartel
a85c5cc626 🔫 2023-12-13 15:04:08 -05:00
Claudel-D-Roy
4c3803c02e pleurer en animation 2023-12-13 14:46:53 -05:00
MarcEricMartel
5e09305398 Merge branch 'SQC-15_online' of https://github.com/CegepSTH/SQCSim2023 into SQC-15_online 2023-12-13 14:27:18 -05:00
MarcEricMartel
fd1fe66d13 SYNC_ACC CMOD_ACC GLOBALS 2023-12-13 14:27:11 -05:00
Claudel-D-Roy
edebad86a6 Blahblahblah 2023-12-13 14:26:46 -05:00
MarcEricMartel
2dbaf84844 Merge branch 'SQC-15_online' of https://github.com/CegepSTH/SQCSim2023 into SQC-15_online 2023-12-13 14:06:29 -05:00
MarcEricMartel
e31e670720 Yaya 2023-12-13 14:06:22 -05:00
Claudel-D-Roy
d8cbc27ca9 ALLO 2023-12-13 14:06:11 -05:00
Claudel-D-Roy
c801877a0c polipocket 2023-12-13 13:53:10 -05:00
Claudel-D-Roy
f4347d35df secret 2023-12-13 13:51:37 -05:00
MarcEricMartel
f509b01827 Merge branch 'SQC-15_online' of https://github.com/CegepSTH/SQCSim2023 into SQC-15_online 2023-12-13 13:47:41 -05:00
MarcEricMartel
18d6d58203 There's a bullet without my name on it. 2023-12-13 13:47:34 -05:00
Claudel-D-Roy
83fc600ce2 l;kjhgfd 2023-12-13 13:46:57 -05:00
Claudel-D-Roy
0e45b2b81e essaie no. 89657657457 2023-12-13 13:33:44 -05:00
Claudel-D-Roy
d3c6353f17 Merge branch 'SQC-15_online' of https://github.com/CegepSTH/SQCSim2023 into SQC-15_online 2023-12-13 13:18:28 -05:00
Claudel-D-Roy
8fbb92ec5b ghfudk 2023-12-13 13:17:29 -05:00
MarcEricMartel
64655856e9 gniah. 2023-12-13 13:13:34 -05:00
MarcEricMartel
a6b6ac870a Update sync plus vite. 2023-12-13 13:01:52 -05:00
MarcEricMartel
5ef6ab5006 Merge branch 'master' into SQC-15_online 2023-12-13 12:57:41 -05:00
MarcEricMartel
7ffccc8bf8 woups^2 2023-12-13 12:39:24 -05:00
MarcEricMartel
c9ebfd348c woups 2023-12-13 12:38:19 -05:00
Claudel-D-Roy
ae247a58a8 Merge branch 'SQC_MenuMusic' 2023-12-13 12:15:39 -05:00
MarcEricMartel
2f53f74ca9 Erratum 2 2023-12-13 11:21:42 -05:00
MarcEricMartel
3d0b35123a Erratum 2023-12-13 11:11:14 -05:00
MarcEricMartel
aacfb880f0 + son de clic quand on clique. 2023-12-13 10:55:58 -05:00
Jonathan Trottier
6c68114fbb
Merge pull request #39 from CegepSTH/PauseMenuFieldsAndOnline
Beaucoup de belles choses
2023-12-12 19:28:28 -05:00
MarcEricMartel
b840e3ad19 Erratum 2023-12-12 09:31:56 -05:00
MarcEricMartel
7a30e43001 Merge branch 'SQC-15_online' into PauseMenuFieldsAndOnline 2023-12-12 09:31:01 -05:00
mduval76
c099a3b8eb Push menu pause fonctionnel 2023-12-11 21:41:40 -05:00
MarcEricMartel
7498076d7a Corrections timer 2023-12-11 07:31:20 -05:00
MarcEricMartel
7c1f70646a Correction bug de switch de fullscreen 2023-12-11 05:35:29 -05:00
31 changed files with 857 additions and 485 deletions

View File

@ -48,7 +48,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>ClangCL</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>

View File

@ -3,27 +3,34 @@
Bullet::Bullet(Vector3f pos, Vector3f dir) : m_startpos(pos), m_currentpos(pos), m_velocity(dir) {}
Bullet::Bullet(Vector3f pos, Vector3f dir, uint64_t shooter_id): m_startpos(pos), m_currentpos(pos), m_velocity(dir), m_shooter_id(shooter_id) {}
Bullet::Bullet(Vector3f pos, Vector3f dir, uint64_t shooter_id) : m_startpos(pos), m_currentpos(pos), m_velocity(dir), m_shooter_id(shooter_id) {}
Bullet::Bullet(Vector3f pos, Vector3f dir, uint64_t shooter_id, bool canhurt): m_startpos(pos), m_currentpos(pos), m_velocity(dir), m_shooter_id(shooter_id), m_canhurt(canhurt) {}
Bullet::~Bullet() {}
bool Bullet::Update(World* world, float elapsedtime, int perframe, std::unordered_map<uint64_t, Player*> mapPlayer, netprot::ChunkMod** chunkmod) {
int max = 100 / perframe;
float damage = 0.057f;
float damage = 0.098f;
for (int x = 0; x < max; ++x) {
m_currentpos += m_velocity * elapsedtime;
for (auto& [key, player] : mapPlayer) {
if (key == m_shooter_id)
continue;
bool hit = false;
if ((m_currentpos - player->GetPosition()).Length() < .6f) {
if ((m_currentpos - player->GetPosition()).Length() < 1.5f) {
hit = true;
}
if ((m_currentpos - player->GetPOV()).Length() < .2f) {
else if ((m_currentpos - player->GetPOV()).Length() < .7f) {
damage *= 2; // HEADSHOT!
hit = true;
}
if (hit && !player->AmIDead()) {
player->InflictDamage(damage);
if (m_canhurt)
player->InflictDamage(damage);
player->m_hit = true;
if (player->AmIDead())
@ -36,15 +43,17 @@ bool Bullet::Update(World* world, float elapsedtime, int perframe, std::unordere
if (!world->ChunkAt(m_currentpos))
return true;
else if (world->BlockAt(m_currentpos) != BTYPE_AIR) {
if (chunkmod) {
using namespace netprot;
*chunkmod = new ChunkMod();
(*chunkmod)->old_b_type = world->BlockAt(m_currentpos);
(*chunkmod)->b_type = BTYPE_AIR;
(*chunkmod)->pos = m_currentpos;
}
if (m_canhurt) {
if (chunkmod) {
using namespace netprot;
*chunkmod = new ChunkMod();
(*chunkmod)->old_b_type = world->BlockAt(m_currentpos);
(*chunkmod)->b_type = BTYPE_AIR;
(*chunkmod)->pos = m_currentpos;
}
world->ChangeBlockAtPosition(BTYPE_AIR, m_currentpos);
world->ChangeBlockAtPosition(BTYPE_AIR, m_currentpos);
}
return true;
}
else if ((m_currentpos - m_startpos).Length() > VIEW_DISTANCE) return true;

View File

@ -14,6 +14,7 @@ class Bullet {
public:
Bullet(Vector3f pos, Vector3f dir);
Bullet(Vector3f pos, Vector3f dir, uint64_t tid);
Bullet(Vector3f pos, Vector3f dir, uint64_t tid, bool canhurt);
~Bullet();
bool Update(World* world, float elapsedtime, int perframe, std::unordered_map<uint64_t, Player*> m_mapPlayer, netprot::ChunkMod** chunkmod);
@ -28,6 +29,8 @@ private:
m_velocity;
uint64_t m_shooter_id = 0;
bool m_canhurt = true;
};

View File

@ -35,7 +35,10 @@
#define TIME_DAMAGE_BOOST 10 //secondes
#define TIME_INVINCIBLE_BOOST 4 //secondes
#define STRENGTH_SPEED_BOOST 10 //Pourcentage
#define BULLET_TIME .1
#define BULLET_TIME .2 //secondes
#define SYNC_ACC 600 // ms
#define CMOD_ACC 1000 // ms
typedef uint8_t BlockType;
enum BLOCK_TYPE { BTYPE_AIR, BTYPE_DIRT, BTYPE_GRASS, BTYPE_METAL, BTYPE_ICE, BTYPE_GREENGRASS, BTYPE_LAST };

View File

@ -4,14 +4,15 @@
Player::Player(const Vector3f& position, float rotX, float rotY) : m_position(position), m_rotX(rotX), m_rotY(rotY) {
m_velocity = Vector3f(0, 0, 0);
m_airborne = true;
m_hp = 1.0f; //TODO: Remettre <20> 1.0f
m_hp = 1.0f;
m_sensitivity = 0.5f;
m_username = "Zelda Bee-Bop56";
}
Player::~Player() {}
void Player::TurnLeftRight(float value) {
m_rotY += value;
void Player::TurnLeftRight(float value, float sensitivity) {
m_rotY += value * sensitivity;
if (m_rotY > 360) m_rotY = 0;
else if (m_rotY < -360) m_rotY = 0;
@ -25,8 +26,8 @@ void Player::TurnLeftRight(float value) {
m_direction.Normalize();
}
void Player::TurnTopBottom(float value) {
m_rotX += value;
void Player::TurnTopBottom(float value, float sensitivity) {
m_rotX += value * sensitivity;
if (m_rotX > 80) m_rotX = 80;
else if (m_rotX < -80) m_rotX = -80;
@ -78,7 +79,7 @@ Vector3f Player::GetInput(bool front, bool back, bool left, bool right, bool jum
}
if (shoot) // Recoil!
TurnTopBottom(-1);
TurnTopBottom(-1, 1.0f);
return delta;
}
@ -122,35 +123,55 @@ Player::Sound Player::ApplyPhysics(Vector3f input, World* world, float elapsedTi
bt1 = world->BlockAt(GetPosition().x + input.x, GetPosition().y, GetPosition().z);
bt2 = world->BlockAt(GetPosition().x + input.x, GetPosition().y - 0.9f, GetPosition().z);
bt3 = world->BlockAt(GetPosition().x + input.x, GetPosition().y - 1.7f, GetPosition().z);
if (bt1 == BTYPE_AIR && bt2 != BTYPE_AIR && bt3 != BTYPE_AIR) {
if (input.x > 0)
input.x = m_velocity.x = 0.5f;
else
input.x = m_velocity.x = -0.5f;
m_velocity.y = 0.3;
m_velocity.z *= .5f;
}
else if (bt1 != BTYPE_AIR || bt2 != BTYPE_AIR || bt3 != BTYPE_AIR) {
input.x = m_velocity.x = 0;
if (bt1 != BTYPE_AIR || bt2 != BTYPE_AIR || bt3 != BTYPE_AIR) {
//input.x = m_velocity.x = 0;
m_velocity.y += .04f;
m_velocity.z *= .5f;
m_velocity.x *= .5f;
}
bt1 = world->BlockAt(GetPosition().x, GetPosition().y, GetPosition().z + input.z);
bt2 = world->BlockAt(GetPosition().x, GetPosition().y - 0.9f, GetPosition().z + input.z);
bt3 = world->BlockAt(GetPosition().x, GetPosition().y - 1.7f, GetPosition().z + input.z);
if (bt1 == BTYPE_AIR && bt2 != BTYPE_AIR && bt3 != BTYPE_AIR) {
if (input.z > 0)
input.z = m_velocity.z = 0.5f;
else
input.z = m_velocity.z = -0.5f;
m_velocity.y = 0.3;
m_velocity.x *= .5f;
}
else if (bt1 != BTYPE_AIR || bt2 != BTYPE_AIR || bt3 != BTYPE_AIR) {
input.z = m_velocity.z = 0;
if (bt1 != BTYPE_AIR || bt2 != BTYPE_AIR || bt3 != BTYPE_AIR) {
//input.z = m_velocity.z = 0;
m_velocity.y += .04f;
m_velocity.z *= .5f;
m_velocity.x *= .5f;
}
//bt1 = world->BlockAt(GetPosition().x + input.x, GetPosition().y, GetPosition().z);
//bt2 = world->BlockAt(GetPosition().x + input.x, GetPosition().y - 0.9f, GetPosition().z);
//bt3 = world->BlockAt(GetPosition().x + input.x, GetPosition().y - 1.7f, GetPosition().z);
//if (bt1 == BTYPE_AIR && bt2 != BTYPE_AIR && bt3 != BTYPE_AIR) {
// if (input.x > 0)
// input.x = m_velocity.x = 0.5f;
// else
// input.x = m_velocity.x = -0.5f;
// m_velocity.y = 0.3;
// m_velocity.z *= .5f;
//}
//else if (bt1 != BTYPE_AIR || bt2 != BTYPE_AIR || bt3 != BTYPE_AIR) {
// input.x = m_velocity.x = 0;
// m_velocity.z *= .5f;
//}
//bt1 = world->BlockAt(GetPosition().x, GetPosition().y, GetPosition().z + input.z);
//bt2 = world->BlockAt(GetPosition().x, GetPosition().y - 0.9f, GetPosition().z + input.z);
//bt3 = world->BlockAt(GetPosition().x, GetPosition().y - 1.7f, GetPosition().z + input.z);
//if (bt1 == BTYPE_AIR && bt2 != BTYPE_AIR && bt3 != BTYPE_AIR) {
// if (input.z > 0)
// input.z = m_velocity.z = 0.5f;
// else
// input.z = m_velocity.z = -0.5f;
// m_velocity.y = 0.3;
// m_velocity.x *= .5f;
//}
//else if (bt1 != BTYPE_AIR || bt2 != BTYPE_AIR || bt3 != BTYPE_AIR) {
// input.z = m_velocity.z = 0;
// m_velocity.x *= .5f;
//}
/* Fin gestion de collisions */
/* Gestion de la friction */
@ -204,11 +225,7 @@ Player::Sound Player::ApplyPhysics(Vector3f input, World* world, float elapsedTi
void Player::ApplyTransformation(Transformation& transformation, bool rel, bool rot) const {
transformation.ApplyRotation(-m_rotX, 1, 0, 0);
transformation.ApplyRotation(-m_rotY, 0, 1, 0);
if (rel) transformation.ApplyTranslation(-GetPOV());
}
void Player::GetBooster(Booster boosttype)
@ -270,8 +287,24 @@ Vector3f Player::GetDirection() const { return m_direction; }
std::string Player::GetUsername() const { return m_username; }
void Player::SetUsername(std::string username) {
m_username = username;
}
float Player::GetSensitivity() const {
return m_sensitivity;
}
void Player::SetSensitivity(float sensitivity) {
m_sensitivity = sensitivity;
}
float Player::GetHP() const { return m_hp; }
void Player::SetHP(float hp) {
m_hp = hp;
}
void Player::Teleport(int& x, int& z) {
m_position.x -= x * CHUNK_SIZE_X;
m_position.z -= z * CHUNK_SIZE_Z;
@ -285,9 +318,6 @@ void Player::InflictDamage(float hitPoints) {
if (m_hp < 0)
m_hp == 0;
//if (AmIDead())
//{ // Quand le joueur est mort.
//}
}
int Player::getScore() const { return m_score; }

View File

@ -16,8 +16,8 @@ public:
Player(const Vector3f& position, float rotX = 0, float rotY = 0);
~Player();
void TurnLeftRight(float value);
void TurnTopBottom(float value);
void TurnLeftRight(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);
Sound ApplyPhysics(Vector3f input, World* world, float elapsedTime);
void GetBooster(Booster boosttype);
@ -32,7 +32,11 @@ public:
Vector3f GetVelocity() const;
Vector3f GetPOV() const;
std::string GetUsername() const;
void SetUsername(std::string username);
float GetSensitivity() const;
void SetSensitivity(float sensitivity);
float GetHP() const;
void SetHP(float hp);
void Teleport(int& x, int& z);
bool GetIsAirborne() const;
@ -44,6 +48,8 @@ public:
std::string m_username;
bool m_hit = false;
bool Eulogy = false;
private:
uint64_t getId() const;
@ -61,6 +67,7 @@ protected:
float timeboostspeed;
float timeboostdamage;
float timeboostinvincible;
float m_sensitivity;
float m_hp;
@ -69,8 +76,6 @@ protected:
bool boostdamage;
bool boostinvincible;
Vector3f InterpolatePosition(const Vector3f& vec1, const Vector3f& vec2, const Timestamp& tim1, const Timestamp& tim2, const Timestamp& now);
};
#endif //_PLAYER_H__

View File

@ -49,8 +49,6 @@ void World::RemoveChunk(int nbReduit)
if (x > WORLD_SIZE_X - nbReduit)
chk = m_chunks.Remove(x, y);
// TODO: MakeDirty() les voisins pour qu'ils se redessinent.
if (!chk)
continue;
@ -167,7 +165,6 @@ void World::GetScope(unsigned int& x, unsigned int& y) {
void World::Update(Bullet* bullets[MAX_BULLETS], const Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]) {
UpdateWorld(player_pos, blockinfo);
//TransposeWorld(player_pos, bullets);
}
netprot::ChunkMod* World::ChangeBlockAtCursor(BlockType blockType, const Vector3f& player_pos, const Vector3f& player_dir, bool& block, bool net) {
@ -258,7 +255,6 @@ void World::UpdateWorld(const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]
int side = 0;
int threads = 0;
std::future<Chunk*> genThList[THREADS_GENERATE_CHUNKS];
//std::future<void> delThList[THREADS_DELETE_CHUNKS];
if (frameGenerate > 0) --frameGenerate;
if (frameUpdate > 0) --frameUpdate;
@ -349,101 +345,6 @@ void World::UpdateWorld(const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]
side = 0;
threads = 0;
//if (!frameUpdate)
// while (side * CHUNK_SIZE_X <= VIEW_DISTANCE * 2) {
// int tx = -side, ty = -side;
// for (; tx <= side; ++tx) {
// if (frameUpdate)
// break;
// unsigned int chx = cx + tx * CHUNK_SIZE_X, chy = cy + ty * CHUNK_SIZE_Z;
// if (ChunkAt(chx, 1, chy) &&
// ChunkAt(chx, 1, chy)->IsDirty()) {
// updateThList[threads++] =
// std::async(std::launch::async,
// [](Chunk* chunk, BlockInfo* blockinfo[BTYPE_LAST], World* world) {
// chunk->Update(blockinfo, world); return chunk; }, ChunkAt(chx, 1, chy), blockinfo, this);
// if (threads == THREADS_UPDATE_CHUNKS) frameUpdate = FRAMES_UPDATE_CHUNKS;
// }
// }
// for (; ty <= side; ++ty) {
// if (frameUpdate)
// break;
// unsigned int chx = cx + tx * CHUNK_SIZE_X, chy = cy + ty * CHUNK_SIZE_Z;
// if (ChunkAt(chx, 1, chy) &&
// ChunkAt(chx, 1, chy)->IsDirty()) {
// updateThList[threads++] =
// std::async(std::launch::async,
// [](Chunk* chunk, BlockInfo* blockinfo[BTYPE_LAST], World* world) {
// chunk->Update(blockinfo, world); return chunk; }, ChunkAt(chx, 1, chy), blockinfo, this);
// if (threads == THREADS_UPDATE_CHUNKS) frameUpdate = FRAMES_UPDATE_CHUNKS;
// }
// }
// for (; tx >= -side; --tx) {
// if (frameUpdate)
// break;
// unsigned int chx = cx + tx * CHUNK_SIZE_X, chy = cy + ty * CHUNK_SIZE_Z;
// if (ChunkAt(chx, 1, chy) &&
// ChunkAt(chx, 1, chy)->IsDirty()) {
// updateThList[threads++] =
// std::async(std::launch::async,
// [](Chunk* chunk, BlockInfo* blockinfo[BTYPE_LAST], World* world) {
// chunk->Update(blockinfo, world); return chunk; }, ChunkAt(chx, 1, chy), blockinfo, this);
// if (threads == THREADS_UPDATE_CHUNKS) frameUpdate = FRAMES_UPDATE_CHUNKS;
// }
// }
// for (; ty >= -side; --ty) {
// if (frameUpdate)
// break;
// unsigned int chx = cx + tx * CHUNK_SIZE_X, chy = cy + ty * CHUNK_SIZE_Z;
// if (ChunkAt(chx, 1, chy) &&
// ChunkAt(chx, 1, chy)->IsDirty()) {
// updateThList[threads++] =
// std::async(std::launch::async,
// [](Chunk* chunk, BlockInfo* blockinfo[BTYPE_LAST], World* world) {
// chunk->Update(blockinfo, world); return chunk; }, ChunkAt(chx, 1, chy), blockinfo, this);
// if (threads == THREADS_UPDATE_CHUNKS) frameUpdate = FRAMES_UPDATE_CHUNKS;
// }
// }
// if (frameUpdate)
// break;
// ++side;
// }
//if (threads > 0) {
// for (int i = 0; i < threads; ++i) {
// updateThList[i].wait();
// Chunk* chunk = updateThList[i].get();
// chunk->FlushMeshToVBO();
// }
//}
threads = 0;
//int del = THREADS_DELETE_CHUNKS;
//while (!m_tbDeleted.empty() && del--) { // Moins rapide que le bout en dessous, mais -beaucoup- plus stable.
// m_tbDeleted.back()->FlushVBO();
// m_tbDeleted.back()->~Chunk();
// m_tbDeleted.pop_back();
//}
/*while (!m_tbDeleted.empty() && !frameDelete) {
if (m_tbDeleted.back()) {
m_tbDeleted.back()->FlushVBO();
delThList[threads] =
std::async(std::launch::async,
[](Chunk* chunk) { delete chunk; }, m_tbDeleted.back());
m_tbDeleted.pop_back();
if (++threads > THREADS_DELETE_CHUNKS) frameDelete = FRAMES_DELETE_CHUNKS;
}
else m_tbDeleted.pop_back();
}*/
/*for (int x = 0; x < threads; ++x) {
delThList[x].wait();
delThList[x].get();
}*/
}
int World::GettbDeleted() const { return m_tbDeleted.size(); }

View File

@ -48,7 +48,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>ClangCL</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>

View File

@ -59,7 +59,9 @@ void Connection::getPacks(SOCKET sock) {
switch (netprot::getType(pck, 1)) {
using enum netprot::PACKET_TYPE;
case INPUT:
if (Deserialize(&in, pck, &bsize)) {
if (player->AmIDead())
break;
else if (Deserialize(&in, pck, &bsize)) {
m_input_manifest[in.timestamp] = in;
m_input_vector.push_back(in);
}
@ -77,8 +79,23 @@ void Connection::getPacks(SOCKET sock) {
void Connection::sendPacks(SOCKET sock, std::unordered_map<uint64_t, Connection*> conns, const uint32_t timer) {
static int outs = 0;
static Timestamp last = 0;
static uint32_t lasttimer = timer;
if (m_output_vector.empty() && player->AmIDead()) {
if (timer != lasttimer) {
lasttimer = timer;
Sync sync;
sync.timestamp = sync.sid = m_loginfo.sid;
sync.hp = 0;
sync.ammo = -1;
sync.timer = timer;
sendPackTo<Sync>(sock, &sync, &m_bufout, &m_addr);
}
}
while (!m_output_vector.empty()) {
Output out = m_output_vector.front();
for (auto& [key, conn] : conns) {
if (m_playinfo.id == conn->GetHash(false))
continue;
@ -91,16 +108,23 @@ void Connection::sendPacks(SOCKET sock, std::unordered_map<uint64_t, Connection*
outs += out.timestamp + last;
if (outs >= 1000) {
outs -= 1000;
static bool syncdead = false;
bool dead = player->AmIDead();
if (outs >= SYNC_ACC || (!syncdead && dead)) {
Sync sync;
sync.hp = player->GetHP();
outs -= SYNC_ACC;
sync.timestamp = out.timestamp;
sync.position = out.position;
sync.sid = m_loginfo.sid;
sync.timer = timer;
sync.timestamp = out.timestamp;
sync.ammo = -1;
sync.hp = player->GetHP();
if (dead) {
sync.timestamp = m_loginfo.sid;
syncdead = true;
}
sendPackTo<Sync>(sock, &sync, &m_bufout, &m_addr);
}
@ -114,27 +138,33 @@ Timestamp Connection::Run(World* world) {
Timestamp tstamp = 0;
float el;
if (m_input_manifest.size() < 2)
bool dead = player->AmIDead();
if (m_input_manifest.size() < 2 && !dead)
return tstamp;
if (player->AmIDead()) {
m_input_manifest.clear();
return tstamp;
}
while (m_last_in < m_input_vector.size() - 1 || dead) {
if (!dead) {
in = m_input_vector.at(m_last_in + 1);
last = m_input_vector.at(m_last_in);
if (in.timestamp <= m_tstamp) {
++m_last_in;
continue;
}
el = (double)(in.timestamp - last.timestamp) / 1000.;
if (m_shoot_acc > 0.) {
m_shoot_acc -= el;
if (m_shoot_acc < 0.)
m_shoot_acc = 0.;
}
player->SetDirection(in.direction);
}
else {
el = 1. / 60.;
in = Input();
while (m_last_in < m_input_vector.size() - 1) {
in = m_input_vector.at(m_last_in + 1);
last = m_input_vector.at(m_last_in);
el = (double)(in.timestamp - last.timestamp) / 1000.;
if (m_shoot_acc > 0.) {
m_shoot_acc -= el;
if (m_shoot_acc < 0.)
m_shoot_acc = 0;
}
player->SetDirection(in.direction);
player->ApplyPhysics(player->GetInput(in.keys.forward,
in.keys.backward,
in.keys.left,
@ -147,7 +177,10 @@ Timestamp Connection::Run(World* world) {
}
out.states.jumping = player->GetIsAirborne();
out.states.running = player->GetVelocity().Length() > .5f;
Vector3f horSpeed = player->GetVelocity();
horSpeed.y = 0;
out.states.running = horSpeed.Length() > .2f;
out.states.still = !out.states.running && !out.states.jumping;
out.states.hit = player->m_hit;
player->m_hit = false;
@ -180,7 +213,7 @@ Timestamp Connection::Run(World* world) {
else out.states.jumpshot = false;
if (in.keys.shoot && m_shoot_acc <= 0.) {
Bullets.push_back(std::move(new Bullet(player->GetPOV() + player->GetDirection(), player->GetDirection(), GetHash(true))));
Bullets.emplace_back(new Bullet(player->GetPOV() + player->GetDirection(), player->GetDirection(), GetHash(true)));
m_shoot_acc = BULLET_TIME;
}
@ -190,9 +223,12 @@ Timestamp Connection::Run(World* world) {
out.id = m_playinfo.id;
m_output_manifest[out.timestamp] = out;
m_output_vector.push_back(out);
tstamp = out.timestamp;
m_tstamp = tstamp = out.timestamp;
++m_last_in;
if (!dead)
++m_last_in;
dead = false;
}
return tstamp;

View File

@ -202,8 +202,8 @@ void Server::Run() {
m_conns.erase(key);
continue;
}
int x = (rand() % (CHUNK_SIZE_X * WORLD_SIZE_X - 1) - (CHUNK_SIZE_X * WORLD_SIZE_X / 2)) / 8,
y = (rand() % (CHUNK_SIZE_Y * WORLD_SIZE_Y - 1) - (CHUNK_SIZE_Y * WORLD_SIZE_Y / 2)) / 8;
int x = (rand() % (CHUNK_SIZE_X * WORLD_SIZE_X - 1) - (CHUNK_SIZE_X * WORLD_SIZE_X / 2)) / 16,
y = (rand() % (CHUNK_SIZE_Y * WORLD_SIZE_Y - 1) - (CHUNK_SIZE_Y * WORLD_SIZE_Y / 2)) / 16;
conn->player = new Player(Vector3f(x + .5f, CHUNK_SIZE_Y + 1.8f, y + .5f));
conn->player->m_username = conn->GetName();
m_players[key] = conn->player;
@ -217,7 +217,7 @@ void Server::Run() {
sendPackTo<Sync>(m_sock_udp, &sync, &m_buf, conn->getAddr());
}
int timer = m_game.countdown, sync_acc = 0, deadplayers = 0;
int timer = m_game.countdown, timer_acc = 0, deadplayers = 0;
std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now();
Timestamp last = 0;
std::vector<Chat*> chatlog;
@ -230,22 +230,23 @@ void Server::Run() {
Chat* startchat = new Chat();
startchat->src_id = 0;
char startmess[] = "How would -YOU- like to die today, motherf-words?";
float endtime = 0.;
strcpy(startchat->mess, 140, startmess);
chatlog.emplace_back(startchat);
while (!endgame) {
while (!endgame && endtime < 1.) {
using namespace std::chrono;
Timestamp tstamp = duration_cast<milliseconds>(high_resolution_clock::now() - start).count();
if (last == 0)
last = tstamp;
sync_acc += tstamp - last;
if (sync_acc >= 1000) {
while (sync_acc >= 1000)
sync_acc -= 1000;
--timer;
timer_acc += tstamp - last;
if (timer_acc >= 1000) {
while (timer_acc >= 1000)
timer_acc -= 1000;
if (!endgame)
--timer;
std::string str = "Timer: ";
Log(str.append(std::to_string(timer)), false, false);
}
@ -275,34 +276,43 @@ void Server::Run() {
default: break;
}
}
lsPck.clear();
if (!lsPck.empty())
lsPck.clear();
/* Process */
if (conn->m_nsync) {
Timestamp tstamp = conn->Run(m_world);
if (conn->player->AmIDead()) {
if (conn->player->AmIDead() && !conn->player->Eulogy) {
Chat* chat = new Chat();
chat->dest_id = chat->dest_team_id = chat->src_id = 0;
chat->dest_id = chat->dest_team_id = chat->src_id = 0;
std::string killer = m_conns.at(conn->player->Killer)->player->GetUsername();
Player* murderer = m_conns.at(conn->player->Killer)->player;
if (murderer != conn->player)
murderer->addPoint();
std::string killer = murderer->GetUsername();
std::string mess = getDeathMessage(conn->player->GetUsername(), killer);
strcpy(chat->mess, 140, mess.c_str());
chatlog.emplace_back(chat);
++deadplayers;
conn->player->Eulogy = true;
conn->m_nsync = false;
}
else {
for (auto& chmo : conn->ChunkDiffs)
chunkdiffs.emplace_back(std::move(chmo));
conn->ChunkDiffs.clear();
if (!conn->ChunkDiffs.empty())
conn->ChunkDiffs.clear();
for (auto& bull : conn->Bullets) {
bullets.emplace_back(bull);
//Log("POW!", false, false);
BulletAdd* nbul = new BulletAdd();
nbul->pos = bull->getPos();
nbul->dir = bull->getVel();
@ -311,15 +321,50 @@ void Server::Run() {
netbull.emplace_back(std::move(nbul));
}
conn->Bullets.clear();
if (!conn->Bullets.empty())
conn->Bullets.clear();
}
/* Out */
conn->sendPacks(m_sock_udp, m_conns, timer);
}
if ((deadplayers == players - 1 && deadplayers != 0) || timer <= 0)
/* Out */
conn->sendPacks(m_sock_udp, m_conns, timer);
if ((deadplayers == players - 1 && deadplayers != 0) || timer < 0) {
if (!endgame) {
Chat* gameover = new Chat();
gameover->dest_id = gameover->dest_team_id = gameover->src_id = 0;
std::string winner, winmess;
int score = 0;
bool plural = false;
for (auto& [key, conn] : m_conns) {
if (conn->player->getScore() > score) {
winner = conn->player->GetUsername();
score = conn->player->getScore();
plural = false;
}
else if (conn->player->getScore() == score) {
winner = winner.append(" and ").append(conn->player->GetUsername());
plural = true;
}
}
winmess = "And the winner";
if (!plural)
winmess = winmess.append(" is ");
else winmess = winmess.append("s are ");
winmess = winmess.append(winner).append(" with ").append(std::to_string(score)).append(" point");
if (score > 1)
winmess = winmess.append("s.");
else winmess = winmess.append(".");
strcpy(gameover->mess, 140, winmess.c_str());
chatlog.emplace_back(gameover);
}
endgame = true;
endtime += .001;
}
}
for (auto& bull : netbull) {
@ -328,36 +373,43 @@ void Server::Run() {
sendPackTo<BulletAdd>(m_sock_udp, bull, &m_buf, conn->getAddr());
delete bull;
}
netbull.clear();
if (!netbull.empty())
netbull.clear();
for (auto bull = bullets.begin(); bull != bullets.end(); ++bull) {
ChunkMod* cmod = nullptr;
Bullet* bullet = *bull;
if (bullet->Update(m_world, (1. / 60.), 20, m_players, &cmod)) {
if (bullet->Update(m_world, (1. / 60.), 50, m_players, &cmod)) {
if (cmod)
chunkdiffs.emplace_back(cmod);
bullit.push_back(bull);
delete bullet;
}
}
for (auto& bull: bullit)
for (auto& bull : bullit) {
delete* bull;
bullets.erase(bull);
bullit.clear();
}
if (!bullit.empty())
bullit.clear();
for (auto& chat : chatlog) {
Log(chat->mess, false, false);
Log(chat->mess, false, false);
for (auto& [key, conn] : m_conns)
sendPackTo<Chat>(m_sock_udp, chat, &m_buf, conn->getAddr());
delete chat;
}
chatlog.clear();
if (!chatlog.empty())
chatlog.clear();
for (auto& chmo : chunkdiffs) {
for (auto& [key, conn] : m_conns)
sendPackTo<ChunkMod>(m_sock_udp, chmo, &m_buf, conn->getAddr());
delete chmo;
}
chunkdiffs.clear();
if (!chunkdiffs.empty())
chunkdiffs.clear();
}
Chat end;
@ -367,8 +419,7 @@ void Server::Run() {
for (auto& [key, conn] : m_conns) {
std::string str = conn->player->GetUsername();
Log(str.append(" ").append(std::to_string(conn->player->GetHP())), false, false);
Log(str.append(" ").append(std::to_string(conn->player->getScore())), false, false);
}
for (auto& [key, conn] : m_conns)

View File

@ -91,7 +91,7 @@
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>ClangCL</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@ -196,7 +196,7 @@
<FloatingPointModel>Fast</FloatingPointModel>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>

View File

@ -2,26 +2,40 @@
Audio::Audio() {
m_engine = irrklang::createIrrKlangDevice();
m_engine->setDopplerEffectParameters(10);
m_engine->setRolloffFactor(2);
m_engine->setDefault3DSoundMinDistance(.1);
m_engine->setDopplerEffectParameters(1);
m_engine->setRolloffFactor(1);
m_engine->setDefault3DSoundMinDistance(1);
m_engine->setDefault3DSoundMaxDistance(1000);
}
Audio::Audio(const char * music) {
Audio::Audio(const char * music, const char* menumusic) {
m_engine = irrklang::createIrrKlangDevice();
m_engine->setDopplerEffectParameters(1);
m_engine->setRolloffFactor(2);
m_engine->setDefault3DSoundMinDistance(.1);
m_engine->setDefault3DSoundMaxDistance(1000);
m_engine->setRolloffFactor(1);
m_engine->setDefault3DSoundMinDistance(1);
m_engine->setDefault3DSoundMaxDistance(100);
m_music = m_engine->play2D(music, true, true, true, irrklang::ESM_STREAMING);
m_menumusic = m_engine->play2D(menumusic, true, true, true, irrklang::ESM_STREAMING);
m_music->setVolume(.5);
m_menumusic->setVolume(.5);
m_mainvolume = 0.5f;
m_engine->setSoundVolume(m_mainvolume);
m_sfxvolume = 0.5f;
}
Audio::~Audio() {
if (m_music) m_music->drop();
if (m_menumusic) m_menumusic->drop();
if (m_engine) m_engine->drop();
}
void Audio::playSound(const char* name, float volume = 1.) {
irrklang::ISound* sfx = m_engine->play2D(name, false, true);
sfx->setVolume(volume);
sfx->setIsPaused(false);
m_sfxes.push_back(sfx);
}
void Audio::Update3DAudio(Vector3f pos, Vector3f dir, Vector3f vel) {
m_engine->setListenerPosition(irrklang::vec3df(pos.x, pos.y, pos.z),
irrklang::vec3df(dir.x, dir.y, dir.z),
@ -29,9 +43,10 @@ void Audio::Update3DAudio(Vector3f pos, Vector3f dir, Vector3f vel) {
}
irrklang::ISound* Audio::Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, bool is_looped = false, float volume = 1) {
sound = m_engine->play3D(name, irrklang::vec3df(pos.x, pos.y, pos.z), is_looped, false, true, is_looped? irrklang::ESM_STREAMING: irrklang::ESM_NO_STREAMING, true);
sound = m_engine->play3D(name, irrklang::vec3df(pos.x, pos.y, pos.z), is_looped, true, true, is_looped? irrklang::ESM_STREAMING: irrklang::ESM_NO_STREAMING, true);
sound->setVelocity(irrklang::vec3df(vel.x, vel.y, vel.z));
sound->setVolume(volume);
sound->setIsPaused(false);
return sound;
}
@ -45,10 +60,76 @@ void Audio::Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& v
// m_music = m_engine->play2D(music, false, false, false, irrklang::ESM_STREAMING);
//}
void Audio::ToggleMusicState() { m_music->setIsPaused(!m_music->getIsPaused()); }
void Audio::CleanupSFX() {
while (!m_sfxes.empty()) {
irrklang::ISound* sfx = m_sfxes.back();
if (sfx->isFinished()) {
sfx->drop(); // drop() fait deja la job du delete sfx.
}
else break;
m_sfxes.pop_back();
}
}
void Audio::ToggleMusicState(GameState state) {
if (m_music_on) {
switch (state) {
case PLAY:
m_music->setIsPaused(false);
m_menumusic->setIsPaused(true);
break;
case PAUSE:
m_music->setIsPaused(true);
m_menumusic->setIsPaused(true);
break;
default:
m_music->setIsPaused(true);
m_menumusic->setIsPaused(false);
break;
}
}
else {
m_music->setIsPaused(true);
m_menumusic->setIsPaused(true);
}
}
void Audio::SetMusic(bool ison, GameState state) {
m_music_on = state;
if (!state) {
m_music->setIsPaused(true);
m_menumusic->setIsPaused(true);
}
else ToggleMusicState(state);
}
bool Audio::GetMusic() {
return m_music_on;
}
void Audio::PauseEngine() { m_engine->setAllSoundsPaused(); }
float Audio::GetMusicVolume() const {
return m_music->getVolume();
}
void Audio::SetMusicVolume(float volume) {
m_music->setVolume(volume);
m_menumusic->setVolume(volume);
}
float Audio::GetMainVolume() const {
return m_engine->getSoundVolume();
}
void Audio::SetMainVolume(float volume) {
m_engine->setSoundVolume(volume);
}
float Audio::GetSfxVolume() const {
return m_sfxvolume;
}
void Audio::SetSfxVolume(float volume) {
m_sfxvolume = volume;
}

View File

@ -15,26 +15,46 @@
class Audio {
private:
irrklang::ISound* m_music;
irrklang::ISound* m_menumusic;
float m_mainvolume;
float m_sfxvolume;
bool m_music_on = true;
std::vector<irrklang::ISound*> m_sfxes;
public:
Audio();
Audio(const char* music);
Audio(const char* music, const char* menumusic);
~Audio();
irrklang::ISoundEngine* m_engine;
void Update3DAudio(Vector3f pos, Vector3f dir, Vector3f speed);
irrklang::ISound* Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, bool is_looped, float volume);
void Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& vel, float volume);
//void PlaySong(const char* music);
void ToggleMusicState();
void CleanupSFX();
void ToggleMusicState(GameState state);
void playSound(const char* sound, float volume);
void SetMusic(bool ison, GameState state);
bool GetMusic();
void PauseEngine();
float GetMainVolume() const;
void SetMainVolume(float volume);
float GetMusicVolume() const;
void SetMusicVolume(float volume);
float GetSfxVolume() const;
void SetSfxVolume(float volume);
};
#endif // AUDIO_H__

View File

@ -25,8 +25,8 @@
#define BULLET_UPDATES_PER_FRAME 20
#define BASE_WIDTH 640
#define BASE_HEIGHT 480
#define BASE_WIDTH 1280
#define BASE_HEIGHT 720
#define ANIME_PATH_JUMP "./media/textures/AssetOtherPlayer/FinalPNGJumping/"
@ -50,7 +50,6 @@ enum GameState {
SPLASH,
LOBBY,
OPTIONS,
QUIT,
PLAY,
PAUSE
};
@ -59,7 +58,7 @@ enum Resolution {
HD = 0, // 1280x720 (High Definition)
FHD, // 1920x1080 (Full HD)
QHD, // 2560x1440 (Quad HD)
UHD // 3840x2160 (Ultra HD)
UHD, // 3840x2160 (Ultra HD)
};
#endif // DEFINE_H__

View File

@ -1 +0,0 @@

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -49,6 +49,7 @@ private:
bool StartMultiplayerGame();
bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true);
void ChangeResolution(Resolution resolution);
void InstantDamage();
void SystemNotification(std::string systemLog);
@ -73,6 +74,8 @@ private:
void SetPlayerUsername(float elapsedTime);
void SetServerAddress(float elapsedTime);
void DisplayPauseMenu(float elapsedTime);
void DisplayOptionsMenu();
void DisplayAudioMenu(float centerX, float centerY);
void DisplayGraphicsMenu(float centerX, float centerY);
@ -86,8 +89,7 @@ private:
char SimulateKeyboard(unsigned char key);
void HandlePlayerInput(float elapsedTime);
//udio m_menuaudio = Audio(AUDIO_PATH "menumusic.wav");
Audio m_audio = Audio(AUDIO_PATH "music01.wav");
Audio m_audio = Audio(AUDIO_PATH "music01.wav", AUDIO_PATH "menumusic01.wav");
irrklang::ISound* m_powpow, * m_scream;
irrklang::ISound* m_whoosh[MAX_BULLETS];
@ -138,6 +140,9 @@ private:
Texture m_textureCheck;
Texture m_textureChecked;
Texture m_texturePauseResume;
Texture m_texturePauseMainMenu;
Texture m_textureOptAudio;
Texture m_textureOptBack;
Texture m_textureOptGameplay;
@ -172,10 +177,10 @@ private:
int m_nbReductionChunk = 4;
int m_timerReductionChunk = 30;
float m_volPrincipal = 0.0f;
float m_volMusique = 0.0f;
float m_volEffets = 0.0f;
float m_volSensible = 0.0f;
float m_mainvolume;
float m_musicvolume;
float m_sfxvolume;
float m_sensitivity;
int m_selectedOption = 0;
@ -204,13 +209,18 @@ private:
std::string m_currentInputString;
std::string m_username;
std::string m_serverAddr;
char m_inputChar = 0;
bool m_invalidChar = false;
bool m_charChanged = false;
bool m_settingUsername = false;
bool m_settingServer = false;
bool m_selectedSinglePlayer = false;
bool m_selectedMultiPlayer = false;
bool m_singleReady = false;
bool m_multiReady = false;
bool m_key1 = false;
bool m_key2 = false;
bool m_keyK = false;
@ -239,6 +249,7 @@ private:
std::deque<netprot::ChunkMod*> m_chunkmod_manifest;
std::chrono::high_resolution_clock::time_point m_startTime;
std::unordered_map<uint64_t, Player*> m_players;
std::set<uint64_t> m_deadplayers;
netprot::Buffer m_buf, m_bufout;
netprot::ChunkMod* m_chunkmod = nullptr;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 562 KiB

After

Width:  |  Height:  |  Size: 596 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@ -53,9 +53,9 @@ protected:
void ShowCrossCursor() const;
bool m_istarted = false;
void InitWindow(int width, int height);
private:
void InitWindow(int width, int height);
MOUSE_BUTTON ConvertMouseButton(sf::Mouse::Button button) const;
private:

View File

@ -8,11 +8,11 @@
RemotePlayer::RemotePlayer(netprot::PlayerInfo pinfo) : m_pinfo(pinfo), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), previous(), m_texture_front(), Player(Vector3f(0, 0, 0)){
RemotePlayer::RemotePlayer(netprot::PlayerInfo* pinfo) : m_pinfo(*pinfo), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), previous(), m_texture_front(), Player(Vector3f(0, 0, 0)) {
}
RemotePlayer::RemotePlayer(netprot::PlayerInfo pinfo, const Vector3f& pos) : m_pinfo(pinfo), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), previous(), m_texture_front(), Player(pos) {
RemotePlayer::RemotePlayer(netprot::PlayerInfo* pinfo, const Vector3f& pos) : m_pinfo(*pinfo), m_aminacc(0.0f), m_animstate(Anim::STILL), m_team_id(0), current(), previous(), m_texture_front(), Player(pos) {
}
@ -31,54 +31,9 @@ void RemotePlayer::Feed(const netprot::Output out) {
m_position = Vector3f(out.position);
m_direction = Vector3f(out.direction);
current.states = out.states;
//current.position = out.position;
//current.direction = out.direction;
//current.states = out.states;
//current.id = out.id;
//if (current.position != previous.position)
//{
// Vector3f positionDelta = current.position - previous.position;
// m_position = current.position + positionDelta;
// m_direction = current.direction;
//}
//if(current.direction != previous.direction)
//{
// m_direction = current.direction;
// current.direction = current.direction;
//}
//if (current.states.shooting) {
// m_animstate = Anim::SHOOTING;
//}
//else if (current.states.jumping) {
// m_animstate = Anim::JUMPING;
//}
//else if (current.states.dead) {
// m_animstate = Anim::DEAD;
//}
//else if(current.states.powerup){
// m_animstate = Anim::POWERUP;
//}
//else if (current.states.still) {
// m_animstate = Anim::STILL;
//}
//else if (current.states.running) {
// m_animstate = Anim::RUNNING;
//}
//previous.direction = current.direction;
//previous.position = current.position;
//previous.states = current.states;
//previous.id = current.id;
//m_direction = current.direction;
//m_position = current.position;
}
@ -118,26 +73,25 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
int index = 0;
angle = -angle;
Vector3f side = angleRemote.Cross(angleCam);
side = -side;
static float time = 0.f;
static bool Shooting = false;
bool isLeft = side.y > 0;
time += elapsedTime;
if (time >= 200)
if (time >= 0.05)
{
time -= 200;
if (!current.states.shooting)
Shooting = false;
else
Shooting = !Shooting;
time -= 0.05;
Shooting = !Shooting;
}
//std::cout << "shooting : " << current.states.shooting << " jumping : " << current.states.jumping << " jumpshot : " << current.states.jumpshot << " running : " << current.states.running << " still : " << current.states.still << " dead : " << current.states.dead << " hit : " << current.states.hit << std::endl;
if (angle >= 0.75) //Face - side positif
{
if(current.states.shooting){
if (current.states.shooting) {
if (Shooting)
index = 17;
else
@ -151,7 +105,7 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
}
else if (current.states.jumping)
index = 25;
else if (current.states.running && current.states.still)
else if (!current.states.jumping && !current.states.shooting && !current.states.jumpshot)
index = 0;
}
@ -162,6 +116,7 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
index = 18;
else
index = 10;
}
else if (current.states.jumpshot) {
if (Shooting)
@ -169,11 +124,12 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
else
index = 34;
}
else if (current.states.jumping )
else if (current.states.jumping)
index = 26;
else if (current.states.running && current.states.still)
else if (!current.states.jumping && !current.states.shooting && !current.states.jumpshot)
index = 1;
}
else if (angle >= -0.25 && isLeft) //ProfileLeft
{
@ -182,18 +138,20 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
index = 20;
else
index = 12;
}
else if (current.states.jumpshot ) {
else if (current.states.jumpshot) {
if (Shooting)
index = 44;
else
index = 36;
}
else if (current.states.jumping )
else if (current.states.jumping)
index = 28;
else if (current.states.running && current.states.still)
else if (!current.states.jumping && !current.states.shooting && !current.states.jumpshot)
index = 3;
}
else if (angle >= -0.75 && isLeft) //BackLeft
{
@ -202,6 +160,7 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
index = 22;
else
index = 14;
}
else if (current.states.jumpshot) {
if (Shooting)
@ -211,8 +170,10 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
}
else if (current.states.jumping)
index = 30;
else if (current.states.running && current.states.still)
else if (!current.states.jumping && !current.states.shooting && !current.states.jumpshot)
index = 5;
}
else if (angle < -0.75) //Dos - side négatif
{
@ -221,6 +182,7 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
index = 24;
else
index = 16;
}
else if (current.states.jumpshot) {
if (Shooting)
@ -228,13 +190,14 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
else
index = 40;
}
else if (current.states.jumping )
else if (current.states.jumping)
index = 32;
else if (current.states.running && current.states.still)
else if (!current.states.jumping && !current.states.shooting && !current.states.jumpshot)
index = 7;
}
else if (angle >= 0.25 && !isLeft) //FrontRight
else if (angle >= 0.25 && !isLeft) //FrontRight //REVOIR L'ANIME DE SHOOTING EST PAS DRETTE
{
if (current.states.shooting) {
if (Shooting)
@ -250,9 +213,10 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
}
else if (current.states.jumping)
index = 27;
else if (current.states.running && current.states.still)
else if (!current.states.jumping && !current.states.shooting && !current.states.jumpshot)
index = 2;
}
else if (angle >= -0.25 && !isLeft) //ProfileRight
{
@ -270,9 +234,10 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
}
else if (current.states.jumping)
index = 29;
else if (current.states.running && current.states.still)
else if (!current.states.jumping && !current.states.shooting && !current.states.jumpshot)
index = 4;
}
else if (angle >= -0.75 && !isLeft) //BackRight
{
@ -281,6 +246,7 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
index = 23;
else
index = 15;
}
else if (current.states.jumpshot) {
if (Shooting)
@ -290,9 +256,10 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
}
else if (current.states.jumping)
index = 31;
else if (current.states.running && current.states.still)
else if (!current.states.jumping && !current.states.shooting && !current.states.jumpshot)
index = 6;
}
@ -304,10 +271,25 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
atlas.TextureIndexToCoord(index, u, v, w, h);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (current.states.hit)
{
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR);
glBlendColor(1.f, 0.f, 0.f, 1.f);
}
else {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
glBlendEquation(GL_FUNC_ADD);
glLoadMatrixf(tran.GetMatrix().GetInternalValues());
glDepthFunc(GL_LEQUAL);
glBegin(GL_QUADS);
glTexCoord2f(u, v); glVertex3f(v1.x, v1.y, v1.z);
glTexCoord2f(u + w, v); glVertex3f(v2.x, v2.y, v2.z);

View File

@ -14,8 +14,8 @@ class RemotePlayer : public Player {
public:
enum Anim: uint8_t { STILL = 1, RUNNING = 2, JUMPING = 4, SHOOTING = 8, POWERUP = 16, DEAD = 32 }; // A REVOIR VOIR DEFINE.H POUR LES ANIMES
RemotePlayer(netprot::PlayerInfo pinfo);
RemotePlayer(netprot::PlayerInfo pinfo, const Vector3f& pos);
RemotePlayer(netprot::PlayerInfo* pinfo);
RemotePlayer(netprot::PlayerInfo* pinfo, const Vector3f& pos);
~RemotePlayer();

View File

@ -9,7 +9,7 @@ Settings::Settings(Audio& audio)
m_fullscreen(false),
m_brightness(0.5f),
m_contrast(0.5f),
m_mouseSensitivity(0.5f) {
m_mouseSensitivity(0.0f) {
ApplyResolution(m_resolution);
}

BIN
docs/Plan_de_test.pdf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.