diff options
author | quou <quou@disroot.org> | 2023-05-02 21:37:07 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2023-05-02 21:37:07 +1000 |
commit | 65fa1051585f5345c3270db73ab53b7a0dbbaa50 (patch) | |
tree | 30fed63168b86f8de48698174b265ffbdfae4343 /sprite_system.c | |
parent | d3745895ca0107c705b2d89b8b80e254536dad86 (diff) |
Add ECS.
Diffstat (limited to 'sprite_system.c')
-rw-r--r-- | sprite_system.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sprite_system.c b/sprite_system.c new file mode 100644 index 0000000..99360fc --- /dev/null +++ b/sprite_system.c @@ -0,0 +1,23 @@ +#include "asset.h" +#include "components.h" +#include "render.h" +#include "world.h" + +void sprite_system(const World* world) { + int i; + unsigned bits; + const CSprite* sprite; + const CPosition* pos; + const Bitmap* b; + + for (i = 0; i < world->entity_count; i++) { + bits = world->bitmask[i]; + if ((bits & ctype_position) && (bits & ctype_sprite)) { + pos = &world->positions[i]; + sprite = &world->sprites[i]; + + b = get_bitmap(sprite->id); + render_bitmap(b, pos->x, pos->y, &sprite->rect); + } + } +} |