This repository has been archived by the owner on May 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added placeholder state, minor changes
- Loading branch information
Showing
3 changed files
with
63 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <game/states/placeholder.h> | ||
|
||
#include <assert.h> | ||
#include <math.h> | ||
|
||
#include <raylib.h> | ||
|
||
#include "system/strid.h" | ||
#define SCOPE_NAME "placeholder" | ||
#include "system/logging.h" | ||
|
||
#include "game/game.h" | ||
|
||
|
||
typedef struct placeholder_state_s { | ||
int _; | ||
} placeholder_state_t; | ||
|
||
static void _placeholder_state_enter(game_state_t* state, game_t* game) { | ||
state->data = malloc(sizeof(placeholder_state_t)); | ||
assert(state->data); | ||
placeholder_state_t* placeholder = (placeholder_state_t*)state->data; | ||
|
||
*placeholder = (placeholder_state_t) {0}; | ||
} | ||
|
||
static void _placeholder_state_update(game_state_t* state, game_t* game, update_context_t ctx) { | ||
placeholder_state_t* placeholder = (placeholder_state_t*)state->data; | ||
|
||
if (IsKeyPressed(KEY_ESCAPE)) | ||
game->is_running = false; | ||
} | ||
|
||
static void _placeholder_state_exit(game_state_t* state, game_t* game) { | ||
free(state->data); | ||
} | ||
|
||
game_state_t placeholder_state_create() { | ||
return (game_state_t) { | ||
.name = strid_get_strid(SCOPE_NAME), | ||
.data = NULL, | ||
.on_enter = _placeholder_state_enter, | ||
.on_update = _placeholder_state_update, | ||
.on_exit = _placeholder_state_exit | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef GAME_STATES_PLACEHOLDER_H | ||
#define GAME_STATES_PLACEHOLDER_H | ||
|
||
|
||
typedef struct game_state_s game_state_t; | ||
|
||
game_state_t placeholder_state_create(); | ||
|
||
|
||
#endif |