R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1
/*
2
** EPITECH PROJECT, 2025
3
** Created by mael on 02/12/2025.
4
** File description:
5
** main.cpp
6
*/
7
8
#include <iostream>
9
#include <string>
10
#include "
Client/Client.hpp
"
11
12
// Parse command line arguments
13
void
parseCommandLine
(
int
argc,
char
**argv, std::string &host, uint16_t &port) {
14
if
(argc > 1) {
15
host = argv[1];
16
}
17
if
(argc > 2) {
18
port =
static_cast<
uint16_t
>
(std::atoi(argv[2]));
19
}
20
}
21
22
// Print welcome banner
23
void
printBanner
(
const
std::string &host, uint16_t port) {
24
std::cout <<
"=================================="
<< std::endl;
25
std::cout <<
"R-Type Client"
<< std::endl;
26
std::cout <<
"Server: "
<< host <<
":"
<< port << std::endl;
27
std::cout <<
"=================================="
<< std::endl;
28
}
29
30
int
main
(
int
argc,
char
**argv) {
31
std::string host =
"127.0.0.1"
;
32
uint16_t port = 4242;
33
34
// Parse command line arguments
35
parseCommandLine
(argc, argv, host, port);
36
printBanner
(host, port);
37
38
std::string playerName =
"Player"
;
// Default name, will be updated by login
39
40
// Create and initialize Client
41
// The client handles the login phase internally before connecting
42
Client
client
(playerName, host, port);
43
44
if
(!
client
.initialize()) {
45
std::cerr <<
"Failed to initialize client"
<< std::endl;
46
return
1;
47
}
48
49
// Run client - this will show login, connect, and start game
50
client
.run();
51
52
return
0;
53
}
Client.hpp
Client
R-Type client application.
Definition
Client.hpp:40
main
int main(int argc, char **argv)
Definition
main.cpp:30
printBanner
void printBanner(const std::string &host, uint16_t port)
Definition
main.cpp:23
parseCommandLine
void parseCommandLine(int argc, char **argv, std::string &host, uint16_t &port)
Definition
main.cpp:13
client
Definition
ClientGameRules.hpp:15
client
main.cpp
Generated by
1.9.8