code: basic asset descriptions

isolation_bkp/dynres
Dominik Madarász 2021-01-18 15:46:11 +01:00
parent 872273c42b
commit de5554cecc
6 changed files with 36 additions and 2 deletions

View File

@ -30,6 +30,9 @@ add_library(client-common STATIC
../../common/signal_handling.c
../../common/signal_handling.h
../../common/assets.h
../../common/assets.c
)
add_executable(eco2d-client

View File

@ -29,6 +29,9 @@ add_executable(eco2d-server
../../common/signal_handling.c
../../common/signal_handling.h
../../common/assets.h
../../common/assets.c
)
include_directories(eco2d-server header)

View File

@ -2,13 +2,15 @@
#include "flecs/flecs.h"
#include "flecs/flecs_meta.h"
#include "assets.h"
ECS_STRUCT(Vector2D, {
int16_t x;
int16_t y;
});
ECS_STRUCT(Drawable, {
char filename[80];
uint16_t id;
});
typedef Vector2D Chunk;

View File

@ -136,7 +136,7 @@ uint64_t network_client_create(uint16_t peer_id) {
ecs_entity_t e = ecs_new(world_ecs(), Player);
ecs_add(world_ecs(), e, EcsClient);
ecs_set(world_ecs(), e, ClientInfo, {peer_id});
ecs_set(world_ecs(), e, Drawable, {"player.png"});
ecs_set(world_ecs(), e, Drawable, {ASSET_PLAYER});
librg_entity_track(world_tracker(), e);
librg_entity_owner_set(world_tracker(), e, peer_id);

View File

@ -0,0 +1,5 @@
#include "assets.h"
asset_info assets[] = {
{.id = ASSET_PLAYER, .kind = ASSET_KIND_IMAGE, .filename = "player.png"}
};

View File

@ -0,0 +1,21 @@
#pragma once
#include "system.h"
typedef struct {
uint16_t id;
uint8_t kind;
char* filename;
} asset_info;
enum {
ASSET_KIND_IMAGE,
ASSET_KIND_SOUND,
ASSET_KIND_FORCE_8 = UINT8_MAX,
};
enum {
ASSET_PLAYER,
ASSET_FORCE_16 = UINT16_MAX,
};
extern asset_info assets[];