0
\$\begingroup\$

I am currently working on a game in Java that uses an entity component system. The game currently has two separate update() and render() methods in the game loop however this does not seem to fit with my entity component system. From what I understand, each system in an ECS has an update method but what about say, a rendering system that draws sprites to the screen? How does rendering work with an ECS? One idea could be to have systems that draw on the screen implement a RenderSystem interface so that they are only used in the rendering method but I've never seen anything like this. Is there a certain way of doing this?

\$\endgroup\$
2
\$\begingroup\$

A common way to implement rendering in an ECS is to have a Renderer component on any entity which is supposed to be visible in the game world. This component would hold all the information which is required by the graphic engine (which you can call RenderingSystem if you like) to visualize this entity.

\$\endgroup\$
  • \$\begingroup\$ So a system where the render system holds information about entities to be used every render call? Currently the update() method is called 60 times per second and the render() method is called every loop. So could it be possible to store render information in the render system in the update() function to be later used in the render() function in the renderer? \$\endgroup\$ – Gigas Mar 27 '17 at 16:59
  • \$\begingroup\$ @Gigas Certainly. One thing you could handle in Renderer.update is animation. \$\endgroup\$ – Philipp Mar 27 '17 at 19:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.