From e5268813dcbdc0d90a081b2223ebc21749038635 Mon Sep 17 00:00:00 2001 From: nathansmithsmith Date: Fri, 7 Jul 2023 23:10:23 -0600 Subject: Better world --- src/game.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 5 deletions(-) (limited to 'src/game.c') diff --git a/src/game.c b/src/game.c index 2e966f2..bffc6b5 100644 --- a/src/game.c +++ b/src/game.c @@ -4,23 +4,81 @@ void initGame(Game * game) { // Window. InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "Killa Facsista"); + // Assets. + LoadAssets(&game->assets); + // Screen id. game->screenId = SCREEN_GAME; + // Main menu. + initMainMenu(game); + // Camera. initPlayerCamera(&game->playerCamera); - // Ship test. - game->ship = createEntity(ENTITY_ANTIFA); - SetTargetFPS(60); //DisableCursor(); + + // World. + initWorld(&game->world); + + // Debug. + // Add player. + addEntityToWorld( + &game->world, + createEntity(ENTITY_ANTIFA, game) + ); + + // Test entity. + Entity soldato = createEntity(ENTITY_SOLDATO, game); + soldato.position = (Vector3){10.0, 10.0, 10.0}; + addEntityToWorld(&game->world, soldato); + + soldato = createEntity(ENTITY_SOLDATO, game); + soldato.position = (Vector3){20.0, 20.0, 20.0}; + addEntityToWorld(&game->world, soldato); + + soldato = createEntity(ENTITY_SOLDATO, game); + soldato.position = (Vector3){30.0, 30.0, 30.0}; + addEntityToWorld(&game->world, soldato); + + printf("%d\n", removeEntityFromWorld(&game->world, 2)); + printf("%d\n", removeEntityFromWorld(&game->world, 3)); + + soldato = createEntity(ENTITY_SOLDATO, game); + soldato.position = (Vector3){-30.0, -30.0, -30.0}; + addEntityToWorld(&game->world, soldato); + + + puts("v"); + + for (int i = 0; i < game->world.vacantIdsCount; ++i) + printf("%d\n", game->world.vacantIds[i]); + + puts("l"); + + for (int i = 0; i < game->world.lookUpSize; ++i) { + printf("%d\n", game->world.lookUp[i]); + + Entity * e = getEntityFromWorld(game->world, i); + + if (e == NULL) { + puts("null"); + continue; + } + + if (e->id == i) + printf("good %x\n", e->fingerprint); + else + printf("bad %d\n", e->id); + } } void closeGame(Game * game) { - // Close ship test. - closeEntity(&game->ship); + unloadAssets(&game->assets); + freeWorld(&game->world); + // Close window last. CloseWindow(); } -- cgit v1.2.3