updated draft
parent
74f0956b66
commit
ac6b44eb0a
|
@ -9,23 +9,101 @@
|
||||||
typedef int efd_app;
|
typedef int efd_app;
|
||||||
typedef uint16_t efd_entity_type;
|
typedef uint16_t efd_entity_type;
|
||||||
typedef int32_t efd_result;
|
typedef int32_t efd_result;
|
||||||
typedef uint64_t efd_entity;
|
typedef void * efd_world;
|
||||||
|
|
||||||
typedef enum efd_asset_type {
|
|
||||||
// EFD_ASSET_NONE = 0,
|
|
||||||
EFD_ASSET_TEXTURE,
|
|
||||||
EFD_ASSET_ANIMATION,
|
|
||||||
EFD_ASSET_SOUND,
|
|
||||||
EFD_ASSET_FONT,
|
|
||||||
EFD_ASSET_SHADER,
|
|
||||||
EFD_ASSET_COUNT_TYPES,
|
|
||||||
} efd_asset_type;
|
|
||||||
|
|
||||||
// define amount of memeory reserved for???
|
// define amount of memeory reserved for???
|
||||||
// custom data within COMMAND (cli->ser) and SNAPSHOT (ser->cli)
|
// custom data within COMMAND (cli->ser) and SNAPSHOT (ser->cli)
|
||||||
#define EFD_COMMAND_SIZE 64 * 1024
|
#define EFD_COMMAND_SIZE 64 * 1024
|
||||||
#define EFD_SNAPSHOT_SIZE 128 * 1024
|
#define EFD_SNAPSHOT_SIZE 128 * 1024
|
||||||
|
|
||||||
|
#define EFD_TYPE_SHIFT 16
|
||||||
|
#define EFD_ID(type) (((type) << EFD_TYPE_SHIFT) + 1)
|
||||||
|
#define EFD_TYPE(id) ((id - 1) >> EFD_TYPE_SHIFT)
|
||||||
|
#define EFD_END 0
|
||||||
|
|
||||||
|
typedef enum efd_asset_type {
|
||||||
|
EFD_NONE = 0,
|
||||||
|
EFD_TEXTURE,
|
||||||
|
EFD_TEXTURE_ATLAS,
|
||||||
|
EFD_ANIMATION,
|
||||||
|
EFD_SOUND,
|
||||||
|
EFD_FONT,
|
||||||
|
EFD_SHADER,
|
||||||
|
} efd_asset_type;
|
||||||
|
|
||||||
|
typedef enum efd_object_type {
|
||||||
|
EFD_TYPE_NONE,
|
||||||
|
EFD_TYPE_TILE,
|
||||||
|
EFD_TYPE_BLOCK,
|
||||||
|
EFD_TYPE_ENTITY,
|
||||||
|
EFD_TYPE_ITEM,
|
||||||
|
EFD_TYPE_CRAFT,
|
||||||
|
EFD_TYPE_CHUNK,
|
||||||
|
|
||||||
|
EFD_TYPE_TYPE_LAST,
|
||||||
|
EFD_TYPE_TYPE_MAX = 0xFFFF,
|
||||||
|
} efd_object_type;
|
||||||
|
|
||||||
|
typedef enum efd_flags {
|
||||||
|
EFD_FLAG_COLLISION = (1 << 1),
|
||||||
|
EFD_FLAG_HAZARD = (1 << 2),
|
||||||
|
EFD_FLAG_ESSENTIAL = (1 << 3),
|
||||||
|
EFD_FLAG_DESTROY_ON_COLLISION = (1 << 4),
|
||||||
|
EFD_FLAG_AI = (1 << 5),
|
||||||
|
EFD_FLAG_PLAYER = (1 << 6),
|
||||||
|
EFD_FLAG_VEHICLE = (1 << 7),
|
||||||
|
} efd_flags;
|
||||||
|
|
||||||
|
typedef struct efd_asset {
|
||||||
|
efd_asset_type type;
|
||||||
|
int id;
|
||||||
|
const char *path;
|
||||||
|
void *data; /* TODO: make a union */
|
||||||
|
} efd_asset;
|
||||||
|
|
||||||
|
typedef struct efd_tile {
|
||||||
|
int id;
|
||||||
|
int flags;
|
||||||
|
float drag;
|
||||||
|
float friction;
|
||||||
|
} efd_tile;
|
||||||
|
|
||||||
|
typedef struct efd_block {
|
||||||
|
int id;
|
||||||
|
int flags;
|
||||||
|
float bounce;
|
||||||
|
int velx;
|
||||||
|
int vely;
|
||||||
|
} efd_block;
|
||||||
|
|
||||||
|
typedef struct efd_entity {
|
||||||
|
int id;
|
||||||
|
int flags;
|
||||||
|
} efd_entity;
|
||||||
|
|
||||||
|
typedef struct efd_item {
|
||||||
|
int id;
|
||||||
|
const char *t1;
|
||||||
|
const char *t2;
|
||||||
|
} efd_item;
|
||||||
|
|
||||||
|
typedef struct efd_craft_item {
|
||||||
|
int id;
|
||||||
|
int qty;
|
||||||
|
} efd_craft_item;
|
||||||
|
|
||||||
|
typedef struct efd_craft {
|
||||||
|
int producer;
|
||||||
|
int ticks;
|
||||||
|
efd_craft_item *input;
|
||||||
|
efd_craft_item *output;
|
||||||
|
} efd_craft;
|
||||||
|
|
||||||
|
typedef struct efd_tooltip {
|
||||||
|
const char *title;
|
||||||
|
const char *description;
|
||||||
|
} efd_tooltip;
|
||||||
|
|
||||||
typedef struct efd_app_desc {
|
typedef struct efd_app_desc {
|
||||||
const char *name;
|
const char *name;
|
||||||
int debug_ui;
|
int debug_ui;
|
||||||
|
@ -42,6 +120,7 @@ typedef struct efd_app_desc {
|
||||||
int world_seed_random;
|
int world_seed_random;
|
||||||
|
|
||||||
efd_result (*init_cb)();
|
efd_result (*init_cb)();
|
||||||
|
efd_result (*system_cb)();
|
||||||
efd_result (*update_cb)();
|
efd_result (*update_cb)();
|
||||||
efd_result (*render_cb)(efd_entity_type type);
|
efd_result (*render_cb)(efd_entity_type type);
|
||||||
efd_result (*player_join_cb)(efd_entity player_id);
|
efd_result (*player_join_cb)(efd_entity player_id);
|
||||||
|
@ -55,105 +134,66 @@ typedef struct efd_app_desc {
|
||||||
float item_attract_radius;
|
float item_attract_radius;
|
||||||
float item_attract_force;
|
float item_attract_force;
|
||||||
} rules;
|
} rules;
|
||||||
|
|
||||||
|
efd_asset *assets;
|
||||||
|
efd_tile *tiles;
|
||||||
|
efd_block *blocks;
|
||||||
|
efd_entity *entities;
|
||||||
|
efd_item *items;
|
||||||
|
efd_craft *crafting;
|
||||||
|
efd_tooltip *tooltips;
|
||||||
} efd_app_desc;
|
} efd_app_desc;
|
||||||
|
|
||||||
// assets
|
|
||||||
|
|
||||||
// #define EFD_ASSET_TEXTURE_LAST 15
|
|
||||||
// #define EFD_ASSET_ANIMATION_LAST 2222222
|
|
||||||
// #define EFD_ASSET_ANIMATION_LAST 2222222
|
|
||||||
|
|
||||||
// #define CONC(a, b) a##b
|
|
||||||
/* + CONC(type, _LAST) */
|
|
||||||
|
|
||||||
#define EFD_ASSET_SHIFT 16
|
|
||||||
#define EFD_ASSET(type) ((type) << EFD_ASSET_SHIFT)
|
|
||||||
#define EFD_ASSET_TYPE(id) ((id) >> EFD_ASSET_SHIFT)
|
|
||||||
|
|
||||||
typedef struct efd_asset {
|
|
||||||
int id;
|
|
||||||
const char *path;
|
|
||||||
void *data; /* TODO: make a union */
|
|
||||||
} efd_asset;
|
|
||||||
|
|
||||||
efd_result efd_asset_add(int id, const char *path);
|
|
||||||
efd_result efd_asset_remove(int id);
|
|
||||||
efd_asset *efd_asset_get(int id);
|
|
||||||
|
|
||||||
// notifications
|
|
||||||
|
|
||||||
efd_result efd_notify_push(efd_entity actor, const char *title, const char *text, float duration);
|
|
||||||
efd_result efd_notify_clear(efd_entity actor);
|
|
||||||
|
|
||||||
// tooltips
|
|
||||||
|
|
||||||
efd_result efd_tooltip_add(const char *name, const char *text);
|
|
||||||
efd_result efd_tooltip_remove(const char *name);
|
|
||||||
|
|
||||||
// entities
|
|
||||||
|
|
||||||
enum efd_entity_type_builtins {
|
|
||||||
EFD_ENTITY_NONE = 0,
|
|
||||||
EFD_ENTITY_PLAYER = 1,
|
|
||||||
EFD_ENTITY_CHUNK,
|
|
||||||
EFD_ENTITY_OBJECT,
|
|
||||||
EFD_ENTITY_ITEM,
|
|
||||||
EFD_ENTITY_NPC,
|
|
||||||
EFD_ENTITY_VEHICLE,
|
|
||||||
|
|
||||||
EFD_ENTITY_TYPE_LAST,
|
|
||||||
EFD_ENTITY_TYPE_MAX = 0xFFFF,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// app.c
|
/// app.c
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
/* textures */
|
/* textures */
|
||||||
ASSET_TILE_DIRT = EFD_ASSET(EFD_ASSET_TEXTURE),
|
TILE_AIR = EFD_ID(EFD_TYPE_TILE),
|
||||||
ASSET_TILE_GRASS,
|
TILE_DIRT,
|
||||||
ASSET_TILE_STONE,
|
TILE_GRASS,
|
||||||
|
TILE_STONE,
|
||||||
|
TILE_WATER,
|
||||||
|
TILE_LAVA,
|
||||||
|
|
||||||
ASSET_BLOCK_STONE,
|
BLOCK_STONE = EFD_ID(EFD_TYPE_BLOCK),
|
||||||
ASSET_BLOCK_BRICK,
|
BLOCK_BRICK,
|
||||||
|
BLOCK_HILL,
|
||||||
|
BLOCK_HILL_SNOW,
|
||||||
|
BLOCK_FENCE,
|
||||||
|
BLOCK_WOOD,
|
||||||
|
BLOCK_WALL,
|
||||||
|
BLOCK_BELT_LEFT,
|
||||||
|
BLOCK_BELT_RIGHT,
|
||||||
|
BLOCK_BELT_UP,
|
||||||
|
BLOCK_BELT_DOWN,
|
||||||
|
|
||||||
ASSET_PLAYER,
|
ENTITY_PLAYER = EFD_ID(EFD_TYPE_ENTITY),
|
||||||
ASSET_TREE,
|
ENTITY_MONSTER,
|
||||||
ASSET_CHEST,
|
ENTITY_TRUCK,
|
||||||
ASSET_MONSTER,
|
ENTITY_TREE,
|
||||||
|
ENTITY_CHEST,
|
||||||
|
ENTITY_FURNACE,
|
||||||
|
ENTITY_CRAFTBENCH,
|
||||||
|
ENTITY_ASSEMBLER,
|
||||||
|
|
||||||
ASSET_ITEM_WOOD,
|
ITEM_IRON_ORE = EFD_ID(EFD_TYPE_ITEM),
|
||||||
ASSET_ITEM_STONE,
|
ITEM_IRON_INGOT,
|
||||||
ASSET_ITEM_IRON,
|
ITEM_IRON_PLATE,
|
||||||
|
ITEM_SCREW,
|
||||||
/* animations */
|
ITEM_BELT,
|
||||||
ASSET_PLAYER_ANIM = EFD_ASSET(EFD_ASSET_ANIMATION),
|
|
||||||
|
|
||||||
/* sounds */
|
|
||||||
ASSET_PLAYER_SOUND = EFD_ASSET(EFD_ASSET_SOUND),
|
|
||||||
ASSET_TREE_SOUND,
|
|
||||||
ASSET_CHEST_SOUND,
|
|
||||||
|
|
||||||
/* fonts */
|
|
||||||
ASSET_FONT_DEFAULT = EFD_ASSET(EFD_ASSET_FONT),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
// void Move(ecs_iter_t *it) {
|
||||||
ENTITY_MONSTER = EFD_ENTITY_TYPE_LAST,
|
// // Get fields from system query
|
||||||
ENTITY_WEAPON,
|
// Position *p = ecs_field(it, Position, 1);
|
||||||
};
|
// Velocity *v = ecs_field(it, Velocity, 2);
|
||||||
|
|
||||||
void Move(ecs_iter_t *it) {
|
|
||||||
// Get fields from system query
|
|
||||||
Position *p = ecs_field(it, Position, 1);
|
|
||||||
Velocity *v = ecs_field(it, Velocity, 2);
|
|
||||||
|
|
||||||
// Iterate matched entities
|
|
||||||
for (int i = 0; i < it->count, i++) {
|
|
||||||
p[i].x += v[i].x;
|
|
||||||
p[i].y += v[i].y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// // Iterate matched entities
|
||||||
|
// for (int i = 0; i < it->count, i++) {
|
||||||
|
// p[i].x += v[i].x;
|
||||||
|
// p[i].y += v[i].y;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
efd_result init() {
|
efd_result init() {
|
||||||
// NOTE: control sets could be implemented later on
|
// NOTE: control sets could be implemented later on
|
||||||
|
@ -177,7 +217,7 @@ efd_result init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
efd_result systems(efd_world *w) {
|
efd_result systems(efd_world *w) {
|
||||||
ECS_SYSTEM(w, Move, EcsOnUpdate, Position, [in] Velocity);
|
// ECS_SYSTEM(w, Move, EcsOnUpdate, Position, [in] Velocity);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -187,29 +227,29 @@ efd_result update() {
|
||||||
}
|
}
|
||||||
|
|
||||||
efd_result render(efd_entity_type type) {
|
efd_result render(efd_entity_type type) {
|
||||||
switch (type) {
|
// switch (type) {
|
||||||
case EFD_ENTITY_PLAYER:
|
// case EFD_ENTITY_PLAYER:
|
||||||
/* additional/replacable rendering code on top of what EFD provides for built-in types */
|
// /* additional/replacable rendering code on top of what EFD provides for built-in types */
|
||||||
efd_render_texture(ASSET_PLAYER, 0, 0, 0, 0, 0, 0, 0, 0);
|
// efd_render_texture(ENTITY_PLAYER, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||||
|
|
||||||
return 1; /* we handled the rendering, don't render with the default renderer */
|
// return 1; /* we handled the rendering, don't render with the default renderer */
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case ENTITY_MONSTER:
|
// case ENTITY_MONSTER:
|
||||||
/* our custom rendering code for monster */
|
// /* our custom rendering code for monster */
|
||||||
efd_render_texture(ASSET_MONSTER, 0, 0, 0, 0, 0, 0, 0, 0);
|
// efd_render_texture(ENTITY_MONSTER, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case ENTITY_WEAPON:
|
// case ENTITY_WEAPON:
|
||||||
/* our custom rendering code for weapon */
|
// /* our custom rendering code for weapon */
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
efd_result player_join(efd_entity player) {
|
efd_result player_join(efd_entity player) {
|
||||||
efd_notify_push(player, "Test", "Welcome to the game!", 5.0f);
|
// efd_notify_push(player, "Test", "Welcome to the game!", 5.0f);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,91 +296,107 @@ efd_app_desc efd_main() {
|
||||||
.item_attract_force = 0.1f,
|
.item_attract_force = 0.1f,
|
||||||
},
|
},
|
||||||
|
|
||||||
.assets = {
|
.assets = (efd_asset[]){
|
||||||
{ASSET_PLAYER, "assets/player.png"},
|
{EFD_TEXTURE, ENTITY_TREE, "assets/tree.png"},
|
||||||
{ASSET_MONSTER, "assets/monster.png"},
|
{EFD_TEXTURE, ENTITY_CHEST, "assets/chest.png"},
|
||||||
|
{EFD_TEXTURE, ENTITY_FURNACE, "assets/furnace.png"},
|
||||||
|
|
||||||
{ASSET_ITEM_WOOD, "assets/item_wood.png"},
|
{EFD_TEXTURE, ENTITY_PLAYER, "assets/player.png"},
|
||||||
{ASSET_ITEM_STONE, "assets/item_stone.png"},
|
{EFD_TEXTURE, ENTITY_MONSTER, "assets/monster.png"},
|
||||||
{ASSET_ITEM_IRON, "assets/item_iron.png"},
|
|
||||||
|
|
||||||
{ASSET_TREE, "assets/tree.png"},
|
{EFD_END},
|
||||||
{ASSET_CHEST, "assets/chest.png"},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
.tiles = {
|
.tiles = (efd_tile[]){
|
||||||
{ASSET_EMPTY, EFD_FLAG_NONE, 'E'},
|
{TILE_AIR},
|
||||||
{ASSET_GROUND, EFD_FLAG_NONE, '.', .drag = 1.0f, .friction = 1.0f},
|
{TILE_DIRT, .drag = 1.0f, .friction = 1.0f},
|
||||||
{ASSET_DIRT, EFD_FLAG_NONE, ',', .drag = 2.1f , .friction = 1.0f},
|
{TILE_GRASS, .drag = 1.0f, .friction = 1.0f},
|
||||||
{ASSET_WATER, EFD_FLAG_NONE, '~', .drag = 0.11f , .friction = 10.0f},
|
{TILE_WATER, .drag = 0.11f , .friction = 10.0f},
|
||||||
{ASSET_LAVA, EFD_FLAG_HAZARD, '!', .drag = 6.2f , .friction = 40.0f},
|
{TILE_LAVA, EFD_FLAG_HAZARD, .drag = 6.2f , .friction = 40.0f},
|
||||||
|
|
||||||
|
{EFD_END},
|
||||||
},
|
},
|
||||||
|
|
||||||
.blocks = {
|
.blocks = (efd_block[]){
|
||||||
{ASSET_WALL, EFD_FLAG_COLLISION, '#', .bounce = 1.0f},
|
{BLOCK_WALL, EFD_FLAG_COLLISION, .bounce = 1.0f},
|
||||||
{ASSET_HILL, EFD_FLAG_COLLISION, '^'},
|
{BLOCK_HILL, EFD_FLAG_COLLISION},
|
||||||
{ASSET_HILL_SNOW, EFD_FLAG_COLLISION, '*'},
|
{BLOCK_HILL_SNOW, EFD_FLAG_COLLISION},
|
||||||
{ASSET_FENCE, EFD_FLAG_COLLISION, '[', .bounce = 1.0f},
|
{BLOCK_FENCE, EFD_FLAG_COLLISION, .bounce = 1.0f},
|
||||||
{ASSET_WOOD, EFD_FLAG_COLLISION, ']', .bounce = 0.0f},
|
{BLOCK_WOOD, EFD_FLAG_COLLISION, .bounce = 0.0f},
|
||||||
{ASSET_TREE, EFD_FLAG_COLLISION|EFD_FLAG_DESTROY_ON_COLLISION, '@', .bounce = 0.0f},
|
|
||||||
{ASSET_CHEST, EFD_FLAG_ENTITY, 'C'},
|
|
||||||
{ASSET_FURNACE, EFD_FLAG_ENTITY, 'F'},
|
|
||||||
{ASSET_TEST_TALL, EFD_FLAG_COLLISION, '.'},
|
|
||||||
|
|
||||||
{ASSET_BELT_LEFT, EFD_FLAG_NONE, '@', .velx = -150.0f},
|
{BLOCK_BELT_LEFT, .velx = -150.0f},
|
||||||
{ASSET_BELT_RIGHT, EFD_FLAG_NONE, '@', .velx = 150.0f},
|
{BLOCK_BELT_RIGHT, .velx = 150.0f},
|
||||||
{ASSET_BELT_UP, EFD_FLAG_NONE, '@', .vely = -150.0f},
|
{BLOCK_BELT_UP, .vely = -150.0f},
|
||||||
{ASSET_BELT_DOWN, EFD_FLAG_NONE, '@', .vely = 150.0f},
|
{BLOCK_BELT_DOWN, .vely = 150.0f},
|
||||||
|
|
||||||
|
{EFD_END},
|
||||||
},
|
},
|
||||||
|
|
||||||
.items = {
|
.entities = (efd_entity[]){
|
||||||
{ITEM_WOOD, ASSET_ITEM_WOOD, "Wood", "A piece of wood."},
|
{ENTITY_TREE, EFD_FLAG_DESTROY_ON_COLLISION},
|
||||||
{ITEM_STONE, ASSET_ITEM_STONE, "Stone", "A piece of stone."},
|
{ENTITY_CHEST},
|
||||||
|
{ENTITY_FURNACE},
|
||||||
|
|
||||||
|
{ENTITY_PLAYER, EFD_FLAG_PLAYER},
|
||||||
|
{ENTITY_TRUCK, EFD_FLAG_VEHICLE},
|
||||||
|
{ENTITY_MONSTER, EFD_FLAG_AI},
|
||||||
|
|
||||||
|
{EFD_END},
|
||||||
},
|
},
|
||||||
|
|
||||||
.crafting = {
|
.items = (efd_item[]){
|
||||||
|
// {ITEM_WOOD, "Wood", "A piece of wood."},
|
||||||
|
// {ITEM_STONE, "Stone", "A piece of stone."},
|
||||||
|
{EFD_END},
|
||||||
|
},
|
||||||
|
|
||||||
|
.crafting = (efd_craft[]){
|
||||||
{
|
{
|
||||||
.producer = ASSET_FURNACE,
|
.producer = ENTITY_FURNACE,
|
||||||
.process_ticks = 20,
|
.ticks = 20,
|
||||||
.reagents = {
|
.input = (efd_craft_item[]){
|
||||||
{ .item = ASSET_IRON_ORE, .qty = 1 },
|
{ITEM_IRON_ORE, 1},
|
||||||
|
{EFD_END},
|
||||||
},
|
},
|
||||||
.products = {
|
.output = (efd_craft_item[]){
|
||||||
{ .item = ASSET_IRON_PLATES, .qty = 4 },
|
{ITEM_IRON_PLATE, 4},
|
||||||
|
{EFD_END},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.producer = ASSET_CRAFTBENCH,
|
.producer = ENTITY_CRAFTBENCH,
|
||||||
.process_ticks = 40,
|
.ticks = 40,
|
||||||
.reagents = {
|
.input = (efd_craft_item[]){
|
||||||
{ .item = ASSET_IRON_PLATES, .qty = 1 },
|
{ITEM_IRON_PLATE, 1},
|
||||||
|
{EFD_END},
|
||||||
},
|
},
|
||||||
.products = {
|
.output = (efd_craft_item[]){
|
||||||
{ .item = ASSET_SCREWS, .qty = 8 },
|
{ITEM_SCREW, 8},
|
||||||
|
{EFD_END},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.producer = ASSET_ASSEMBLER,
|
.producer = ENTITY_ASSEMBLER,
|
||||||
.production_ticks = 120,
|
.ticks = 120,
|
||||||
.reagents = {
|
.input = (efd_craft_item[]){
|
||||||
{ .item = ASSET_FENCE, .qty = 1 },
|
{BLOCK_FENCE, 1},
|
||||||
{ .item = ASSET_SCREWS, .qty = 4 },
|
{ITEM_SCREW, 4},
|
||||||
{ .item = ASSET_IRON_PLATES, .qty = 2 },
|
{ITEM_IRON_PLATE, 2},
|
||||||
|
{EFD_END},
|
||||||
},
|
},
|
||||||
.products = {
|
.output = (efd_craft_item[]){
|
||||||
{ .item = ASSET_BELT, .qty = 1 },
|
{ITEM_BELT, 1},
|
||||||
|
{EFD_END},
|
||||||
},
|
},
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
.entities = {
|
{EFD_END},
|
||||||
{ENTITY_TREE, ASSET_TREE, "Tree", "A tree."},
|
|
||||||
{ENTITY_CHEST, ASSET_CHEST, "Chest", "A chest."},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
.tooltips = {
|
.tooltips = (efd_tooltip[]){
|
||||||
{"ASSET_BLOCK_STONE", "It's a block of stone, what did you expect?"},
|
{"BLOCK_STONE", "It's a block of stone, what did you expect?"},
|
||||||
{"ASSET_BLOCK_BRICK", "It's a block of brick, what did you expect?"},
|
{"BLOCK_BRICK", "It's a block of brick, what did you expect?"},
|
||||||
|
{EFD_END},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -349,33 +405,15 @@ efd_app_desc efd_main() {
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
efd_result efd_asset_add(int id, const char *path) {
|
|
||||||
printf("asset_add: %d, %s\n", id, path);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
efd_result efd_tooltip_add(const char *id, const char *text) {
|
|
||||||
printf("tooltip_add: %s, %s\n", id, text);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
efd_result efd_notify_push(efd_entity player, const char *title, const char *text, float duration) {
|
|
||||||
printf("notify_push: %llu, %s, %s, %f\n", player, title, text, duration);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void test(efd_entity_type type) { printf("type: %d\n", type); }
|
void test(efd_entity_type type) { printf("type: %d\n", type); }
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
efd_app_desc desc = efd_main();
|
efd_app_desc desc = efd_main();
|
||||||
printf("value: %f\n", desc.rules.item_pickup_radius);
|
printf("value: %f\n", desc.rules.item_pickup_radius);
|
||||||
printf("ASSET_TILE_DIRT: %d\n", ASSET_TILE_DIRT);
|
printf("TILE_DIRT: %d\n", TILE_DIRT);
|
||||||
printf("ASSET_TILE_GRASS: %d\n", ASSET_TILE_GRASS);
|
printf("TILE_GRASS: %d\n", TILE_GRASS);
|
||||||
printf("ASSET_PLAYER: %d\n", ASSET_PLAYER);
|
printf("ENTITY_PLAYER: %d\n", ENTITY_PLAYER);
|
||||||
printf("ASSET_CHEST: %d\n", ASSET_CHEST);
|
printf("ENTITY_CHEST: %d\n", ENTITY_CHEST);
|
||||||
printf("ASSET_PLAYER_ANIM: %d\n", ASSET_PLAYER_ANIM);
|
|
||||||
printf("ASSET_PLAYER_SOUND: %d\n", ASSET_PLAYER_SOUND);
|
|
||||||
printf("ASSET_TREE_SOUND: %d\n", ASSET_TREE_SOUND);
|
|
||||||
|
|
||||||
desc.init_cb();
|
desc.init_cb();
|
||||||
|
|
||||||
|
|
|
@ -41,12 +41,12 @@
|
||||||
* world - a map of chunks within the game world
|
* world - a map of chunks within the game world
|
||||||
* world-view - a representation of the world recreated by the client
|
* world-view - a representation of the world recreated by the client
|
||||||
----------
|
----------
|
||||||
|
* chunk - entity that contains set of tiles and blocks
|
||||||
* tile - basic thing that makes up the chunks
|
* tile - basic thing that makes up the chunks
|
||||||
* block - 2nd level of things that make up the chunk
|
* block - 2nd level of things that make up the chunk
|
||||||
* chunk - entity that contains set of tiles and blocks
|
|
||||||
* item - an entity in the world, that can have a different state when its picked up
|
|
||||||
* crafting recipe - a recipe that can be used to craft an item
|
|
||||||
* entity - an grid-independant static or dynamic entity that can exist in the world and has some systems controlling it
|
* entity - an grid-independant static or dynamic entity that can exist in the world and has some systems controlling it
|
||||||
|
* item - an entity in the world, that can have a different state when its picked up
|
||||||
|
* crafting - a recipe that can be used to craft an item
|
||||||
|
|
||||||
|
|
||||||
## Naming
|
## Naming
|
||||||
|
@ -58,12 +58,14 @@
|
||||||
* prefix: efd_
|
* prefix: efd_
|
||||||
|
|
||||||
## Objects
|
## Objects
|
||||||
* entity
|
* tile
|
||||||
* objects
|
* block
|
||||||
* players
|
* entity
|
||||||
* npc
|
* npc
|
||||||
* vehicles
|
* player
|
||||||
* items
|
* vehicle
|
||||||
|
* item
|
||||||
|
* craft
|
||||||
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
Loading…
Reference in New Issue