restructure the project, again

isolation_bkp/dynres
Dominik Madarász 2021-05-12 17:50:30 +02:00
parent 884f10e6ec
commit fb5c2fae86
44 changed files with 40 additions and 48 deletions

View File

@ -10,13 +10,14 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_compile_options(/MP /W4)
add_compile_options(/MP /W4 /nologo)
endif()
include_directories(code/common code/vendors code/vendors/flecs)
include(cmake/FindRaylib.cmake)
add_subdirectory(code/modules)
add_subdirectory(code/common)
add_subdirectory(code/vendors)
add_subdirectory(code/game)

View File

@ -8,11 +8,6 @@ function(link_system_libs target_name)
endif()
endfunction()
macro(populate_pkt_srcs)
file(GLOB PKT_SRCS ../common/packets/*.h ../common/packets/*.c)
endmacro()
macro(use_cxx11)
if (CMAKE_VERSION VERSION_LESS "3.1")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")

View File

@ -1,10 +0,0 @@
file(GLOB SRCS *.h *.c packets/*.h world/*.h)
set(SRCS ${SRCS}
world/blocks.c
world/perlin.c
world/world.c
world/worldgen/worldgen_test.c
)
include_directories(../modules . world)
add_library(eco2d-common STATIC ${SRCS})

View File

@ -1,4 +0,0 @@
#pragma once
#define ATLAS_STRIDE 10
#define ATLAS_XY(x,y) ((y*ATLAS_STRIDE)+x)

View File

@ -1,10 +0,0 @@
#include "atlas_shared.h"
#include "world/blocks.h"
static block blocks[] = {
{.tex_id = ATLAS_XY(0, 0), .name = "base-ground", .flags = 0, .kind = BLOCK_KIND_GROUND, .biome = 0, .symbol = '.'},
{.tex_id = ATLAS_XY(1, 0), .name = "base-wall", .flags = BLOCK_FLAG_COLLISION, .kind = BLOCK_KIND_WALL, .biome = 0, .symbol = '#'},
{.tex_id = ATLAS_XY(2, 0), .name = "base-hill", .flags = BLOCK_FLAG_COLLISION, .kind = BLOCK_KIND_HILL, .biome = 0, .symbol = '^'},
{.tex_id = ATLAS_XY(3, 0), .name = "base-hill-snow", .flags = BLOCK_FLAG_COLLISION, .kind = BLOCK_KIND_HILL_SNOW, .biome = 0, .symbol = '*'},
{.tex_id = ATLAS_XY(0, 1), .name = "base-water", .flags = BLOCK_FLAG_COLLISION, .kind = BLOCK_KIND_WATER, .biome = 0, .symbol = '~'},
};

View File

@ -1,24 +1,38 @@
include(FindRaylib.cmake)
file(GLOB PKT_SRCS ../game/header/packets/*.h ../game/source/packets/*.c)
populate_pkt_srcs()
add_executable(eco2d
source/platform_raylib.c
source/main.c
source/network.c
source/game.c
source/game.c
source/camera.c
source/world_view.c
source/prediction.c
source/assets.c
source/compress.c
source/entity.c
source/entity_view.c
source/packet.c
source/player.c
source/signal_handling.c
source/utils/options.c
header/network.h
source/world/blocks.c
source/world/perlin.c
source/world/world.c
source/world/worldgen/worldgen_test.c
${PKT_SRCS}
)
target_compile_definitions(eco2d PRIVATE CLIENT)
include_directories(header ../modules)
target_link_libraries(eco2d raylib cwpack eco2d-common eco2d-modules flecs-bundle)
target_link_libraries(eco2d raylib cwpack eco2d-modules flecs-bundle)
link_system_libs(eco2d)

View File

@ -12,7 +12,6 @@ typedef enum {
uint8_t blocks_find(uint32_t biome, uint32_t kind);
char *blocks_get_name(uint8_t id);
uint8_t blocks_get_tex_id(uint8_t id);
char blocks_get_symbol(uint8_t id);
uint32_t blocks_get_flags(uint8_t id);
uint32_t blocks_get_biome(uint8_t id);

View File

@ -2,7 +2,7 @@
#include "flecs/flecs.h"
#include "flecs/flecs_meta.h"
#include "librg.h"
#include "world.h"
#include "world/world.h"
#include "modules/general.h"
#include "modules/controllers.h"

View File

@ -3,7 +3,7 @@
#include "flecs/flecs.h"
#include "flecs/flecs_meta.h"
#include "librg.h"
#include "world.h"
#include "world/world.h"
#include "modules/general.h"
#include "modules/controllers.h"

View File

@ -1,23 +1,25 @@
#define ZPL_PICO
#include "zpl.h"
#include "world/blocks.h"
// todo: csv parsing + utils
#include "raylib.h"
#define BLOCKS_COUNT (sizeof(blocks)/sizeof(block))
typedef struct {
uint8_t tex_id;
char *name;
uint32_t flags;
uint32_t kind;
uint32_t biome;
char symbol;
// NOTE(zaklaus): viewer data
Image tex;
} block;
#include "blocks_list.c"
uint8_t blocks_find(uint32_t biome, uint32_t kind) {
for (int i=0; i<BLOCKS_COUNT; i++) {
for (uint32_t i=0; i<BLOCKS_COUNT; i++) {
if (blocks[i].biome == biome && blocks[i].kind == kind)
return i;
}
@ -28,10 +30,6 @@ char *blocks_get_name(uint8_t id) {
return blocks[id].name;
}
uint8_t blocks_get_tex_id(uint8_t id) {
return blocks[id].tex_id;
}
char blocks_get_symbol(uint8_t id) {
return blocks[id].symbol;
}

View File

@ -0,0 +1,9 @@
#include "world/blocks.h"
static block blocks[] = {
{.name = "base-ground", .flags = 0, .kind = BLOCK_KIND_GROUND, .biome = 0, .symbol = '.'},
{.name = "base-wall", .flags = BLOCK_FLAG_COLLISION, .kind = BLOCK_KIND_WALL, .biome = 0, .symbol = '#'},
{.name = "base-hill", .flags = BLOCK_FLAG_COLLISION, .kind = BLOCK_KIND_HILL, .biome = 0, .symbol = '^'},
{.name = "base-hill-snow", .flags = BLOCK_FLAG_COLLISION, .kind = BLOCK_KIND_HILL_SNOW, .biome = 0, .symbol = '*'},
{.name = "base-water", .flags = BLOCK_FLAG_COLLISION, .kind = BLOCK_KIND_WATER, .biome = 0, .symbol = '~'},
};

View File

@ -5,7 +5,7 @@
#include "modules/physics.h"
#include "world/world.h"
#include "entity_view.h"
#include "worldgen/worldgen.h"
#include "world/worldgen/worldgen.h"
#include "platform.h"
#include "packets/pkt_send_librg_update.h"

View File

@ -1,3 +1,3 @@
file(GLOB MODULES modules/*.h source/*.c)
add_library(eco2d-modules STATIC ${MODULES})
include_directories(.)
include_directories(. ../game/header)