Properly link flecs library
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
#ifndef MULTI_SET_GET_H
|
||||
#define MULTI_SET_GET_H
|
||||
|
||||
/* This generated file contains includes for project dependencies */
|
||||
#include "multi_set_get/bake_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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 MULTI_SET_GET_BAKE_CONFIG_H
|
||||
#define MULTI_SET_GET_BAKE_CONFIG_H
|
||||
|
||||
/* Headers of public dependencies */
|
||||
#include <flecs.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"id": "multi_set_get",
|
||||
"type": "application",
|
||||
"value": {
|
||||
"use": [
|
||||
"flecs"
|
||||
],
|
||||
"public": false,
|
||||
"language": "c++"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#include <multi_set_get.h>
|
||||
#include <iostream>
|
||||
|
||||
/* This code shows how to get & set multiple components in a single command */
|
||||
|
||||
struct Position {
|
||||
double x, y;
|
||||
};
|
||||
|
||||
struct Mass {
|
||||
double value;
|
||||
};
|
||||
|
||||
int main(int, char *[]) {
|
||||
flecs::world ecs;
|
||||
|
||||
// Create new entity, set Position and Mass component
|
||||
flecs::entity e = ecs.entity()
|
||||
.set([](Position& p, Mass& m) {
|
||||
p.x = 10;
|
||||
p.y = 20;
|
||||
m.value = 100;
|
||||
});
|
||||
|
||||
// Print values of Position and Mass component
|
||||
bool found = e.get([](const Position& p, const Mass& m) {
|
||||
std::cout << "Position: {" << p.x << ", " << p.y << "}\n"
|
||||
<< "Mass: {" << m.value << "}\n";
|
||||
});
|
||||
|
||||
std::cout << "Components found: " << (found ? "true" : "false") << "\n";
|
||||
|
||||
// Output:
|
||||
// Position: {10, 20}
|
||||
// Mass: {100}
|
||||
// Components found: true
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user