Game stage stub

This commit is contained in:
2025-09-25 21:36:10 +02:00
parent 3672ca6450
commit f2fc5180d0
2 changed files with 56 additions and 1 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ static World *test_world;
World *
_make_test_World ()
{
World *self = World_load_from_path ("res/test_map_2.png");
World *self = World_load_from_path ("res/test_map.png");
/* TODO: add players and so on. That will be in GameState,
though. Or GameData. */
+55
View File
@@ -0,0 +1,55 @@
/*
LibreFront --- an OpenFront clone
Copyright (C) 2025 Adrien Jaguenet
Copyright (C) 2025 Emil Kosz
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/*
A GameStage is basically like a scene in traditional ECS-style game
engines.
*/
/* https://www.studyplan.dev/sdl2/sdl2-user-events */
#pragma once
#include <glib-2.0/glib.h>
#include <client/gfx_context.h>
typedef struct EventHandler
{
int priority;
void *callback_data;
gboolean (*callback) (SDL_Event *, void *);
} EventHandler;
typedef struct GameStage
{
GList *event_handlers;
void *data;
void (*on_enter) (struct GameStage *);
void (*on_update) (struct GameStage *);
void (*on_render) (struct GameStage *, GfxContext *);
void (*on_exit) (struct GameStage *);
void (*free) (struct GameStage *);
} GameStage;