#include #include // TODO: remove because our dll should not be platform dependant #undef min #undef max #include #include #include #include #include #include #include GameState* gGameState = nullptr; GameState* GetGameState() { return gGameState; } // Test code namespace Game { struct Door { DECLARE_ENTITY() bool IsOpened; }; DEFINE_ENTITY(Door); struct Rock { DECLARE_ENTITY() int Health; }; DEFINE_ENTITY(Rock); } // namespace Game extern "C" JULIET_API void __cdecl GameShutdown() { printf("Shutting down game...\n"); using namespace Juliet; using namespace Game; ShutdownEntityManager(); } extern "C" JULIET_API void __cdecl GameUpdate(Juliet::GameData* params, [[maybe_unused]] float deltaTime) { using namespace Juliet; using namespace Game; gGameState = params->GameState; if (!gGameState) { Arena* gameStateArena = ArenaAllocate({ .ReserveSize = Megabytes(1) } JULIET_DEBUG_PARAM("Game Total Arena")); auto* gameState = ArenaPushStruct(gameStateArena); gGameState = params->GameState = gameState; gameState->TotalArena = gameStateArena; gameState->TotalTime = 0.0f; gameState->Score = 0; printf("Game Arena Allocated: %p\n", static_cast(gameState)); // Bootstrap world auto* worldArena = ArenaAllocate({ .ReserveSize = Megabytes(1) } JULIET_DEBUG_PARAM("World Arena")); World* world = ArenaPushStruct(worldArena JULIET_DEBUG_PARAM("World")); gameState->World = world; gameState->World->WorldArena = worldArena; // Entity Use case InitEntityManager(gameState->World); auto& manager = GetEntityManager(); Door* door = MakeEntity(manager, 10.0f, 2.0f); door->IsOpened = true; Entity* ent = door->Base; [[maybe_unused]] Door* stillDoor = DownCast(ent); Assert(door == stillDoor); Rock* rock = MakeEntity(manager, 1.f, 2.f); rock->Health = 100; Assert(door->Base != rock->Base); printf("Door is %s\n", door->IsOpened ? "Opened" : "Closed"); printf("Rock has %d health points\n", rock->Health); } // printf("Updating game...\n"); }