Restructure/refactor of main.c
This commit is contained in:
14
game/systems/entity_renderer.c
Normal file
14
game/systems/entity_renderer.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "systems.h"
|
||||
|
||||
void renderEntities(ecs_iter_t *it) {
|
||||
Position *p = ecs_field(it, Position, 1);
|
||||
Size *s = ecs_field(it, Size, 2);
|
||||
Rotation *r = ecs_field(it, Rotation, 3);
|
||||
TextureRegion *t = ecs_field(it, TextureRegion, 4);
|
||||
|
||||
for (i32 i = 0; i < it->count; i++) {
|
||||
Rectangle dst = {p[i].x, p[i].y, s[i].x, s[i].y};
|
||||
Vector2 origin = {dst.width * 0.5f, dst.height * 0.5f};
|
||||
DrawTexturePro(t[i].texture, t[i].rec, dst, origin, r[i], WHITE);
|
||||
}
|
||||
}
|
||||
10
game/systems/systems.h
Normal file
10
game/systems/systems.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef PIXELDEFENSE_SYSTEMS_H
|
||||
#define PIXELDEFENSE_SYSTEMS_H
|
||||
|
||||
#include <flecs.h>
|
||||
|
||||
#include "../components.h"
|
||||
|
||||
void renderEntities(ecs_iter_t *it);
|
||||
|
||||
#endif //PIXELDEFENSE_SYSTEMS_H
|
||||
Reference in New Issue
Block a user