diff --git a/assets/config.toy b/assets/main.toy similarity index 100% rename from assets/config.toy rename to assets/main.toy diff --git a/source/main.c b/source/main.c index ecac0e5..83724a1 100644 --- a/source/main.c +++ b/source/main.c @@ -89,7 +89,7 @@ void unloadPlayerData(PlayerData player) { int main() { //example Toy controlling the window stuff int size = 0; - const char* source = (char*)readFile("assets/config.toy", &size); + const char* source = (char*)readFile("assets/main.toy", &size); if (!source) { fprintf(stderr, "File read error: %d\n", size); @@ -152,7 +152,7 @@ int main() { //draw the player DrawTextureRec(player.texture, player.rect, player.position, WHITE); - drawMonsterPool(&vm); + drawMonsters(&vm); DrawFPS(0,0); EndDrawing(); diff --git a/source/monster.c b/source/monster.c index 2dab512..c706c48 100644 --- a/source/monster.c +++ b/source/monster.c @@ -205,8 +205,15 @@ void freeMonsterObjectPool(Toy_VM* vm) { monsterArray = Toy_resizeArray(monsterArray, 0); } -void drawMonsterPool(Toy_VM* vm) { +void drawMonsters(Toy_VM* vm) { (void)vm; + + //check for initialization + if (spriteTable == NULL || monsterArray == NULL) { + fprintf(stderr, TOY_CC_ERROR "ERROR: Object pool for monster system hasn't been initialized" TOY_CC_RESET "\n"); + return; + } + for (unsigned int i = 0; i < monsterArray->count; i++) { MonsterData* monster = (MonsterData*)TOY_VALUE_AS_OPAQUE(monsterArray->data[i]); diff --git a/source/monster.h b/source/monster.h index 9be1af8..9dadd58 100644 --- a/source/monster.h +++ b/source/monster.h @@ -6,4 +6,4 @@ void initMonsterObjectPool(Toy_VM* vm); void freeMonsterObjectPool(Toy_VM* vm); -void drawMonsterPool(Toy_VM* vm); +void drawMonsters(Toy_VM* vm);