diff --git a/CMakeLists.txt b/CMakeLists.txt index 348f477..1e4b174 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,10 @@ project(eco2d) include(cmake/utils.cmake) set(CMAKE_C_STANDARD 11) -setup_build_dirs() +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(code/common code/vendors code/vendors/flecs) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 6e3aaf7..e354f3c 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -7,10 +7,3 @@ function(link_system_libs target_name) target_link_libraries(${target_name} pthread m dl atomic) endif() endfunction() - -function(setup_build_dirs) - 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}) -endfunction() diff --git a/code/apps/server/modules/source/physics.c b/code/apps/server/modules/source/physics.c index d851aa0..e9c6fe5 100644 --- a/code/apps/server/modules/source/physics.c +++ b/code/apps/server/modules/source/physics.c @@ -1,7 +1,14 @@ #include "modules/physics.h" void MoveWalk(ecs_iter_t *it) { + Position *p = ecs_column(it, Position, 1); + Velocity *v = ecs_column(it, Velocity, 2); + for (int i = 0; i < it->count; i++) { + // TODO: handle collisions + p[i].x += v[i].x * it->delta_time; + p[i].y += v[i].y * it->delta_time; + } } void PhysicsImport(ecs_world_t *ecs) { diff --git a/code/apps/server/source/main.c b/code/apps/server/source/main.c index 5f785bd..831b828 100644 --- a/code/apps/server/source/main.c +++ b/code/apps/server/source/main.c @@ -75,6 +75,7 @@ int main(int argc, char** argv) { ECS_IMPORT(world_ecs(), FlecsSystemsCivetweb); ecs_set(world_ecs(), 0, EcsDashServer, {.port = 27001}); + ecs_set_target_fps(world_ecs(), 60); } zpl_printf("[INFO] Initializing network...\n"); diff --git a/code/apps/server/source/world/world.c b/code/apps/server/source/world/world.c index 7fc4fc7..5abee96 100644 --- a/code/apps/server/source/world/world.c +++ b/code/apps/server/source/world/world.c @@ -2,9 +2,6 @@ #include "librg.h" #include "modules/general.h" #include "world/world.h" -#include "flecs/flecs.h" -#include "flecs/flecs_dash.h" -#include "flecs/flecs_systems_civetweb.h" typedef struct { uint8_t *data; @@ -73,16 +70,7 @@ int32_t world_init(int32_t seed, uint16_t block_size, uint16_t chunk_size, uint1 world.ecs = ecs_init(); ecs_set_entity_range(world.ecs, 0, UINT32_MAX); - ecs_set_threads(world.ecs, 4); - ecs_set_target_fps(world.ecs, 60); - - /* server dashboard */ - { - ECS_IMPORT(world_ecs(), FlecsDash); - ECS_IMPORT(world_ecs(), FlecsSystemsCivetweb); - - ecs_set(world_ecs(), 0, EcsDashServer, {.port = 27001}); - } + //ecs_set_threads(world.ecs, 4); world.tracker = librg_world_create();