Push connexion multiplayer.
This commit is contained in:
parent
c88143c2bc
commit
09979f1e72
@ -41,7 +41,7 @@ enum GameState {
|
|||||||
SPLASH,
|
SPLASH,
|
||||||
LOBBY,
|
LOBBY,
|
||||||
OPTIONS,
|
OPTIONS,
|
||||||
QUIT,
|
QUIT,
|
||||||
PLAY,
|
PLAY,
|
||||||
PAUSE
|
PAUSE
|
||||||
};
|
};
|
||||||
|
@ -576,43 +576,8 @@ int Engine::GetOptionsChoice() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Engine::StartMultiplayerGame() {
|
void Engine::StartMultiplayerGame() {
|
||||||
char* ch = new char[2];
|
|
||||||
|
|
||||||
//std::cout << "Jouer en ligne? [o/N] ";
|
|
||||||
//std::cin.getline(ch, 2);
|
|
||||||
//std::cout << std::endl;
|
|
||||||
|
|
||||||
char* input = new char[32];
|
|
||||||
std::string playname, srvname;
|
|
||||||
|
|
||||||
/*if (*ch == 'o' || *ch == 'O') {
|
|
||||||
char* input = new char[32];
|
|
||||||
std::string playname, srvname;
|
|
||||||
|
|
||||||
while (playname.size() < 1) {
|
|
||||||
std::cout << "Veuillez entrer un nom de joueur: ";
|
|
||||||
std::cin.getline(input, 32);
|
|
||||||
std::cout << std::endl;
|
|
||||||
playname = input;
|
|
||||||
if (playname.size() < 1 || playname.size() > 32)
|
|
||||||
std::puts("Nom invalide.");
|
|
||||||
}
|
|
||||||
while (srvname.size() < 1) {
|
|
||||||
std::cout << "Veuillez entrer une adresse de serveur: ";
|
|
||||||
std::cin.getline(input, 32);
|
|
||||||
std::cout << std::endl;
|
|
||||||
srvname = input;
|
|
||||||
if (srvname.size() < 1 || srvname.size() > 32)
|
|
||||||
std::puts("Adresse serveur invalide.");
|
|
||||||
}
|
|
||||||
delete[] input;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
delete[] ch;*/
|
|
||||||
|
|
||||||
if (!m_conn.Init()) {
|
if (!m_conn.Init()) {
|
||||||
if (!m_conn.Connect(srvname.c_str(), playname)) {
|
if (!m_conn.Connect(m_serverAddr.c_str(), m_username)) {
|
||||||
// setup jeu en reseau.
|
// setup jeu en reseau.
|
||||||
std::cout << "ID recu du serveur: " << std::to_string(m_conn.getId()) << "!" << std::endl;
|
std::cout << "ID recu du serveur: " << std::to_string(m_conn.getId()) << "!" << std::endl;
|
||||||
std::cout << "Seed recu du serveur: " << std::to_string(m_conn.getSeed()) << "!" << std::endl;
|
std::cout << "Seed recu du serveur: " << std::to_string(m_conn.getSeed()) << "!" << std::endl;
|
||||||
@ -1228,6 +1193,10 @@ void Engine::Render(float elapsedTime) {
|
|||||||
|
|
||||||
if (m_gamestate == GameState::LOBBY) {
|
if (m_gamestate == GameState::LOBBY) {
|
||||||
DisplayLobbyMenu(elapsedTime);
|
DisplayLobbyMenu(elapsedTime);
|
||||||
|
if (m_multiReady) {
|
||||||
|
StartMultiplayerGame();
|
||||||
|
std::cout << "Starting multiplayer game reached" << std::endl;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1910,6 +1879,8 @@ void Engine::HandlePlayerInput(float elapsedTime) {
|
|||||||
m_serverAddr = m_currentInputString;
|
m_serverAddr = m_currentInputString;
|
||||||
m_currentInputString = "";
|
m_currentInputString = "";
|
||||||
m_settingServer = false;
|
m_settingServer = false;
|
||||||
|
m_multiReady = true;
|
||||||
|
m_gamestate = GameState::PLAY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_keyEnter = false;
|
m_keyEnter = false;
|
||||||
|
@ -214,6 +214,7 @@ private:
|
|||||||
bool m_charChanged = false;
|
bool m_charChanged = false;
|
||||||
bool m_settingUsername = false;
|
bool m_settingUsername = false;
|
||||||
bool m_settingServer = false;
|
bool m_settingServer = false;
|
||||||
|
bool m_multiReady = false;
|
||||||
|
|
||||||
bool m_key1 = false;
|
bool m_key1 = false;
|
||||||
bool m_key2 = false;
|
bool m_key2 = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user