Skip to content
This repository has been archived by the owner on May 19, 2024. It is now read-only.

Commit

Permalink
Added placeholder state, minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
xfnty committed Jun 27, 2023
1 parent 18c8df9 commit d58fac4
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/game/states/intro.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@

#include <raylib.h>

#include <system/strid.h>
#include "system/strid.h"
#define SCOPE_NAME "intro"
#include <system/logging.h>
#include "system/logging.h"

#include <game/game.h>
#include "game/game.h"
#include "game/states/placeholder.h"


typedef struct intro_state_s {
Expand All @@ -31,12 +32,12 @@ static void _intro_state_update(game_state_t* state, game_t* game, update_contex

float progress = (GetTime() - intro->start_time) / 1.5;
if (GetKeyPressed() != 0 || progress >= 1)
progress = 1;
game_switch_state(game, placeholder_state_create());

int size = 40;
Rectangle rect = (Rectangle) {
.x = (game->canvas.texture.width - size) / 2,
.y = (game->canvas.texture.height - size) / 2,
.x = (game->canvas.texture.width - size) / 2.0f,
.y = (game->canvas.texture.height - size) / 2.0f,
.width = size,
.height = size
};
Expand Down
46 changes: 46 additions & 0 deletions src/game/states/placeholder.c
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
};
}
10 changes: 10 additions & 0 deletions src/game/states/placeholder.h
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

0 comments on commit d58fac4

Please sign in to comment.