diff --git a/assets_src/gfx/weapons-rigged.cdr b/assets_src/gfx/weapons-rigged.cdr index 37ee430..6bd868f 100644 Binary files a/assets_src/gfx/weapons-rigged.cdr and b/assets_src/gfx/weapons-rigged.cdr differ diff --git a/src/packages/game/IZ_app.c b/src/packages/game/IZ_app.c index 220228e..64e3aef 100644 --- a/src/packages/game/IZ_app.c +++ b/src/packages/game/IZ_app.c @@ -120,7 +120,7 @@ IZ_AppResult IZ_AppRun(struct IZ_App* app, u8 argc, const char* argv[]) { char asset_dir[255]; IZ_AssetResolveDir("weapon-operator", asset_dir); - u16 sprite_slot_index = IZ_VideoGetNextFreeSpriteSlot(&app->video_state); + u16 sprite_slot_index = IZ_VideoGetNextFreeSpriteSlot(&app->video_state, IZ_VIDEO_SPRITE_PRIORITY_MEDIUM); IZ_VideoLoadSprite(&app->video_state, (IZ_VideoLoadSpriteParams) { .dir = asset_dir, .filename = "sprite.svg", @@ -130,7 +130,7 @@ IZ_AppResult IZ_AppRun(struct IZ_App* app, u8 argc, const char* argv[]) { app->video_state.active_sprites[sprite_slot_index].sprite.position = (IZ_Vector2D) { 100.f, 100.f }; IZ_AssetResolveDir("weapon-specialist", asset_dir); - sprite_slot_index = IZ_VideoGetNextFreeSpriteSlot(&app->video_state); + sprite_slot_index = IZ_VideoGetNextFreeSpriteSlot(&app->video_state, IZ_VIDEO_SPRITE_PRIORITY_MEDIUM); IZ_VideoLoadSprite(&app->video_state, (IZ_VideoLoadSpriteParams) { .dir = asset_dir, .filename = "sprite.svg", diff --git a/src/packages/game/core/IZ_entity.c b/src/packages/game/core/IZ_entity.c index b948af3..ba3791b 100644 --- a/src/packages/game/core/IZ_entity.c +++ b/src/packages/game/core/IZ_entity.c @@ -1 +1,8 @@ #include "IZ_entity.h" + +IZ_Entity* IZ_EntityNew(IZ_Entity attrs) { + // TODO let pool allocate memory for entity instead of malloc! + IZ_Entity* new_entity = (IZ_Entity*) malloc(sizeof(IZ_Entity)); + + return new_entity; +} diff --git a/src/packages/game/core/IZ_entity.h b/src/packages/game/core/IZ_entity.h index f5cf831..61dc580 100644 --- a/src/packages/game/core/IZ_entity.h +++ b/src/packages/game/core/IZ_entity.h @@ -1,11 +1,16 @@ #ifndef IZ_ENTITY_H #define IZ_ENTITY_H +#include #include "../geometry/IZ_vector2d.h" typedef struct { IZ_Vector2D pos; + + IZ_Vector2D speed; // TODO object appearance (sprite, sprites contain bounding boxes, collisions contain bounding boxes) } IZ_Entity; +IZ_Entity* IZ_EntityNew(IZ_Entity); + #endif diff --git a/src/packages/game/core/IZ_object.h b/src/packages/game/core/IZ_object.h index 62de6d3..5208506 100644 --- a/src/packages/game/core/IZ_object.h +++ b/src/packages/game/core/IZ_object.h @@ -9,7 +9,6 @@ typedef struct { IZ_Entity as_entity; IZ_Rect collision_rect; - IZ_Vector2D speed; } IZ_Object; #endif diff --git a/src/packages/game/memory/memory.test.c b/src/packages/game/memory/memory.test.c index 99175d9..c2f191a 100644 --- a/src/packages/game/memory/memory.test.c +++ b/src/packages/game/memory/memory.test.c @@ -109,7 +109,7 @@ spec("memory") { it("deallocates old items to make way for new ones when the memory is full") { IZ_PoolInitialize(&pool, sizeof(u32)); - IZ_PoolAllocate(&pool, (IZ_PoolAllocationArgs){ + void* p1 = IZ_PoolAllocate(&pool, (IZ_PoolAllocationArgs){ .size = sizeof(u16), .priority = 0, .timestamp = 0, @@ -117,18 +117,48 @@ spec("memory") { IZ_PoolAllocate(&pool, (IZ_PoolAllocationArgs){ .size = sizeof(u8), .priority = 0, - .timestamp = 0, + .timestamp = 1, }); IZ_PoolAllocate(&pool, (IZ_PoolAllocationArgs){ .size = sizeof(u8), .priority = 0, - .timestamp = 0, + .timestamp = 2, }); - IZ_PoolAllocate(&pool, (IZ_PoolAllocationArgs){ + + void* p2 = IZ_PoolAllocate(&pool, (IZ_PoolAllocationArgs){ .size = sizeof(u8), .priority = 0, - .timestamp = 0, + .timestamp = 3, }); + + check( + p1 == p2, + "Old memory not properly deallocated." + ); + + void* p3 = IZ_PoolAllocate(&pool, (IZ_PoolAllocationArgs){ + .size = sizeof(u8), + .priority = 0, + .timestamp = 4, + }); + + // FIXME here onwards + + check( + p3 == p2 + sizeof(u8), + "Free memory not properly utilized." + ); + + void* p4 = IZ_PoolAllocate(&pool, (IZ_PoolAllocationArgs){ + .size = sizeof(u8), + .priority = 0, + .timestamp = 5, + }); + + check( + p4 == p3 + sizeof(u8), + "Free memory not properly utilized." + ); } }