# Where should I put my mob rendering code?

I'm making a simple LWJGL game. However, I'm a bit confused about rendering. So I have a Mob class and a TriangleMob is a basic enemy.

package daniel.entity.Mob;

public class TriangleMob {
public void render(){
}
public void move(){
}
}


Now I'm wondering do I put a render method in the TriangleMob or do I put some render method in graphics bit.

I'm really confused as I thought you needed to put all rendering in it's own bit. Then, all game logic like movement in another bit. Essentially, I want to spawn a TriangleMob in the SpawnMob class and then render it. I could put the render method in the TriangleMob class, however I want logic and rendering to be in different parts.

• Typically, it's a good idea to decouple the rendering logic from the data model as it will allow you to switch rendering engines without too much of a hassle down the road if you ever choose to - or even port to other platforms easily if need be. – Vaughan Hilts Feb 27 '13 at 6:22
• Noob here (so feel free to dispute) - What you can do is use composition. Inside your base entity, pass in a "EntityRenderer" object that will handle all the rendering logic for the entity. The nice thing about that is you get to choose and change at any time how the object can be rendered. (basically the same as the above comment) – Supericy Feb 27 '13 at 6:51