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 HELLO_WORLD_H
#define HELLO_WORLD_H
/* This generated file contains includes for project dependencies */
#include "hello_world/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 HELLO_WORLD_BAKE_CONFIG_H
#define HELLO_WORLD_BAKE_CONFIG_H
/* Headers of public dependencies */
#include <flecs.h>
#endif

View File

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

View File

@@ -0,0 +1,50 @@
#include <hello_world.h>
#include <iostream>
// Component types
struct Position {
double x;
double y;
};
struct Velocity {
double x;
double y;
};
// Tag types
struct Eats { };
struct Apples { };
int main(int, char *[]) {
// Create the world
flecs::world ecs;
// Register system
ecs.system<Position, Velocity>()
.each([](Position& p, Velocity& v) {
p.x += v.x;
p.y += v.y;
});
// Create an entity with name Bob, add Position and food preference
flecs::entity Bob = ecs.entity("Bob")
.set(Position{0, 0})
.set(Velocity{1, 2})
.add<Eats, Apples>();
// Show us what you got
std::cout << Bob.name() << "'s got [" << Bob.type().str() << "]\n";
// Run systems twice. Usually this function is called once per frame
ecs.progress();
ecs.progress();
// See if Bob has moved (he has)
const Position *p = Bob.get<Position>();
std::cout << Bob.name() << "'s position is {" << p->x << ", " << p->y << "}\n";
// Output
// Bob's got [Position, Velocity, (Identifier,Name), (Eats,Apples)]
// Bob's position is {2, 4}
}