Oh yeah.
This commit is contained in:
parent
461a8aa11b
commit
46298f8256
@ -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)) / 4,
|
||||
y = (rand() % (CHUNK_SIZE_Y * WORLD_SIZE_Y - 1) - (CHUNK_SIZE_Y * WORLD_SIZE_Y / 2)) / 4;
|
||||
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;
|
||||
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;
|
||||
|
@ -29,9 +29,6 @@ Engine::~Engine() {
|
||||
}
|
||||
|
||||
void Engine::Init() {
|
||||
|
||||
uint64_t seed = SEED;
|
||||
|
||||
if (m_istarted)
|
||||
return;
|
||||
else m_istarted = true;
|
||||
@ -39,7 +36,7 @@ void Engine::Init() {
|
||||
// Objet de skybox avec sa propre texture et son propre shader!
|
||||
m_skybox.Init(0.2f);
|
||||
// Objet de musique!
|
||||
//m_audio.ToggleMusicState();
|
||||
m_audio.ToggleMusicState();
|
||||
|
||||
// Array pour les balles.
|
||||
for (int x = 0; x < MAX_BULLETS; ++x) {
|
||||
@ -47,7 +44,8 @@ void Engine::Init() {
|
||||
m_whoosh[x] = nullptr;
|
||||
}
|
||||
|
||||
m_world.SetSeed(seed);
|
||||
m_world.GetChunks().Reset(nullptr);
|
||||
m_world.SetSeed(SEED);
|
||||
|
||||
m_startTime = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
@ -609,7 +607,8 @@ int Engine::GetOptionsChoice() {
|
||||
return m_selectedOption;
|
||||
}
|
||||
|
||||
void Engine::StartMultiplayerGame() {
|
||||
bool Engine::StartMultiplayerGame() {
|
||||
bool ok = true;
|
||||
if (!m_conn.Init()) {
|
||||
if (!m_conn.Connect(m_serverAddr.c_str(), m_username)) {
|
||||
// setup jeu en reseau.
|
||||
@ -620,12 +619,20 @@ void Engine::StartMultiplayerGame() {
|
||||
for (auto& [key, player] : m_conn.m_players)
|
||||
m_players[key] = new RemotePlayer(player);
|
||||
|
||||
//seed = m_conn.getSeed();
|
||||
//m_world.SetSeed(m_conn.getSeed());
|
||||
m_world.SetSeed(9370707);
|
||||
m_networkgame = true;
|
||||
}
|
||||
else std::cout << "Erreur de connexion." << std::endl;
|
||||
else {
|
||||
std::cout << "Erreur de connexion." << std::endl;
|
||||
ok = false;
|
||||
}
|
||||
else std::cout << "Erreur de creation de socket." << std::endl;
|
||||
}
|
||||
else {
|
||||
std::cout << "Erreur de creation de socket." << std::endl;
|
||||
ok = false;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
void Engine::DisplayInfo(float elapsedTime, BlockType bloc) {
|
||||
@ -1228,8 +1235,14 @@ void Engine::Render(float elapsedTime) {
|
||||
if (m_gamestate == GameState::LOBBY) {
|
||||
DisplayLobbyMenu(elapsedTime);
|
||||
if (m_multiReady) {
|
||||
StartMultiplayerGame();
|
||||
if (StartMultiplayerGame()) {
|
||||
std::cout << "Starting multiplayer game reached" << std::endl;
|
||||
m_gamestate = GameState::PLAY;
|
||||
}
|
||||
else {
|
||||
std::cout << "Cannot reach server." << std::endl;
|
||||
m_gamestate = GameState::MAIN_MENU;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -2018,7 +2031,6 @@ void Engine::HandlePlayerInput(float elapsedTime) {
|
||||
m_currentInputString = "";
|
||||
m_settingServer = false;
|
||||
m_multiReady = true;
|
||||
m_gamestate = GameState::PLAY;
|
||||
}
|
||||
}
|
||||
m_keyEnter = false;
|
||||
|
@ -46,7 +46,7 @@ private:
|
||||
int GetFps(float elapsedTime) const;
|
||||
int GetCountdown(float elapsedTime);
|
||||
int GetOptionsChoice();
|
||||
void StartMultiplayerGame();
|
||||
bool StartMultiplayerGame();
|
||||
|
||||
bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true);
|
||||
|
||||
@ -104,7 +104,7 @@ private:
|
||||
BlockInfo* m_blockinfo[BTYPE_LAST];
|
||||
BoostInfo* m_boostinfo[BTYPE_BOOST_LAST];
|
||||
|
||||
GameState m_gamestate = GameState::PLAY;
|
||||
GameState m_gamestate = GameState::SPLASH;
|
||||
|
||||
Shader m_shader01;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user