enter image description here

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.

  • 2
    \$\begingroup\$ 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. \$\endgroup\$ Feb 27, 2013 at 6:22
  • 2
    \$\begingroup\$ 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) \$\endgroup\$
    – Supericy
    Feb 27, 2013 at 6:51

1 Answer 1


Put it wherever you can to make it work. Anything else is design paralysis and just going to slow down your progress.

When you start seeing patterns emerge, refactor your code.

Lots of people will give you advice about the One True Way to do something, but without a breadth of experience to draw from, you'll just be parroting ideas without a true understanding of the reasoning behind it.

  • \$\begingroup\$ Hey thanks for that.I suppose it's bad if I just copy how other people design there games. Thanks. \$\endgroup\$
    – pangaea
    Feb 27, 2013 at 6:56
  • 1
    \$\begingroup\$ I like this answer and wish I could up vote it more than once. You never truly learn without getting your hands dirty. \$\endgroup\$
    – dennmat
    Feb 27, 2013 at 12:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .