Compare commits
96 Commits
SQC-15_ani
...
Améloratio
Author | SHA1 | Date | |
---|---|---|---|
|
2c73a2ed00 | ||
|
d444b4de30 | ||
|
bb100fd5cb | ||
|
a137666546 | ||
|
841947bc7a | ||
|
bc5c28a373 | ||
|
754130ec39 | ||
|
8569e17c93 | ||
|
c5700ae9fd | ||
|
78b3ed85cb | ||
|
4b6c641c97 | ||
|
9ed8ef3273 | ||
|
8b448f5072 | ||
|
a67499049b | ||
|
0af76b3f2e | ||
|
b2c73c930e | ||
|
4aa0aedd61 | ||
|
e52dbd3705 | ||
|
5a491c5446 | ||
|
20eb410b08 | ||
|
c44d1453ae | ||
|
37ea09aaf3 | ||
|
62b7719eb4 | ||
|
3842ca3485 | ||
|
98390c878f | ||
|
def1ab284e | ||
|
90e736a14c | ||
|
ac3628ec0b | ||
|
3e3a7650e8 | ||
|
28082a018d | ||
|
681ac61a74 | ||
|
38cfa95297 | ||
|
34ad4724f2 | ||
|
12ef911e79 | ||
|
5c346c48e6 | ||
|
e89b5914fb | ||
|
15882dc506 | ||
|
6db90a3a16 | ||
|
b23b2c6838 | ||
|
a26929fe66 | ||
|
e3b59e37eb | ||
|
10b8d77734 | ||
|
e8ca08ecab | ||
|
4a9ad70d48 | ||
|
e330f5dd67 | ||
|
2f5579875e | ||
|
114c1631a8 | ||
|
cfc7f7e01d | ||
|
0b5c30b693 | ||
|
f9c3571ab2 | ||
|
2a7fe7e806 | ||
|
8ea5af6ef9 | ||
|
841b0176f6 | ||
|
702a65c5b0 | ||
|
b6d5975648 | ||
|
6e556b4f84 | ||
|
e6b3f2fb1c | ||
|
5e57a13820 | ||
|
9a7d25c1d9 | ||
|
c24123362a | ||
|
6c0d65ea22 | ||
|
9bb8b1c9e5 | ||
|
35a5ddd9bd | ||
|
85ab712032 | ||
|
0f1a864282 | ||
|
0200f77be8 | ||
|
935216e9c3 | ||
|
1ab83a85a7 | ||
|
2ab201e93c | ||
|
ea3d2ffc34 | ||
|
775c8cf26f | ||
|
0c1714dd14 | ||
|
981d66c730 | ||
|
bd3f677118 | ||
|
35c55f2e26 | ||
|
9bf5188e0f | ||
|
e8d456cc09 | ||
|
3043b1ff6b | ||
|
7ccecdfd4a | ||
|
6f13e8fb70 | ||
|
d1c3d17055 | ||
|
573316682b | ||
|
bd14cd3962 | ||
|
480521ebaf | ||
|
312542857a | ||
|
c1aa321f2b | ||
|
d7bd36d134 | ||
|
ce2d03c354 | ||
|
83e438583f | ||
|
75a32270b5 | ||
|
732f74de91 | ||
|
8e041a314d | ||
|
6bb3ee9667 | ||
|
f654c5effa | ||
|
3ca941f0ce | ||
|
4c695fbe47 |
@@ -1,54 +1,86 @@
|
|||||||
#include "chunk.h"
|
#include "chunk.h"
|
||||||
#include "world.h"
|
#include "world.h"
|
||||||
|
#include <random>
|
||||||
|
|
||||||
|
|
||||||
Chunk::Chunk(unsigned int x, unsigned int y, int64_t seed) : m_posX(x), m_posY(y) {
|
Chunk::Chunk(unsigned int x, unsigned int y, int64_t seed) : m_posX(x), m_posY(y) {
|
||||||
//std::ostringstream pos; // V<>rifie l'existence d'un fichier .chunk avec sa position.
|
//std::ostringstream pos; // V<>rifie l'existence d'un fichier .chunk avec sa position.
|
||||||
//pos << CHUNK_PATH << x << '_' << y << ".chunk";
|
//pos << CHUNK_PATH << x << '_' << y << ".chunk";
|
||||||
//std::ifstream input(pos.str(), std::fstream::binary);
|
//std::ifstream input(pos.str(), std::fstream::binary);
|
||||||
|
|
||||||
//if (input.fail()) {
|
//if (input.fail()) {
|
||||||
OpenSimplexNoise::Noise simplex = OpenSimplexNoise::Noise(seed);
|
OpenSimplexNoise::Noise simplex = OpenSimplexNoise::Noise(seed);
|
||||||
|
int ratio = 0;
|
||||||
|
|
||||||
|
ratio = x * y % 7;
|
||||||
m_blocks.Reset(BTYPE_AIR);
|
m_blocks.Reset(BTYPE_AIR);
|
||||||
|
|
||||||
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // Montagnes
|
#pragma region Montagnes et Grass des montagnes
|
||||||
|
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix)
|
||||||
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
||||||
float xnoiz, ynoiz;
|
float xnoiz, ynoiz;
|
||||||
xnoiz = (double)(ix + x * CHUNK_SIZE_X) / 4096.;
|
xnoiz = (double)(ix + x * CHUNK_SIZE_X) / 4796.;
|
||||||
ynoiz = (double)(iz + y * CHUNK_SIZE_Z) / 4096.;
|
ynoiz = (double)(iz + y * CHUNK_SIZE_Z) / 4796.;
|
||||||
double height = 0;
|
double height = 0;
|
||||||
for (int x = 0; x < 39; ++x) {
|
for (int x = 0; x < 39; ++x) {
|
||||||
height += simplex.eval(xnoiz, ynoiz);
|
height += simplex.eval(xnoiz, ynoiz);
|
||||||
height *= .79;
|
height *= .79;
|
||||||
xnoiz *= 1.139;
|
xnoiz *= 1.1305;
|
||||||
ynoiz *= 1.139;
|
ynoiz *= 1.1305;
|
||||||
}
|
}
|
||||||
height = height * 2000. * simplex.eval((double)(ix + x * CHUNK_SIZE_X) / 512., (double)(iz + y * CHUNK_SIZE_Z) / 512.);
|
height = height * 2000. * simplex.eval((double)(ix + x * CHUNK_SIZE_X) / 512., (double)(iz + y * CHUNK_SIZE_Z) / 512.);
|
||||||
height /= (CHUNK_SIZE_Y / 1.9);
|
height /= (CHUNK_SIZE_Y / 1.9);
|
||||||
height += 15.;
|
height += 15.;
|
||||||
for (int iy = 0; iy <= (int)height % CHUNK_SIZE_Y; ++iy)
|
|
||||||
SetBlock(ix, iy, iz, BTYPE_METAL, nullptr);
|
|
||||||
}
|
|
||||||
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // Collines
|
|
||||||
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
|
||||||
float xnoiz, ynoiz;
|
|
||||||
xnoiz = (double)(ix + x * CHUNK_SIZE_X) / 512.;
|
|
||||||
ynoiz = (double)(iz + y * CHUNK_SIZE_Z) / 512.;
|
|
||||||
float height = simplex.eval(xnoiz, ynoiz) * 50.f;// +1.f;
|
|
||||||
for (int iy = 0; iy <= (int)height % CHUNK_SIZE_Y; ++iy) {
|
for (int iy = 0; iy <= (int)height % CHUNK_SIZE_Y; ++iy) {
|
||||||
if (GetBlock(ix, iy, iz) == BTYPE_AIR)
|
if (iy < 20)
|
||||||
SetBlock(ix, iy, iz, BTYPE_GREENGRASS, nullptr);
|
{
|
||||||
|
//std::cout << "" << ynoiz << std::endl;
|
||||||
|
SetBlock(ix, iy, iz, BTYPE_GRASS, nullptr);
|
||||||
|
}
|
||||||
|
else if (iy == 20 || iy == 21) {
|
||||||
|
double fractionalPart = ynoiz - static_cast<int>(ynoiz);
|
||||||
|
|
||||||
|
if (iy == 20) {
|
||||||
|
if (fractionalPart < 0.3) {
|
||||||
|
SetBlock(ix, iy, iz, BTYPE_GRASS, nullptr);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SetBlock(ix, iy, iz, BTYPE_METAL, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (iy == 21) {
|
||||||
|
if (fractionalPart < 0.6) {
|
||||||
|
SetBlock(ix, iy, iz, BTYPE_GRASS, nullptr);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SetBlock(ix, iy, iz, BTYPE_METAL, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetBlock(ix, iy, iz, BTYPE_METAL, nullptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // "Lacs"
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Lacs
|
||||||
|
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix)
|
||||||
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
||||||
for (int iy = 0; iy < 13; ++iy) {
|
for (int iy = 0; iy < 13; ++iy) {
|
||||||
if (GetBlock(ix, iy, iz) == BTYPE_AIR)
|
if (iy < 5 && GetBlock(ix, iy, iz) == BTYPE_AIR) {
|
||||||
SetBlock(ix, iy, iz, BTYPE_ICE, nullptr);
|
SetBlock(ix, iy, iz, BTYPE_ICE, nullptr);
|
||||||
|
}
|
||||||
|
else if (iy >= 5 && GetBlock(ix, iy, iz) == BTYPE_AIR) {
|
||||||
|
SetBlock(ix, iy, iz, BTYPE_ICE, nullptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
int rnd = rand() % 15;
|
//int rnd = rand() % 15;
|
||||||
if (rnd == 4)
|
if (ratio == 1)
|
||||||
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // structure
|
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // structure
|
||||||
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
||||||
for (int iy = 0; iy < 14; ++iy) {
|
for (int iy = 0; iy < 14; ++iy) {
|
||||||
@@ -57,16 +89,16 @@ Chunk::Chunk(unsigned int x, unsigned int y, int64_t seed) : m_posX(x), m_posY(y
|
|||||||
Structure(ix, iy, iz, 2);
|
Structure(ix, iy, iz, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rnd == 3)
|
if (ratio == 3)
|
||||||
for (int ix = 0; ix < CHUNK_SIZE_Z; ++ix) // structure
|
for (int ix = 0; ix < CHUNK_SIZE_Z; ++ix) // structure
|
||||||
for (int iz = 0; iz < CHUNK_SIZE_X; ++iz) {
|
for (int iz = 0; iz < CHUNK_SIZE_X; ++iz) {
|
||||||
for (int iy = 0; iy < 14; ++iy) {
|
for (int iy = 0; iy < 14; ++iy) {
|
||||||
if (iz == 4)
|
if (iz == 4)
|
||||||
if (GetBlock(ix, iy, iz) == BTYPE_AIR)
|
if (GetBlock(ix, iy, iz) == BTYPE_AIR)
|
||||||
Structure(ix, iy, iz, 2);
|
Structure(ix, iy, iz, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rnd == 6)
|
if (ratio == 5)
|
||||||
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // structure
|
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // structure
|
||||||
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
||||||
for (int iy = 0; iy < 14; ++iy) {
|
for (int iy = 0; iy < 14; ++iy) {
|
||||||
@@ -77,38 +109,146 @@ Chunk::Chunk(unsigned int x, unsigned int y, int64_t seed) : m_posX(x), m_posY(y
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // "Arbres"
|
|
||||||
// for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
|
||||||
// float xnoiz, ynoiz;
|
|
||||||
// xnoiz = (double)(iz * CHUNK_SIZE_Y + x * CHUNK_SIZE_X) / 256.;
|
|
||||||
// ynoiz = (double)(ix * CHUNK_SIZE_Y + y * CHUNK_SIZE_Z) / 256.;
|
|
||||||
// bool tree = (int)(abs(simplex.eval(xnoiz, ynoiz)) * 17933.f) % CHUNK_SIZE_Y > 126 ? true : false;
|
|
||||||
// for (int iy = 0; iy < CHUNK_SIZE_Y - 10; ++iy)
|
|
||||||
// if (GetBlock(ix, iy, iz) == BTYPE_AIR)
|
|
||||||
// if (GetBlock(ix, iy - 1, iz) == BTYPE_GRASS)
|
|
||||||
// if (tree) {
|
|
||||||
// for (int i = 0; i < (int)(abs(simplex.eval(xnoiz, ynoiz) * 4)) % 42 + 1; ++i)
|
|
||||||
// SetBlock(ix, iy + i, iz, BTYPE_DIRT, nullptr);
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
/* }
|
|
||||||
else {
|
|
||||||
input.seekg(0, std::ios_base::end);
|
|
||||||
int size = input.tellg();
|
|
||||||
input.seekg(0, std::ios_base::beg);
|
|
||||||
|
|
||||||
char data[CHUNK_SIZE_X * CHUNK_SIZE_Y * CHUNK_SIZE_Z];
|
|
||||||
input.read(data, size);
|
|
||||||
input.close();
|
|
||||||
|
|
||||||
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix)
|
|
||||||
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz)
|
#pragma region Arbre
|
||||||
for (int iy = 0; iy < CHUNK_SIZE_Y; ++iy)
|
double valeurRnd = 0;
|
||||||
m_blocks.Set(ix, iy, iz, data[ix + (iz * CHUNK_SIZE_X) + (iy * CHUNK_SIZE_Z * CHUNK_SIZE_X)]);
|
int treeheight = 10;
|
||||||
}*/
|
int lastTreeX = -1;
|
||||||
|
int lastTreeZ = -1;
|
||||||
|
|
||||||
|
int minDistanceBetweenTrees = 10; // Définir la distance minimale entre les arbres
|
||||||
|
|
||||||
|
|
||||||
|
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) {
|
||||||
|
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
||||||
|
if (GetBlock(ix, 0, iz) != BTYPE_ICE) {
|
||||||
|
float xnoiz = (double)(ix + x * CHUNK_SIZE_X) / 4796.;
|
||||||
|
float ynoiz = (double)(iz + y * CHUNK_SIZE_Z) / 4796.;
|
||||||
|
double height = 0;
|
||||||
|
for (int i = 0; i < 39; ++i) {
|
||||||
|
height += simplex.eval(xnoiz, ynoiz);
|
||||||
|
height *= .79;
|
||||||
|
xnoiz *= 1.1305;
|
||||||
|
ynoiz *= 1.1305;
|
||||||
|
}
|
||||||
|
height = height * 2000. * simplex.eval((double)(ix + x * CHUNK_SIZE_X) / 512., (double)(iz + y * CHUNK_SIZE_Z) / 512.);
|
||||||
|
height /= (CHUNK_SIZE_Y / 1.9);
|
||||||
|
height += 15.;
|
||||||
|
if (GetBlock(ix, (int)height, iz) == BTYPE_GRASS || (GetBlock(ix, (int)height, iz) == BTYPE_METAL)) {
|
||||||
|
valeurRnd = simplex.eval(xnoiz, ynoiz);
|
||||||
|
int distanceThreshold = 20;
|
||||||
|
// Vérifie si l'emplacement n'est pas à l'intérieur des lacs
|
||||||
|
bool isInsideLake = false;
|
||||||
|
for (int iy = 0; iy < 13; ++iy) {
|
||||||
|
if (GetBlock(ix, iy, iz) == BTYPE_ICE) {
|
||||||
|
isInsideLake = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isInsideLake && ((valeurRnd > -0.4 && valeurRnd < -0.38) || (valeurRnd > -0.35 && valeurRnd < -0.31)
|
||||||
|
|| (valeurRnd > 0.3 && valeurRnd < 0.32) || (valeurRnd > 0.37 && valeurRnd < 0.39))
|
||||||
|
) {
|
||||||
|
if (lastTreeX == -1 || abs(ix - lastTreeX) > minDistanceBetweenTrees || abs(iz - lastTreeZ) > minDistanceBetweenTrees) {
|
||||||
|
if (valeurRnd < 0.1)
|
||||||
|
treeheight = 10;
|
||||||
|
else {
|
||||||
|
treeheight = valeurRnd * 20;
|
||||||
|
if (treeheight < 5)
|
||||||
|
treeheight = 5;
|
||||||
|
}
|
||||||
|
PlaceTree(ix, height, iz, treeheight);
|
||||||
|
lastTreeX = ix;
|
||||||
|
lastTreeZ = iz;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//else {
|
||||||
|
// input.seekg(0, std::ios_base::end);
|
||||||
|
// int size = input.tellg();
|
||||||
|
// input.seekg(0, std::ios_base::beg);
|
||||||
|
|
||||||
|
// char data[CHUNK_SIZE_X * CHUNK_SIZE_Y * CHUNK_SIZE_Z];
|
||||||
|
// input.read(data, size);
|
||||||
|
// input.close();
|
||||||
|
|
||||||
|
// for (int ix = 0; ix < CHUNK_SIZE_X; ++ix)
|
||||||
|
// for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz)
|
||||||
|
// for (int iy = 0; iy < CHUNK_SIZE_Y; ++iy)
|
||||||
|
// m_blocks.Set(ix, iy, iz, data[ix + (iz * CHUNK_SIZE_X) + (iy * CHUNK_SIZE_Z * CHUNK_SIZE_X)]);
|
||||||
|
//}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // Collines
|
||||||
|
// for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
||||||
|
// float xnoiz, ynoiz;
|
||||||
|
// xnoiz = (double)(ix + x * CHUNK_SIZE_X) / 512.;
|
||||||
|
// ynoiz = (double)(iz + y * CHUNK_SIZE_Z) / 512.;
|
||||||
|
// float height = simplex.eval(xnoiz, ynoiz) * 50.f;// +1.f;
|
||||||
|
// for (int iy = 0; iy <= (int)height % CHUNK_SIZE_Y; ++iy) {
|
||||||
|
// if (iy < 10 && GetBlock(ix, iy, iz) == BTYPE_AIR) {
|
||||||
|
// SetBlock(ix, iy, iz, BTYPE_METAL, nullptr); // Collines
|
||||||
|
// }
|
||||||
|
// else if (iy >= 10 && GetBlock(ix, iy, iz) == BTYPE_AIR) {
|
||||||
|
// SetBlock(ix, iy, iz, BTYPE_GRASS, nullptr); // Grass des collines
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Chunk::PlaceTree(int x, int y, int z, int height) {
|
||||||
|
// Vérifie si les coordonnées x, y, z sont dans les limites du chunk
|
||||||
|
if (x < 0 || x >= CHUNK_SIZE_X || y < 0 || y >= CHUNK_SIZE_Y || z < 0 || z >= CHUNK_SIZE_Z) {
|
||||||
|
// Coordonnées hors limites du chunk, sortie anticipée pour éviter tout accès non valide
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Place la tige de l'arbre
|
||||||
|
for (int iy = 0; iy < height + 1; ++iy) {
|
||||||
|
if (y + iy < CHUNK_SIZE_Y) { // Vérifie si la hauteur est à l'intérieur des limites du chunk
|
||||||
|
SetBlock(x, y + iy, z, BTYPE_DIRT, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Place les feuilles de l'arbre
|
||||||
|
int foliageHeight = height / 2;
|
||||||
|
for (int dy = 0; dy < foliageHeight; ++dy) {
|
||||||
|
for (int dx = -4; dx <= 4; ++dx) {
|
||||||
|
for (int dz = -4; dz <= 4; ++dz) {
|
||||||
|
// Vérifie que les coordonnées se trouvent à l'intérieur des limites du chunk
|
||||||
|
if (x + dx >= 0 && x + dx < CHUNK_SIZE_X && y + height + dy >= 0 && y + height + dy < CHUNK_SIZE_Y &&
|
||||||
|
z + dz >= 0 && z + dz < CHUNK_SIZE_Z) {
|
||||||
|
// Vérifie si le bloc est à une distance acceptable du centre des feuilles pour les placer
|
||||||
|
double distanceSquared = dx * dx + dy * dy + dz * dz;
|
||||||
|
if (distanceSquared < 20) {
|
||||||
|
SetBlock(x + dx, y + height + dy, z + dz, BTYPE_GREENGRASS, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Chunk::~Chunk() {
|
Chunk::~Chunk() {
|
||||||
/*if (m_isModified) {
|
/*if (m_isModified) {
|
||||||
char data[CHUNK_SIZE_X * CHUNK_SIZE_Y * CHUNK_SIZE_Z];
|
char data[CHUNK_SIZE_X * CHUNK_SIZE_Y * CHUNK_SIZE_Z];
|
||||||
@@ -135,7 +275,7 @@ void Chunk::RemoveBlock(int x, int y, int z, World* world) {
|
|||||||
|
|
||||||
void Chunk::SetBlock(int x, int y, int z, BlockType type, World* world) {
|
void Chunk::SetBlock(int x, int y, int z, BlockType type, World* world) {
|
||||||
m_blocks.Set(x, y, z, type);
|
m_blocks.Set(x, y, z, type);
|
||||||
if (world) CheckNeighbors(x, z, world); // Si nullptr, ne pas v<>rifier les chunks voisines.
|
if (world) CheckNeighbors(x, z, world); // Si nullptr, ne pas v<>rifier les chunks voisines.
|
||||||
m_isDirty = true;
|
m_isDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,6 +303,10 @@ void Chunk::CheckNeighbors(unsigned int x, unsigned int z, World* world) {
|
|||||||
|
|
||||||
void Chunk::GetPosition(unsigned int& x, unsigned int& y) const { x = m_posX; y = m_posY; }
|
void Chunk::GetPosition(unsigned int& x, unsigned int& y) const { x = m_posX; y = m_posY; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Chunk::IsDirty() const { return m_isDirty; }
|
bool Chunk::IsDirty() const { return m_isDirty; }
|
||||||
|
|
||||||
void Chunk::MakeDirty() { m_isDirty = true; }
|
void Chunk::MakeDirty() { m_isDirty = true; }
|
||||||
@@ -174,28 +318,8 @@ void Chunk::MakeModified() { m_isModified = true; }
|
|||||||
|
|
||||||
void Chunk::Structure(int x, int y, int z,int height)
|
void Chunk::Structure(int x, int y, int z,int height)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < height; i++)
|
for (int i = 0; i < height; i++)
|
||||||
{
|
{
|
||||||
SetBlock(x, i + y, z, BTYPE_GRASS, nullptr);
|
SetBlock(x, i + y, z, BTYPE_GRASS, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,7 @@ class Chunk {
|
|||||||
BlockType GetBlock(int x, int y, int z);
|
BlockType GetBlock(int x, int y, int z);
|
||||||
void CheckNeighbors(unsigned int x, unsigned int z, World* world);
|
void CheckNeighbors(unsigned int x, unsigned int z, World* world);
|
||||||
void GetPosition(unsigned int& x, unsigned int& y) const;
|
void GetPosition(unsigned int& x, unsigned int& y) const;
|
||||||
|
void PlaceTree(int x, int y, int z, int height);
|
||||||
|
|
||||||
void Structure(int x, int y, int z, int height);
|
void Structure(int x, int y, int z, int height);
|
||||||
bool IsDirty() const;
|
bool IsDirty() const;
|
||||||
|
@@ -41,17 +41,15 @@ typedef uint8_t BlockType;
|
|||||||
enum BLOCK_TYPE { BTYPE_AIR, BTYPE_DIRT, BTYPE_GRASS, BTYPE_METAL, BTYPE_ICE, BTYPE_GREENGRASS, BTYPE_LAST };
|
enum BLOCK_TYPE { BTYPE_AIR, BTYPE_DIRT, BTYPE_GRASS, BTYPE_METAL, BTYPE_ICE, BTYPE_GREENGRASS, BTYPE_LAST };
|
||||||
typedef uint8_t BoostType;
|
typedef uint8_t BoostType;
|
||||||
enum BOOST_TYPE { BTYPE_SPEED, BTYPE_HEAL, BTYPE_DAMAGE, BTYPE_INVINCIBLE, BTYPE_BOOST_LAST };
|
enum BOOST_TYPE { BTYPE_SPEED, BTYPE_HEAL, BTYPE_DAMAGE, BTYPE_INVINCIBLE, BTYPE_BOOST_LAST };
|
||||||
|
|
||||||
//anim
|
|
||||||
enum ANIM_TYPE { STILL = 0, SHOOTING = 8, JUMPING = 16, JUMPINGSHOOTING = 24, DEAD = 32, TYPE_LAST = 40};
|
enum ANIM_TYPE { STILL = 0, SHOOTING = 8, JUMPING = 16, JUMPINGSHOOTING = 24, DEAD = 32, TYPE_LAST = 40};
|
||||||
enum ANIM_POS {FRONT, QUARTER_FRONT_LEFT, QUATER_FRONT_RIGHT, PROFIL_LEFT, PROFIL_RIGHT, QUARTER_BACK_LEFT, QUARTER_BACK_RIGHT, BACK , POS_LAST};
|
enum ANIM_POS {FRONT, QUARTER_FRONT_LEFT, QUATER_FRONT_RIGHT, PROFIL_LEFT, PROFIL_RIGHT, QUARTER_BACK_LEFT, QUARTER_BACK_RIGHT, BACK , POS_LAST};
|
||||||
|
|
||||||
typedef uint64_t Timestamp;
|
typedef uint64_t Timestamp;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
#pragma comment(lib,"wsock32.lib") // Pour pouvoir faire fonctionner le linker sans le vcxproject
|
#pragma comment(lib,"wsock32.lib") // Pour pouvoir faire fonctionner le linker sans le vcxproject
|
||||||
#pragma comment(lib,"ws2_32.lib")
|
#pragma comment(lib,"ws2_32.lib")
|
||||||
|
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
@@ -248,8 +248,6 @@ void Player::SetDirection(Vector3f dir) { m_direction = dir; }
|
|||||||
|
|
||||||
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::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::GetPositionAbs() const { return m_position; }
|
|
||||||
|
|
||||||
Vector3f Player::GetVelocity() const { return m_velocity; }
|
Vector3f Player::GetVelocity() const { return m_velocity; }
|
||||||
|
|
||||||
Vector3f Player::GetPOV() const { return Vector3f(GetPosition().x, m_POV, GetPosition().z); }
|
Vector3f Player::GetPOV() const { return Vector3f(GetPosition().x, m_POV, GetPosition().z); }
|
||||||
|
@@ -26,7 +26,6 @@ public:
|
|||||||
|
|
||||||
void SetDirection(Vector3f dir);
|
void SetDirection(Vector3f dir);
|
||||||
Vector3f GetPosition() const;
|
Vector3f GetPosition() const;
|
||||||
Vector3f GetPositionAbs() const;
|
|
||||||
Vector3f GetDirection() const;
|
Vector3f GetDirection() const;
|
||||||
Vector3f GetVelocity() const;
|
Vector3f GetVelocity() const;
|
||||||
Vector3f GetPOV() const;
|
Vector3f GetPOV() const;
|
||||||
|
@@ -100,7 +100,7 @@ void Connection::Run(World* world) {
|
|||||||
in.keys.right,
|
in.keys.right,
|
||||||
in.keys.jump, false, el), world, el);
|
in.keys.jump, false, el), world, el);
|
||||||
|
|
||||||
out.position = player.get()->GetPositionAbs();
|
out.position = player.get()->GetPosition();
|
||||||
out.direction = in.direction;
|
out.direction = in.direction;
|
||||||
out.timestamp = in.timestamp;
|
out.timestamp = in.timestamp;
|
||||||
out.id = m_playinfo.id;
|
out.id = m_playinfo.id;
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
<ClInclude Include="mesh.h" />
|
<ClInclude Include="mesh.h" />
|
||||||
<ClInclude Include="openglcontext.h" />
|
<ClInclude Include="openglcontext.h" />
|
||||||
<ClInclude Include="remoteplayer.h" />
|
<ClInclude Include="remoteplayer.h" />
|
||||||
|
<ClInclude Include="settings.h" />
|
||||||
<ClInclude Include="shader.h" />
|
<ClInclude Include="shader.h" />
|
||||||
<ClInclude Include="skybox.h" />
|
<ClInclude Include="skybox.h" />
|
||||||
<ClInclude Include="texture.h" />
|
<ClInclude Include="texture.h" />
|
||||||
@@ -44,6 +45,7 @@
|
|||||||
<ClCompile Include="mesh.cpp" />
|
<ClCompile Include="mesh.cpp" />
|
||||||
<ClCompile Include="openglcontext.cpp" />
|
<ClCompile Include="openglcontext.cpp" />
|
||||||
<ClCompile Include="remoteplayer.cpp" />
|
<ClCompile Include="remoteplayer.cpp" />
|
||||||
|
<ClCompile Include="settings.cpp" />
|
||||||
<ClCompile Include="shader.cpp" />
|
<ClCompile Include="shader.cpp" />
|
||||||
<ClCompile Include="skybox.cpp" />
|
<ClCompile Include="skybox.cpp" />
|
||||||
<ClCompile Include="texture.cpp" />
|
<ClCompile Include="texture.cpp" />
|
||||||
|
@@ -56,6 +56,9 @@
|
|||||||
<ClInclude Include="booster.h">
|
<ClInclude Include="booster.h">
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="settings.h">
|
||||||
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="engine.cpp">
|
<ClCompile Include="engine.cpp">
|
||||||
@@ -103,5 +106,8 @@
|
|||||||
<ClCompile Include="booster.cpp">
|
<ClCompile Include="booster.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="settings.cpp">
|
||||||
|
<Filter>Fichiers sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@@ -48,3 +48,7 @@ void Audio::Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& v
|
|||||||
void Audio::ToggleMusicState() { m_music->setIsPaused(!m_music->getIsPaused()); }
|
void Audio::ToggleMusicState() { m_music->setIsPaused(!m_music->getIsPaused()); }
|
||||||
|
|
||||||
void Audio::PauseEngine() { m_engine->setAllSoundsPaused(); }
|
void Audio::PauseEngine() { m_engine->setAllSoundsPaused(); }
|
||||||
|
|
||||||
|
float Audio::GetMusicVolume() const {
|
||||||
|
return m_music->getVolume();
|
||||||
|
}
|
||||||
|
@@ -33,6 +33,8 @@ public:
|
|||||||
void ToggleMusicState();
|
void ToggleMusicState();
|
||||||
|
|
||||||
void PauseEngine();
|
void PauseEngine();
|
||||||
|
|
||||||
|
float GetMusicVolume() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AUDIO_H__
|
#endif // AUDIO_H__
|
||||||
|
@@ -28,22 +28,28 @@
|
|||||||
#define BASE_WIDTH 640
|
#define BASE_WIDTH 640
|
||||||
#define BASE_HEIGHT 480
|
#define BASE_HEIGHT 480
|
||||||
|
|
||||||
|
|
||||||
#define ANIME_PATH_JUMP "./media/textures/AssetOtherPlayer/FinalPNGJumping/"
|
#define ANIME_PATH_JUMP "./media/textures/AssetOtherPlayer/FinalPNGJumping/"
|
||||||
#define ANIME_PATH_STILL "./media/textures/AssetOtherPlayer/FinalPNGStanding/"
|
#define ANIME_PATH_STILL "./media/textures/AssetOtherPlayer/FinalPNGStanding/"
|
||||||
|
|
||||||
//1 = jump shoot sans anim, 2 = jump shoot avec anim
|
|
||||||
#define ANIM_PATH_JSHOOT1 "./media/textures/AssetOtherPlayer/FinalPNGJumpingShooting/"
|
|
||||||
#define ANIM_PATH_JSHOOT2 "./media/textures/AssetOtherPlayer/FinalPNGJumpingShooting/ShootingJump/"
|
|
||||||
//1 = shoot sans anim, 2 = shoot avec anim
|
|
||||||
#define ANIM_PATH_SSHOOT1 "./media/textures/AssetOtherPlayer/FinalPNGShooting/"
|
|
||||||
#define ANIM_PATH_SSHOOT2 "./media/textures/AssetOtherPlayer/FinalPNGShooting/Shooting/"
|
|
||||||
|
|
||||||
#define TEXTURE_PATH "./media/textures/"
|
#define TEXTURE_PATH "./media/textures/"
|
||||||
#define SHADER_PATH "./media/shaders/"
|
#define SHADER_PATH "./media/shaders/"
|
||||||
#define AUDIO_PATH "./media/audio/"
|
#define AUDIO_PATH "./media/audio/"
|
||||||
#define CHUNK_PATH "./media/chunks/"
|
#define CHUNK_PATH "./media/chunks/"
|
||||||
#define MENU_ITEM_PATH "./media/menu_items/"
|
|
||||||
#define BOOSTER_TEXTURE_PATH "./media/textures/Booster/"
|
#define BOOSTER_TEXTURE_PATH "./media/textures/Booster/"
|
||||||
|
|
||||||
|
enum GameState {
|
||||||
|
MAIN_MENU,
|
||||||
|
SPLASH,
|
||||||
|
OPTIONS,
|
||||||
|
QUIT,
|
||||||
|
PLAY,
|
||||||
|
PAUSE
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Resolution {
|
||||||
|
HD = 0, // 1280x720 (High Definition)
|
||||||
|
FHD, // 1920x1080 (Full HD)
|
||||||
|
QHD, // 2560x1440 (Quad HD)
|
||||||
|
UHD // 3840x2160 (Ultra HD)
|
||||||
|
};
|
||||||
|
|
||||||
#endif // DEFINE_H__
|
#endif // DEFINE_H__
|
||||||
|
@@ -24,15 +24,12 @@
|
|||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
#include "remoteplayer.h"
|
#include "remoteplayer.h"
|
||||||
#include "booster.h"
|
#include "booster.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
class Engine : public OpenglContext {
|
class Engine : public OpenglContext {
|
||||||
public:
|
public:
|
||||||
Engine();
|
Engine();
|
||||||
virtual ~Engine();
|
virtual ~Engine();
|
||||||
virtual void DrawMenu();
|
|
||||||
virtual void DrawPause();
|
|
||||||
virtual void DrawSplachScreen();
|
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
virtual void DeInit();
|
virtual void DeInit();
|
||||||
virtual void LoadResource();
|
virtual void LoadResource();
|
||||||
@@ -47,90 +44,142 @@ public:
|
|||||||
private:
|
private:
|
||||||
int GetFps(float elapsedTime) const;
|
int GetFps(float elapsedTime) const;
|
||||||
int GetCountdown(float elapsedTime);
|
int GetCountdown(float elapsedTime);
|
||||||
|
int GetOptionsChoice();
|
||||||
|
|
||||||
bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true);
|
bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true);
|
||||||
|
|
||||||
void InstantDamage();
|
void InstantDamage();
|
||||||
void SystemNotification(std::string systemLog);
|
void SystemNotification(std::string systemLog);
|
||||||
void KillNotification(Player killer, Player killed);
|
void KillNotification(Player killer, Player killed);
|
||||||
|
|
||||||
void DisplayNotification(std::string message);
|
void DisplayNotification(std::string message);
|
||||||
void ProcessNotificationQueue();
|
|
||||||
void DisplayCrosshair();
|
void DisplayCrosshair();
|
||||||
void DisplayPovGun();
|
void DisplayPovGun();
|
||||||
void DisplayCurrentItem();
|
void DisplayCurrentItem();
|
||||||
void DisplayHud(int timer);
|
void DisplayHud(int timer);
|
||||||
void DisplayInfo(float elapsedTime, BlockType bloc);
|
|
||||||
void DisplaySingleOrMultiplayerMenu();
|
|
||||||
void DrawHud(float elapsedTime, BlockType bloc);
|
void DrawHud(float elapsedTime, BlockType bloc);
|
||||||
|
void DisplayInfo(float elapsedTime, BlockType bloc);
|
||||||
|
|
||||||
|
void DisplaySplashScreen();
|
||||||
|
void DisplayPauseMenu();
|
||||||
|
|
||||||
|
void DisplayMainMenu();
|
||||||
|
void DrawButtonBackgrounds(float centerX, float centerY, int iterations);
|
||||||
|
void DrawMainMenuButtons(float centerX, float centerY);
|
||||||
|
void DrawSingleMultiButtons(float centerX, float centerY);
|
||||||
|
|
||||||
|
void DisplayOptionsMenu();
|
||||||
|
void DisplayAudioMenu(float centerX, float centerY);
|
||||||
|
void DisplayGraphicsMenu(float centerX, float centerY);
|
||||||
|
void DisplayGameplayMenu(float centerX, float centerY);
|
||||||
|
void DrawSliderBackground(float centerX, float centerY, float minVal, float maxVal, float bottomSideValue, float topSideValue);
|
||||||
|
void DisplayBarPercentValue(float centerX, float centerY, float posX, float posY, float minVal, float maxVal, float value);
|
||||||
|
void DrawSlider(float centerX, float centerY, float value, float minVal, float maxVal, float bottomSideValue, float topSideValue);
|
||||||
|
|
||||||
|
|
||||||
void PrintText(float x, float y, const std::string& t, float charSizeMultiplier = 1.0f);
|
void PrintText(float x, float y, const std::string& t, float charSizeMultiplier = 1.0f);
|
||||||
|
void ProcessNotificationQueue();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Connector m_conn;
|
Connector m_conn;
|
||||||
Shader m_shader01;
|
|
||||||
|
Audio m_audio = Audio(AUDIO_PATH "start.wav");
|
||||||
|
irrklang::ISound* m_powpow, * m_scream;
|
||||||
|
irrklang::ISound* m_whoosh[MAX_BULLETS];
|
||||||
|
|
||||||
|
Bullet* m_bullets[MAX_BULLETS];
|
||||||
|
|
||||||
|
std::chrono::high_resolution_clock::time_point m_startTime;
|
||||||
|
std::unordered_map<uint64_t, Player*> m_players;
|
||||||
|
netprot::Buffer m_buf, m_bufout;
|
||||||
|
|
||||||
|
netprot::PlayerInfo m_pinfo;
|
||||||
|
RemotePlayer m_remotePlayer = RemotePlayer(netprot::PlayerInfo(), Vector3f(5.5f, CHUNK_SIZE_Y + 1.8f, 5.5f));
|
||||||
|
std::string m_messageNotification = "";
|
||||||
|
|
||||||
|
World m_world = World();
|
||||||
|
Player m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f));
|
||||||
|
|
||||||
|
Renderer m_renderer = Renderer();
|
||||||
|
|
||||||
|
Booster m_booster = Booster();
|
||||||
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;
|
||||||
|
|
||||||
|
Shader m_shader01;
|
||||||
|
|
||||||
|
Skybox m_skybox;
|
||||||
|
|
||||||
TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST);
|
TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST);
|
||||||
TextureAtlas m_animeAtlas = TextureAtlas(TYPE_LAST + POS_LAST);
|
TextureAtlas m_animeAtlas = TextureAtlas(TYPE_LAST + POS_LAST);
|
||||||
|
|
||||||
World m_world = World();
|
TextureAtlas::TextureIndex texBoostHeal;
|
||||||
Renderer m_renderer = Renderer();
|
|
||||||
Booster m_booster = Booster();
|
|
||||||
|
|
||||||
Texture m_textureCrosshair;
|
Texture m_textureCrosshair;
|
||||||
Texture m_textureFont;
|
Texture m_textureFont;
|
||||||
Texture m_textureGun;
|
Texture m_textureGun;
|
||||||
Texture m_texturePovGun;
|
Texture m_texturePovGun;
|
||||||
Texture m_textureSkybox;
|
Texture m_textureSkybox;
|
||||||
Texture m_textureSoloMultiMenu;
|
|
||||||
Texture m_textureSoloText;
|
|
||||||
Texture m_textureMultiText;
|
|
||||||
Texture m_textureTitle;
|
|
||||||
|
|
||||||
TextureAtlas::TextureIndex texBoostHeal;
|
Texture m_textureMainMenu;
|
||||||
|
Texture m_textureOptionsMenu;
|
||||||
|
Texture m_texturePauseMenu;
|
||||||
|
Texture m_textureSplashScreen;
|
||||||
|
|
||||||
Skybox m_skybox;
|
Texture m_textureHd;
|
||||||
Audio m_audio = Audio(AUDIO_PATH "start.wav");
|
Texture m_textureFhd;
|
||||||
|
Texture m_textureQhd;
|
||||||
|
Texture m_textureUhd;
|
||||||
|
Texture m_textureCheck;
|
||||||
|
Texture m_textureChecked;
|
||||||
|
|
||||||
irrklang::ISound* m_powpow,
|
Texture m_textureOptAudio;
|
||||||
* m_scream;
|
Texture m_textureOptBack;
|
||||||
irrklang::ISound *m_whoosh[MAX_BULLETS];
|
Texture m_textureOptGameplay;
|
||||||
|
Texture m_textureOptGraphics;
|
||||||
|
Texture m_textureOptMain;
|
||||||
|
Texture m_textureOptMusic;
|
||||||
|
Texture m_textureOptOptions;
|
||||||
|
Texture m_textureOptResolution;
|
||||||
|
Texture m_textureOptSensitivity;
|
||||||
|
Texture m_textureOptSfx;
|
||||||
|
|
||||||
Player m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f));
|
Texture m_textureMenuBack;
|
||||||
|
Texture m_textureMenuMulti;
|
||||||
|
Texture m_textureMenuOptions;
|
||||||
|
Texture m_textureMenuPlay;
|
||||||
|
Texture m_textureMenuQuit;
|
||||||
|
Texture m_textureMenuSingle;
|
||||||
|
Texture m_textureMenuTitle;
|
||||||
|
|
||||||
Bullet* m_bullets[MAX_BULLETS];
|
Settings m_options = Settings(m_audio);
|
||||||
|
|
||||||
std::unordered_map<uint64_t, Player*> m_players;
|
|
||||||
netprot::Buffer m_buf, m_bufout;
|
|
||||||
std::chrono::high_resolution_clock::time_point m_startTime;
|
|
||||||
|
|
||||||
//Menu
|
|
||||||
enum class GameState: uint8_t { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY, PAUSE };
|
|
||||||
GameState m_gamestate = GameState::MAIN_MENU;
|
|
||||||
Texture MenuTitleTexture;
|
|
||||||
Texture MenuBGTexture;
|
|
||||||
Texture MenuStartTexture;
|
|
||||||
Texture MenuQuitTexture;
|
|
||||||
Texture MenuOptionsTexture;
|
|
||||||
Texture PauseBGTexture;
|
|
||||||
Texture SplachScreenTexture;
|
|
||||||
|
|
||||||
|
Resolution m_resolution = HD;
|
||||||
|
|
||||||
|
float m_splashTime = 2.0f;
|
||||||
float m_scale;
|
float m_scale;
|
||||||
float m_time = 0;
|
float m_time = 0;
|
||||||
float m_time_SplashScreen = 0;
|
|
||||||
float m_titleX = 0;
|
float m_titleX = 0;
|
||||||
float m_titleY = 0;
|
float m_titleY = 0;
|
||||||
float m_Width = 0;
|
|
||||||
float m_Height = 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;
|
||||||
int m_timerReductionChunk = 30;
|
int m_timerReductionChunk = 30;
|
||||||
|
|
||||||
|
float m_volPrincipal = 0.0f;
|
||||||
|
float m_volMusique = 0.0f;
|
||||||
|
float m_volEffets = 0.0f;
|
||||||
|
float m_volSensible = 0.0f;
|
||||||
|
|
||||||
|
int m_selectedOption = 0;
|
||||||
|
|
||||||
|
bool m_selectedOptAudioMainBar = false;
|
||||||
|
bool m_selectedOptAudioMusicBar = false;
|
||||||
|
bool m_selectedOptAudioSfxBar = false;
|
||||||
|
bool m_selectedGameplaySensitivityBar = false;
|
||||||
|
|
||||||
bool m_damage = false;
|
bool m_damage = false;
|
||||||
|
|
||||||
bool m_wireframe = false;
|
bool m_wireframe = false;
|
||||||
@@ -144,9 +193,12 @@ private:
|
|||||||
bool m_soloMultiChoiceMade = false;
|
bool m_soloMultiChoiceMade = false;
|
||||||
bool m_stopcountdown = false;
|
bool m_stopcountdown = false;
|
||||||
|
|
||||||
|
bool m_selectedPlayOptions = false;
|
||||||
|
bool m_selectedOptions = false;
|
||||||
|
bool m_selectedQuit = 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;
|
||||||
@@ -154,19 +206,17 @@ private:
|
|||||||
bool m_keyS = false;
|
bool m_keyS = false;
|
||||||
bool m_keyD = false;
|
bool m_keyD = false;
|
||||||
bool m_keySpace = false;
|
bool m_keySpace = false;
|
||||||
|
|
||||||
bool m_mouseL = false;
|
bool m_mouseL = false;
|
||||||
bool m_mouseR = false;
|
bool m_mouseR = false;
|
||||||
bool m_mouseC = false;
|
bool m_mouseC = false;
|
||||||
bool m_mouseWU = false;
|
bool m_mouseWU = false;
|
||||||
bool m_mouseWD = false;
|
bool m_mouseWD = false;
|
||||||
//Pour trouver ou est la souris
|
|
||||||
float m_mousemx = 0;
|
float m_mousemx = 0;
|
||||||
float m_mousemy = 0;
|
float m_mousemy = 0;
|
||||||
|
|
||||||
bool m_networkgame = false;
|
bool m_networkgame = false;
|
||||||
netprot::PlayerInfo m_pinfo;
|
|
||||||
RemotePlayer m_remotePlayer = RemotePlayer(netprot::PlayerInfo(),Vector3f(5.5f, CHUNK_SIZE_Y + 1.8f, 5.5f));
|
|
||||||
std::string m_messageNotification = "";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ENGINE_H__
|
#endif // ENGINE_H__
|
||||||
|
After Width: | Height: | Size: 264 KiB |
After Width: | Height: | Size: 320 KiB |
After Width: | Height: | Size: 337 KiB |
After Width: | Height: | Size: 360 KiB |
After Width: | Height: | Size: 394 KiB |
After Width: | Height: | Size: 339 KiB |
After Width: | Height: | Size: 374 KiB |
After Width: | Height: | Size: 656 KiB |
After Width: | Height: | Size: 653 KiB |
After Width: | Height: | Size: 656 KiB |
After Width: | Height: | Size: 652 KiB |
After Width: | Height: | Size: 485 KiB |
After Width: | Height: | Size: 512 KiB |
After Width: | Height: | Size: 575 KiB |
After Width: | Height: | Size: 512 KiB |
After Width: | Height: | Size: 575 KiB |
After Width: | Height: | Size: 716 KiB |
After Width: | Height: | Size: 732 KiB |
After Width: | Height: | Size: 715 KiB |
After Width: | Height: | Size: 731 KiB |
After Width: | Height: | Size: 629 KiB |
After Width: | Height: | Size: 649 KiB |
After Width: | Height: | Size: 644 KiB |
After Width: | Height: | Size: 646 KiB |
After Width: | Height: | Size: 326 KiB |
After Width: | Height: | Size: 268 KiB |
After Width: | Height: | Size: 660 KiB |
After Width: | Height: | Size: 680 KiB |
After Width: | Height: | Size: 659 KiB |
After Width: | Height: | Size: 680 KiB |
After Width: | Height: | Size: 486 KiB |
After Width: | Height: | Size: 494 KiB |
After Width: | Height: | Size: 517 KiB |
After Width: | Height: | Size: 493 KiB |
After Width: | Height: | Size: 517 KiB |
After Width: | Height: | Size: 695 KiB |
After Width: | Height: | Size: 710 KiB |
After Width: | Height: | Size: 701 KiB |
After Width: | Height: | Size: 728 KiB |
After Width: | Height: | Size: 696 KiB |
After Width: | Height: | Size: 732 KiB |
After Width: | Height: | Size: 694 KiB |
After Width: | Height: | Size: 710 KiB |
After Width: | Height: | Size: 410 KiB |
After Width: | Height: | Size: 402 KiB |
After Width: | Height: | Size: 413 KiB |
After Width: | Height: | Size: 402 KiB |
After Width: | Height: | Size: 413 KiB |
Before Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 6.5 MiB |
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1.3 MiB |
BIN
SQCSim2021/media/textures/menus/backgrounds/bgOptions.png
Normal file
After Width: | Height: | Size: 674 KiB |
BIN
SQCSim2021/media/textures/menus/backgrounds/bgPause.png
Normal file
After Width: | Height: | Size: 562 KiB |
Before Width: | Height: | Size: 195 KiB After Width: | Height: | Size: 195 KiB |
BIN
SQCSim2021/media/textures/menus/buttons/main/mainBack.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
SQCSim2021/media/textures/menus/buttons/main/mainMulti.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
SQCSim2021/media/textures/menus/buttons/main/mainOptions.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
SQCSim2021/media/textures/menus/buttons/main/mainPlay.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
SQCSim2021/media/textures/menus/buttons/main/mainQuit.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
SQCSim2021/media/textures/menus/buttons/main/mainSingle.png
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
SQCSim2021/media/textures/menus/buttons/options/optAudio.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
SQCSim2021/media/textures/menus/buttons/options/optBack.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
SQCSim2021/media/textures/menus/buttons/options/optGameplay.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
SQCSim2021/media/textures/menus/buttons/options/optGraphics.png
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
SQCSim2021/media/textures/menus/buttons/options/optMain.png
Normal file
After Width: | Height: | Size: 5.5 KiB |
BIN
SQCSim2021/media/textures/menus/buttons/options/optMusic.png
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
SQCSim2021/media/textures/menus/buttons/options/optOptions.png
Normal file
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 6.8 KiB |
After Width: | Height: | Size: 12 KiB |
BIN
SQCSim2021/media/textures/menus/buttons/options/optSfx.png
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
SQCSim2021/media/textures/menus/labels/labelFhd.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
SQCSim2021/media/textures/menus/labels/labelHd.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
SQCSim2021/media/textures/menus/labels/labelQhd.png
Normal file
After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
BIN
SQCSim2021/media/textures/menus/labels/labelUhd.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
SQCSim2021/media/textures/menus/others/check.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
SQCSim2021/media/textures/menus/others/checked.png
Normal file
After Width: | Height: | Size: 9.8 KiB |
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 2.1 KiB |
@@ -33,51 +33,48 @@ void RemotePlayer::Init()
|
|||||||
|
|
||||||
void RemotePlayer::Feed(const netprot::Output out) {
|
void RemotePlayer::Feed(const netprot::Output out) {
|
||||||
|
|
||||||
current.position = out.position;
|
//current.position = out.position;
|
||||||
current.direction = out.direction;
|
//current.direction = out.direction;
|
||||||
current.states = out.states;
|
//current.states = out.states;
|
||||||
current.id = out.id;
|
//current.id = out.id;
|
||||||
|
|
||||||
if (current.position != previous.position)
|
//if (current.position != previous.position)
|
||||||
{
|
//{
|
||||||
Vector3f positionDelta = current.position - previous.position;
|
// Vector3f positionDelta = current.position - previous.position;
|
||||||
m_position = current.position + positionDelta;
|
// m_position = current.position + positionDelta;
|
||||||
m_direction = current.direction;
|
// m_direction = current.direction;
|
||||||
|
|
||||||
}
|
//}
|
||||||
|
|
||||||
if(current.direction != previous.direction)
|
//if(current.direction != previous.direction)
|
||||||
{
|
//{
|
||||||
m_direction = current.direction;
|
// m_direction = current.direction;
|
||||||
current.direction = current.direction;
|
// current.direction = current.direction;
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (current.states.shooting) {
|
//if (current.states.shooting) {
|
||||||
m_animstate = Anim::SHOOTING;
|
// m_animstate = Anim::SHOOTING;
|
||||||
}
|
//}
|
||||||
else if (current.states.jumping) {
|
//else if (current.states.jumping) {
|
||||||
m_animstate = Anim::JUMPING;
|
// m_animstate = Anim::JUMPING;
|
||||||
}
|
//}
|
||||||
else if (current.states.dead) {
|
//else if (current.states.dead) {
|
||||||
m_animstate = Anim::DEAD;
|
// m_animstate = Anim::DEAD;
|
||||||
}
|
//}
|
||||||
else if(current.states.powerup){
|
//else if(current.states.powerup){
|
||||||
m_animstate = Anim::POWERUP;
|
// m_animstate = Anim::POWERUP;
|
||||||
}
|
//}
|
||||||
else if (current.states.still) {
|
//else if (current.states.still) {
|
||||||
m_animstate = Anim::STILL;
|
// m_animstate = Anim::STILL;
|
||||||
}
|
//}
|
||||||
else if (current.states.running) {
|
//else if (current.states.running) {
|
||||||
m_animstate = Anim::RUNNING;
|
// m_animstate = Anim::RUNNING;
|
||||||
}
|
//}
|
||||||
|
|
||||||
previous.direction = current.direction;
|
//previous.direction = current.direction;
|
||||||
previous.position = current.position;
|
//previous.position = current.position;
|
||||||
previous.states = current.states;
|
//previous.states = current.states;
|
||||||
previous.id = current.id;
|
//previous.id = current.id;
|
||||||
|
|
||||||
m_direction = current.direction;
|
|
||||||
m_position = current.position;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tran, float elapsedTime)
|
void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tran, float elapsedTime)
|
||||||
|
146
SQCSim2021/settings.cpp
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
Settings::Settings(Audio& audio)
|
||||||
|
: m_audio(audio),
|
||||||
|
m_mainVolume(0.5f),
|
||||||
|
m_musicVolume(0.5f),
|
||||||
|
m_sfxVolume(0.5f),
|
||||||
|
m_resolution(FHD),
|
||||||
|
m_fullscreen(false),
|
||||||
|
m_brightness(0.5f),
|
||||||
|
m_contrast(0.5f),
|
||||||
|
m_mouseSensitivity(0.5f) {
|
||||||
|
ApplyResolution(m_resolution);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::SaveFile(const std::string& filename) {
|
||||||
|
std::ofstream file(filename);
|
||||||
|
if (!file.is_open()) {
|
||||||
|
std::cerr << "Failed to open file for saving parameters" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
file << m_mainVolume << '\n';
|
||||||
|
file << m_musicVolume << '\n';
|
||||||
|
file << m_sfxVolume << '\n';
|
||||||
|
|
||||||
|
file << static_cast<int>(m_resolution) << '\n';
|
||||||
|
file << m_fullscreen << '\n';
|
||||||
|
file << m_brightness << '\n';
|
||||||
|
file << m_contrast << '\n';
|
||||||
|
|
||||||
|
file << m_mouseSensitivity << '\n';
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::LoadFile(const std::string& filename) {
|
||||||
|
std::ifstream file(filename);
|
||||||
|
if (!file.is_open()) {
|
||||||
|
std::cerr << "Failed to open file for loading parameters" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
file >> m_mainVolume;
|
||||||
|
file >> m_musicVolume;
|
||||||
|
file >> m_sfxVolume;
|
||||||
|
|
||||||
|
int resolutionValue;
|
||||||
|
file >> resolutionValue;
|
||||||
|
m_resolution = static_cast<Resolution>(resolutionValue);
|
||||||
|
|
||||||
|
file >> m_fullscreen;
|
||||||
|
file >> m_brightness;
|
||||||
|
file >> m_contrast;
|
||||||
|
|
||||||
|
file >> m_mouseSensitivity;
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
float Settings::GetMainVolume() const {
|
||||||
|
return m_mainVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::SetMainVolume(float volume) {
|
||||||
|
m_mainVolume = volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::GetMusicVolume() {
|
||||||
|
m_musicVolume = m_audio.GetMusicVolume();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::SetMusicVolume(float volume) {
|
||||||
|
m_musicVolume = volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Settings::GetSfxVolume() const {
|
||||||
|
return m_sfxVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::SetSfxVolume(float volume) {
|
||||||
|
m_sfxVolume = volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Settings::GetBrightness() const {
|
||||||
|
return m_brightness;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::SetBrightness(float brightness) {
|
||||||
|
m_brightness = brightness;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Settings::GetContrast() const {
|
||||||
|
return m_contrast;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::SetContrast(float contrast) {
|
||||||
|
m_contrast = contrast;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Settings::GetFullscreen() const {
|
||||||
|
return m_fullscreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::SetFullscreen(bool fullscreen) {
|
||||||
|
m_fullscreen = fullscreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Resolution& Settings::GetResolution() const {
|
||||||
|
return m_resolution;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::SetResolution(const Resolution& resolution) {
|
||||||
|
m_resolution = resolution;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Settings::GetMouseSensitivity() const {
|
||||||
|
return m_mouseSensitivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::SetMouseSensitivity(float sensitivity) {
|
||||||
|
m_mouseSensitivity = sensitivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::ApplyResolution(Resolution resolution) {
|
||||||
|
switch (resolution) {
|
||||||
|
case HD:
|
||||||
|
m_rezWidth = 1280;
|
||||||
|
m_rezHeight = 720;
|
||||||
|
break;
|
||||||
|
case FHD:
|
||||||
|
m_rezWidth = 1920;
|
||||||
|
m_rezHeight = 1080;
|
||||||
|
break;
|
||||||
|
case QHD:
|
||||||
|
m_rezWidth = 2560;
|
||||||
|
m_rezHeight = 1440;
|
||||||
|
break;
|
||||||
|
case UHD:
|
||||||
|
m_rezWidth = 3840;
|
||||||
|
m_rezHeight = 2160;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
70
SQCSim2021/settings.h
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
#ifndef SETTINGS_H__
|
||||||
|
#define SETTINGS_H__
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include "define.h"
|
||||||
|
#include "audio.h"
|
||||||
|
|
||||||
|
class Settings {
|
||||||
|
public:
|
||||||
|
Settings(Audio& audio);
|
||||||
|
|
||||||
|
void SaveFile(const std::string& filename);
|
||||||
|
void LoadFile(const std::string& filename);
|
||||||
|
|
||||||
|
// Audio
|
||||||
|
float GetMainVolume() const;
|
||||||
|
void SetMainVolume(float volume);
|
||||||
|
|
||||||
|
void GetMusicVolume();
|
||||||
|
void SetMusicVolume(float volume);
|
||||||
|
|
||||||
|
float GetSfxVolume() const;
|
||||||
|
void SetSfxVolume(float volume);
|
||||||
|
|
||||||
|
// Graphic
|
||||||
|
float GetBrightness() const;
|
||||||
|
void SetBrightness(float brightness);
|
||||||
|
|
||||||
|
float GetContrast() const;
|
||||||
|
void SetContrast(float contrast);
|
||||||
|
|
||||||
|
bool GetFullscreen() const;
|
||||||
|
void SetFullscreen(bool fullscreen);
|
||||||
|
|
||||||
|
const Resolution& GetResolution() const;
|
||||||
|
void SetResolution(const Resolution& resolution);
|
||||||
|
|
||||||
|
// Gameplay
|
||||||
|
float GetMouseSensitivity() const;
|
||||||
|
void SetMouseSensitivity(float sensitivity);
|
||||||
|
|
||||||
|
void ApplyResolution(Resolution resolution);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
Audio& m_audio;
|
||||||
|
// Audio
|
||||||
|
float m_mainVolume;
|
||||||
|
float m_musicVolume;
|
||||||
|
float m_sfxVolume;
|
||||||
|
|
||||||
|
// Graphic
|
||||||
|
Resolution m_resolution;
|
||||||
|
bool m_fullscreen;
|
||||||
|
int m_rezWidth;
|
||||||
|
int m_rezHeight;
|
||||||
|
float m_brightness;
|
||||||
|
float m_contrast;
|
||||||
|
|
||||||
|
// Gameplay
|
||||||
|
float m_mouseSensitivity;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // PARAMETERS_H
|