Properly link flecs library

This commit is contained in:
2023-11-09 11:38:29 +01:00
parent dc585396c3
commit 8edcf9305c
1392 changed files with 390081 additions and 164 deletions

View File

@@ -0,0 +1,16 @@
#ifndef BASICS_H
#define BASICS_H
/* This generated file contains includes for project dependencies */
#include "basics/bake_config.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,24 @@
/*
)
(.)
.|.
| |
_.--| |--._
.-'; ;`-'& ; `&.
\ & ; & &_/
|"""---...---"""|
\ | | | | | | | /
`---.|.|.|.---'
* This file is generated by bake.lang.c for your convenience. Headers of
* dependencies will automatically show up in this file. Include bake_config.h
* in your main project file. Do not edit! */
#ifndef BASICS_BAKE_CONFIG_H
#define BASICS_BAKE_CONFIG_H
/* Headers of public dependencies */
#include <flecs.h>
#endif

View File

@@ -0,0 +1,11 @@
{
"id": "basics",
"type": "application",
"value": {
"author": "Jane Doe",
"description": "A simple hello world flecs application",
"use": [
"flecs"
]
}
}

View File

@@ -0,0 +1,46 @@
#include <basics.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
ecs_world_t *ecs = ecs_init_w_args(argc, argv);
ECS_TAG(ecs, Eats);
// Entity used for Grows relationship
ecs_entity_t grows = ecs_new_entity(ecs, "Grows");
// Relationship objects
ecs_entity_t apples = ecs_new_entity(ecs, "Apples");
ecs_entity_t pears = ecs_new_entity(ecs, "Pears");
// Create an entity with 3 relationships. Relationships are like regular components,
// but combine two types/identifiers into an (relationship, object) pair.
ecs_entity_t bob = ecs_new_entity(ecs, "Bob");
// Pairs can be constructed from a type and entity
ecs_add_pair(ecs, bob, Eats, apples);
ecs_add_pair(ecs, bob, Eats, pears);
// Pairs can also be constructed from two entity ids
ecs_add_pair(ecs, bob, grows, pears);
// Has can be used with relationships as well
printf("Bob eats apples? %d\n", ecs_has_pair(ecs, bob, Eats, apples));
// Wildcards can be used to match relationships
printf("Bob grows food? %d\n", ecs_has_pair(ecs, bob, grows, EcsWildcard));
// Print the type of the entity. Should output:
// (Identifier,Name),(Eats,Apples),(Eats,Pears),(Grows,Pears)
char *type_str = ecs_type_str(ecs, ecs_get_type(ecs, bob));
printf("Bob's type: [%s]\n", type_str);
ecs_os_free(type_str);
// Get first target of relationship
printf("Bob eats %s\n",
ecs_get_name(ecs, ecs_get_target(ecs, bob, Eats, 0)));
// Get second target of relationship
printf("Bob also eats %s\n",
ecs_get_name(ecs, ecs_get_target(ecs, bob, Eats, 1)));
return ecs_fini(ecs);
}