Started working on the ObjectStore

This commit is contained in:
abdelrahman committed 2022-09-11 01:20:16 +01:00
1 parent 33066b381e
commit 6b1197bfca
3 files changed
+17 -2

No files matched your search

+1
View File
@@ -48,6 +48,7 @@ install(FILES
include/Game.h include/Game.h
include/Window.h include/Window.h
include/Renderer.h include/Renderer.h
include/ObjectStore.h
CONFIGURATIONS Release CONFIGURATIONS Release
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
) )
+13
View File
@@ -0,0 +1,13 @@
#ifndef OBJECT_STORE_H
#define OBJECT_STORE_H
#include "Renderer.h"
typedef void (*UpdateFuncPtr)(float delta, void *object);
typedef void (*RenderFuncPtr)(Renderer *renderer, void *object);
typedef struct object_store ObjectStore;
void add_object_to_store(ObjectStore *os, UpdateFuncPtr uf, RenderFuncPtr rf);
#endif // !OBJECT_STORE_H
+3 -2
View File
@@ -1,5 +1,6 @@
#include "Game.h" #include "Game.h"
#include "SDL.h" #include "SDL.h"
#include "SDL_error.h"
#include "SDL_events.h" #include "SDL_events.h"
#include "SDL_pixels.h" #include "SDL_pixels.h"
#include "Window.h" #include "Window.h"
@@ -21,7 +22,7 @@ bool init_game(const char *game_name, int window_width, int window_height,
bool full_screen) { bool full_screen) {
if (SDL_Init(SDL_INIT_EVERYTHING) != 0) { if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
#ifdef DEBUG_ENGINE #ifdef DEBUG_ENGINE
printf("Failed to initialise game\n"); printf("Failed to initialise SDL. Error: %s\n", SDL_GetError());
#endif /* DEBUG_ENGINE */ #endif /* DEBUG_ENGINE */
return false; return false;
@@ -30,7 +31,7 @@ bool init_game(const char *game_name, int window_width, int window_height,
if (!init_window(&(Game.window), game_name, window_width, window_height, if (!init_window(&(Game.window), game_name, window_width, window_height,
full_screen)) { full_screen)) {
#ifdef DEBUG_ENGINE #ifdef DEBUG_ENGINE
printf("Failed to initialise game\n"); printf("Failed to initialise window\n");
#endif /* DEBUG_ENGINE */ #endif /* DEBUG_ENGINE */
return false; return false;