-
-
Notifications
You must be signed in to change notification settings - Fork 441
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d65b795
commit c3feadf
Showing
20 changed files
with
94 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
cmake_minimum_required (VERSION 2.8.7) | ||
|
||
project (cmake_example) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
|
||
add_subdirectory (flecs) | ||
|
||
add_executable(cmake_example main.cpp) | ||
add_executable(cmake_example_static main.cpp) | ||
|
||
target_link_libraries(cmake_example flecs) | ||
target_link_libraries(cmake_example_static flecs_static) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
For this to work, flecs needs to be a subdirectory of the example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "flecs.h" | ||
#include <iostream> | ||
|
||
/* Component types */ | ||
struct Position { | ||
float x; | ||
float y; | ||
}; | ||
|
||
struct Velocity { | ||
float x; | ||
float y; | ||
}; | ||
|
||
int main(int argc, char *argv[]) { | ||
/* Create the world, pass arguments for overriding the number of threads,fps | ||
* or for starting the admin dashboard (see flecs.h for details). */ | ||
flecs::world world(argc, argv); | ||
|
||
flecs::component<Position>(world, "Position"); | ||
flecs::component<Velocity>(world, "Velocity"); | ||
|
||
flecs::system<Position, Velocity>(world) | ||
.action([](const flecs::iter& it, | ||
flecs::column<Position> p, | ||
flecs::column<Velocity> v) | ||
{ | ||
for (auto row : it) { | ||
p[row].x += v[row].x; | ||
p[row].y += v[row].y; | ||
|
||
std::cout << "Moved " << it.entity(row).name() << " to {" << | ||
p[row].x << ", " << p[row].y << "}" << std::endl; | ||
} | ||
}); | ||
|
||
flecs::entity(world, "MyEntity") | ||
.set<Position>({0, 0}) | ||
.set<Velocity>({1, 1}); | ||
|
||
world.set_target_fps(1); | ||
|
||
std::cout << "Application move_system is running, press CTRL-C to exit..." << std::endl; | ||
|
||
/* Run systems */ | ||
while (world.progress()) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
#ifndef FLECS_MAP_H | ||
#define FLECS_MAP_H | ||
|
||
#include "api_defines.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
#ifndef FLECS_SPARSE_H | ||
#define FLECS_SPARSE_H | ||
|
||
#include "api_defines.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
#ifndef FLECS_STRBUF_H_ | ||
#define FLECS_STRBUF_H_ | ||
|
||
#include "api_defines.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
#ifndef FLECS_VECTOR_H | ||
#define FLECS_VECTOR_H | ||
|
||
#include "api_defines.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
#include "flecs/addon/ringbuf.h" | ||
#include "flecs.h" | ||
|
||
struct ecs_ringbuf_t { | ||
ecs_vector_t *data; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include "flecs/private/sparse.h" | ||
#include "flecs.h" | ||
|
||
#define CHUNK_ALLOC_SIZE (4096) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include "flecs/private/strbuf.h" | ||
#include "flecs.h" | ||
|
||
/* Add an extra element to the buffer */ | ||
static | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include "flecs/private/vector.h" | ||
#include "flecs.h" | ||
|
||
/** Resize the vector buffer */ | ||
static | ||
|