Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions include/config.h
Original file line number Diff line number Diff line change
@@ -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_ */
13 changes: 7 additions & 6 deletions src/start_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "display.h"
#include "events.h"
#include "raycasting_functions.h"
#include "config.h"

static bool init_keys(game_t *game)
{
Expand Down Expand Up @@ -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;
}

Expand Down
7 changes: 4 additions & 3 deletions src/utils/create/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "game.h"
#include "create.h"
#include "config.h"

void create_window(game_t *game)
{
Expand All @@ -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));
Expand Down
4 changes: 3 additions & 1 deletion src/utils/network/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "game.h"
#include "network_functions.h"
#include "config.h"

static sfTcpSocket *check_connection(sfTcpSocket *server)
{
Expand Down Expand Up @@ -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);
Expand Down
Loading