Started implementing a hashmap that includes tags for the all the game
objects.
This commit is contained in:
1 parent
6b1197bfca
commit
20f476c4ab
7 files changed
+196
-3
No files matched your search
@@ -0,0 +1,13 @@
|
||||
#ifndef HASHMAP_H
|
||||
#define HASHMAP_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void init_hashmap();
|
||||
int32_t add_object_to_map(const char *key);
|
||||
int32_t get_object_index(const char *key);
|
||||
void delete_object_from_map(const char *key);
|
||||
void destroy_hashmap();
|
||||
|
||||
#endif // !HASHMAP_H
|
||||
@@ -2,12 +2,20 @@
|
||||
#define OBJECT_STORE_H
|
||||
|
||||
#include "Renderer.h"
|
||||
#include "SDL_events.h"
|
||||
|
||||
typedef void (*EventHandlerPtr)(const SDL_Event *event, void *object);
|
||||
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);
|
||||
void add_object_to_store(ObjectStore *os, const char *object_tag,
|
||||
EventHandlerPtr eh, UpdateFuncPtr uf,
|
||||
RenderFuncPtr rf);
|
||||
void handle_all_object_events(ObjectStore *os);
|
||||
void update_all_objects(ObjectStore *os);
|
||||
void render_all_objects(ObjectStore *os);
|
||||
void remove_object_from_store(ObjectStore *os, const char *object_tag);
|
||||
|
||||
#endif // !OBJECT_STORE_H
|
||||
@@ -3,4 +3,8 @@
|
||||
|
||||
#define INTERNAL static
|
||||
|
||||
#define MAX_OBJ_COUNT 10000
|
||||
#define HASH_PRIME_01 1987
|
||||
#define HASH_PRIME_02 7919
|
||||
|
||||
#endif // !CONSTANTS_H
|
||||
Reference in new issue
Block a user