diff --git a/include/config.h b/include/config.h new file mode 100644 index 0000000..7e0fa6c --- /dev/null +++ b/include/config.h @@ -0,0 +1,22 @@ +/* +** EPITECH PROJECT, 2023 +** rpg +** File description: +** config +*/ + +#ifndef CONFIG_H_ + #define CONFIG_H_ + + #define SERVER_IP "142.93.35.112" + #define SERVER_PORT 6060 + #define SERVER_TIMEOUT 2 + + #define DEFAULT_FPS 60 + #define FPS_CAP 3000 + #define DEFAULT_VOLUME 100 + #define DEFAULT_WIDTH 1920 + #define DEFAULT_HEIGHT 1080 + #define DEFAULT_BPP 32 + +#endif /* !CONFIG_H_ */ diff --git a/src/start_game.c b/src/start_game.c index 297ab3b..63f7d61 100644 --- a/src/start_game.c +++ b/src/start_game.c @@ -10,6 +10,7 @@ #include "display.h" #include "events.h" #include "raycasting_functions.h" +#include "config.h" static bool init_keys(game_t *game) { @@ -50,13 +51,13 @@ static bool init_params(game_t *game) if (game->params == NULL) return false; game->params[0] = (params_t){0}; - game->params->volume = 100; - game->params->fps = 60; + game->params->volume = DEFAULT_VOLUME; + game->params->fps = DEFAULT_FPS; game->params->fullscreen = 0; - game->params->resolution = (sfVector2u){1920, 1080}; - game->params->window_size = (sfVector2u){1920, 1080}; - game->params->mode = - (sfVideoMode){.size = {1920, 1080}, .bitsPerPixel = 32}; + game->params->resolution = (sfVector2u){DEFAULT_WIDTH, DEFAULT_HEIGHT}; + game->params->window_size = (sfVector2u){DEFAULT_WIDTH, DEFAULT_HEIGHT}; + game->params->mode = (sfVideoMode){ + .size = {DEFAULT_WIDTH, DEFAULT_HEIGHT}, .bitsPerPixel = DEFAULT_BPP}; return true; } diff --git a/src/utils/create/window.c b/src/utils/create/window.c index b3fe264..1e7c091 100644 --- a/src/utils/create/window.c +++ b/src/utils/create/window.c @@ -7,6 +7,7 @@ #include "game.h" #include "create.h" +#include "config.h" void create_window(game_t *game) { @@ -16,9 +17,9 @@ void create_window(game_t *game) game->window->title, sfClose | sfResize, sfWindowed, NULL); if (game->window->window == NULL) return; - game->window->view = sfView_createFromRect( - (sfFloatRect){.position = {0, 0}, .size = {1920, 1080}}); - sfRenderWindow_setFramerateLimit(game->window->window, 3000); + game->window->view = sfView_createFromRect((sfFloatRect){ + .position = {0, 0}, .size = {DEFAULT_WIDTH, DEFAULT_HEIGHT}}); + sfRenderWindow_setFramerateLimit(game->window->window, FPS_CAP); sfRenderWindow_setVerticalSyncEnabled(game->window->window, true); sfRenderWindow_setView(game->window->window, game->window->view); game->window->song = malloc(sizeof(song_t)); diff --git a/src/utils/network/connection.c b/src/utils/network/connection.c index 4680399..813d7b2 100644 --- a/src/utils/network/connection.c +++ b/src/utils/network/connection.c @@ -9,6 +9,7 @@ #include "game.h" #include "network_functions.h" +#include "config.h" static sfTcpSocket *check_connection(sfTcpSocket *server) { @@ -37,7 +38,8 @@ network_t *connect_to_server(void) network->server = sfTcpSocket_create(); sfTcpSocket_setBlocking(network->server, false); if (sfTcpSocket_connect(network->server, sfIpAddress_fromString( - "142.93.35.112"), 6060, sfSeconds(2)) == sfSocketError) { + SERVER_IP), SERVER_PORT, sfSeconds(SERVER_TIMEOUT)) + == sfSocketError) { write(2, "Connection failed\n", 18); sfTcpSocket_destroy(network->server); free(network);