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,5 @@
.bake_cache
.DS_Store
.vscode
gcov
bin

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,12 @@
{
"id": "basics",
"type": "application",
"value": {
"author": "Jane Doe",
"description": "A simple hello world flecs application",
"use": [
"flecs"
],
"language": "c++"
}
}

View File

@@ -0,0 +1,53 @@
#include <basics.h>
#include <iostream>
struct Position {
double x, y;
};
struct Walking { };
int main(int, char *[]) {
flecs::world ecs;
// Create an entity with name Bob
flecs::entity bob = ecs.entity("Bob")
// The set operation finds or creates a component, and sets it.
// Components are automatically registered with the world.
.set<Position>({10, 20})
// The add operation adds a component without setting a value. This is
// useful for tags, or when adding a component with its default value.
.add<Walking>();
// Get the value for the Position component
const Position* ptr = bob.get<Position>();
std::cout << "{" << ptr->x << ", " << ptr->y << "}" << "\n";
// Overwrite the value of the Position component
bob.set<Position>({20, 30});
// Create another named entity
flecs::entity alice = ecs.entity("Alice")
.set<Position>({10, 20});
// Add a tag after entity is created
alice.add<Walking>();
// Print all of the components the entity has. This will output:
// Position, Walking, (Identifier,Name)
std::cout << "[" << alice.type().str() << "]" << "\n";
// Remove tag
alice.remove<Walking>();
// Iterate all entities with Position
ecs.each([](flecs::entity e, Position& p) {
std::cout << e.name() << ": {" << p.x << ", " << p.y << "}" << "\n";
});
// Output
// {10, 20}
// [Position, Walking, (Identifier,Name)]
// Alice: {10, 20}
// Bob: {20, 30}
}