diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d7eaa3..2a9ca57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,11 @@ project(eco2d) set(CMAKE_C_STANDARD 11) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}) +include_directories(eco2d-cli code/vendors code/common) include_directories(eco2d-client code/vendors code/common) include_directories(eco2d-server code/vendors code/common) diff --git a/code/apps/client/CMakeLists.txt b/code/apps/client/CMakeLists.txt index e0c81a8..cdb3a75 100644 --- a/code/apps/client/CMakeLists.txt +++ b/code/apps/client/CMakeLists.txt @@ -19,16 +19,33 @@ if (NOT raylib_FOUND) endif() endif() -add_executable(eco2d-client - source/main.c +add_library(client-common STATIC source/network.c - source/renderer.c source/game.c - header/renderer.h header/network.h + header/renderer.h header/game.h ) +add_executable(eco2d-client + source/main.c + source/renderer_raylib.c +) + +add_executable(eco2d-cli + source/main.c + source/renderer_text.c +) + include_directories(header/) -target_link_libraries(eco2d-client raylib) +target_link_libraries(eco2d-client raylib client-common) +target_link_libraries(eco2d-cli client-common) + +if (WIN32) + target_link_libraries(eco2d-cli winmm) + target_link_libraries(eco2d-client winmm) +elseif (UNIX) + target_link_libraries(eco2d-cli pthread m dl) + target_link_libraries(eco2d-client pthread m dl) +endif() diff --git a/code/apps/client/header/game.h b/code/apps/client/header/game.h index f026fb6..cbf1db6 100644 --- a/code/apps/client/header/game.h +++ b/code/apps/client/header/game.h @@ -1,7 +1,9 @@ #pragma once +#include "system.h" void game_init(); void game_shutdown(); +uint8_t game_is_running(); void game_input(); void game_update(); diff --git a/code/apps/client/header/network.h b/code/apps/client/header/network.h index 6f70f09..0647295 100644 --- a/code/apps/client/header/network.h +++ b/code/apps/client/header/network.h @@ -1 +1,2 @@ #pragma once +#include "system.h" diff --git a/code/apps/client/header/renderer.h b/code/apps/client/header/renderer.h index a4df5ea..42998c0 100644 --- a/code/apps/client/header/renderer.h +++ b/code/apps/client/header/renderer.h @@ -1,6 +1,8 @@ #pragma once +#include "system.h" void gfx_init(); void gfx_shutdown(); +uint8_t gfx_is_running(); void gfx_render(); diff --git a/code/apps/client/source/game.c b/code/apps/client/source/game.c index 4f1bc34..bf4e0cb 100644 --- a/code/apps/client/source/game.c +++ b/code/apps/client/source/game.c @@ -9,6 +9,9 @@ void game_shutdown() { gfx_shutdown(); } +uint8_t game_is_running() { + return gfx_is_running(); +} void game_input() { diff --git a/code/apps/client/source/main.c b/code/apps/client/source/main.c index 6fbd72c..b3c6bc8 100644 --- a/code/apps/client/source/main.c +++ b/code/apps/client/source/main.c @@ -1,10 +1,12 @@ +#define ZPL_IMPL +#include "zpl.h" #include "game.h" int main(void) { game_init(); - while (!WindowShouldClose()) + while (game_is_running()) { game_input(); game_update(); diff --git a/code/apps/client/source/renderer.c b/code/apps/client/source/renderer_raylib.c similarity index 87% rename from code/apps/client/source/renderer.c rename to code/apps/client/source/renderer_raylib.c index 8438dd9..87325cf 100644 --- a/code/apps/client/source/renderer.c +++ b/code/apps/client/source/renderer_raylib.c @@ -1,4 +1,3 @@ -#include "system.h" #include "renderer.h" #include "raylib.h" @@ -14,6 +13,10 @@ void gfx_shutdown() { CloseWindow(); } +uint8_t gfx_is_running() { + return !WindowShouldClose(); +} + void gfx_render() { BeginDrawing(); ClearBackground(RAYWHITE); diff --git a/code/apps/client/source/renderer_text.c b/code/apps/client/source/renderer_text.c new file mode 100644 index 0000000..a06aee1 --- /dev/null +++ b/code/apps/client/source/renderer_text.c @@ -0,0 +1,18 @@ +#include "renderer.h" +#include + +void gfx_init() { + printf("eco2d-cli\n"); +} + +void gfx_shutdown() { + printf("Bye!\n"); +} + +uint8_t gfx_is_running() { + +} + +void gfx_render() { + // TODO +}