transfered from codeberg
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
#include "game_initializer.h"
|
||||
|
||||
#include "display.h"
|
||||
#include "performance.h"
|
||||
#include "player.h"
|
||||
#include "world.h"
|
||||
#include "function_success.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
uint8_t create_game(struct world_struct** world,
|
||||
struct player_struct** player)
|
||||
{
|
||||
(void)InitWindow(screen_width,
|
||||
screen_height,
|
||||
"Enter The Fog");
|
||||
|
||||
if (!function_success(create_player(player),
|
||||
"Failed to create player in game_initializer"))
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (!function_success(create_world(world),
|
||||
"Failed to create world in game_initializer"))
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
(void)SetTargetFPS(framerate_limit);
|
||||
(void)DisableCursor();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef game_initializer_h
|
||||
#define game_initializer_h
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct world_struct;
|
||||
struct player_struct;
|
||||
|
||||
/**
|
||||
* @brief Initializes the game by creating the world and player, setting up the window,
|
||||
* and configuring initial game settings like framerate and cursor visibility.
|
||||
*
|
||||
* This function is responsible for setting up the core elements of the game, including:
|
||||
* - Initializing the game window with the specified dimensions and title.
|
||||
* - Creating the player using the `create_player` function.
|
||||
* - Creating the world using the `create_world` function.
|
||||
* - Configuring the framerate limit for the game loop.
|
||||
* - Disabling the cursor for a more immersive experience.
|
||||
*
|
||||
* If any of the initialization steps fail, the function will return an error code
|
||||
* (`EXIT_FAILURE`). Otherwise, it returns `EXIT_SUCCESS` to indicate successful
|
||||
* initialization.
|
||||
*
|
||||
* @param[out] world A pointer to a pointer of type `struct world_struct`. On success,
|
||||
* it will point to the created world structure.
|
||||
* @param[out] player A pointer to a pointer of type `struct player_struct`. On success,
|
||||
* it will point to the created player structure.
|
||||
*
|
||||
* @return `EXIT_SUCCESS` (0) if the game initialization was successful,
|
||||
* or `EXIT_FAILURE` (1) if any initialization step fails.
|
||||
*/
|
||||
uint8_t create_game(struct world_struct** world, struct player_struct** player);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user