summary refs log tree commit diff stats
path: root/src/systems
diff options
context:
space:
mode:
Diffstat (limited to 'src/systems')
-rw-r--r--src/systems/rendering.cpp21
-rw-r--r--src/systems/rendering.h16
2 files changed, 37 insertions, 0 deletions
diff --git a/src/systems/rendering.cpp b/src/systems/rendering.cpp new file mode 100644 index 0000000..0034dc3 --- /dev/null +++ b/src/systems/rendering.cpp
@@ -0,0 +1,21 @@
1#include "rendering.h"
2#include "entity_manager.h"
3#include "components/sprite_renderable.h"
4#include "components/transformable.h"
5
6void RenderingSystem::tick(EntityManager& manager, float dt)
7{
8 texture.fill(texture.entirety(), 0, 0, 0);
9
10 std::set<int> spriteEntities = manager.getEntitiesWithComponents<SpriteRenderableComponent, TransformableComponent>();
11 for (int entity : spriteEntities)
12 {
13 auto& sprite = manager.getComponent<SpriteRenderableComponent>(entity);
14 auto& transform = manager.getComponent<TransformableComponent>(entity);
15 Rectangle dstrect {(int) transform.getX(), (int) transform.getY(), transform.getW(), transform.getH()};
16
17 texture.blit(sprite.getTexture(), sprite.getFrameRect(), dstrect);
18 }
19
20 texture.renderScreen();
21}
diff --git a/src/systems/rendering.h b/src/systems/rendering.h new file mode 100644 index 0000000..80ea79e --- /dev/null +++ b/src/systems/rendering.h
@@ -0,0 +1,16 @@
1#ifndef RENDERING_H_76ABC02A
2#define RENDERING_H_76ABC02A
3
4#include "system.h"
5#include "renderer.h"
6#include "consts.h"
7
8class RenderingSystem : public System {
9 public:
10 void tick(EntityManager& manager, float dt);
11
12 private:
13 Texture texture {GAME_WIDTH, GAME_HEIGHT};
14};
15
16#endif /* end of include guard: RENDERING_H_76ABC02A */