Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
2  
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
2  
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

1 Answer 1

up vote 18 down vote accepted

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.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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