Added Game project that will contain the game + game framework
This commit is contained in:
66
Game/dllmain.cpp
Normal file
66
Game/dllmain.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#include <cstdio>
|
||||
#include <windows.h> // TODO: remove because our dll should not be platform dependant
|
||||
|
||||
#include <Entity/Entity.h>
|
||||
#include <Entity/EntityManager.h>
|
||||
|
||||
// Test code
|
||||
namespace Game
|
||||
{
|
||||
struct Door
|
||||
{
|
||||
DECLARE_ENTITY()
|
||||
bool IsOpened;
|
||||
};
|
||||
DEFINE_ENTITY(Door);
|
||||
|
||||
struct Rock
|
||||
{
|
||||
DECLARE_ENTITY()
|
||||
int Health;
|
||||
};
|
||||
DEFINE_ENTITY(Rock);
|
||||
|
||||
} // namespace Game
|
||||
|
||||
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
||||
{
|
||||
using namespace Game;
|
||||
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
{
|
||||
// Entity Use case
|
||||
InitEntityManager();
|
||||
auto& manager = GetEntityManager();
|
||||
Door* door = MakeEntity<Door>(manager, 10.0f, 2.0f);
|
||||
door->IsOpened = true;
|
||||
|
||||
Entity* ent = door->Base;
|
||||
Door* stillDoor = DownCast<Door>(ent);
|
||||
Assert(door == stillDoor);
|
||||
|
||||
Rock* rock = MakeEntity<Rock>(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);
|
||||
|
||||
// Have to manually free for now because im not using arenas or anything
|
||||
free(door->Base);
|
||||
free(door);
|
||||
free(rock->Base);
|
||||
free(rock);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case DLL_THREAD_ATTACH: break;
|
||||
case DLL_THREAD_DETACH: break;
|
||||
case DLL_PROCESS_DETACH: break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
Reference in New Issue
Block a user