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.

I am fairly new to game development, but I have a good programming background with object oriented programming.

But with games, I do not know when I should use an object (or class) for an entity on the screen or whether I should just draw the images straight to the screen.

I think that for any graphic objects that need interacting with (say the player or certain environment objects) would need their own class and just decoration (the image that make up the background) could be drawn straight to the screen.

So, my question is: when do I use an object or class for my graphics?

If it makes any difference, I am using LibGDX.

share|improve this question

closed as off-topic by Josh Petrie Dec 6 '13 at 3:30

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Programming questions that aren't specific to game development are off-topic here, but can be asked on Stack Overflow. A good rule of thumb is to ask yourself "would a professional game developer give me a better/different/more specific answer to this question than other programmers?"" – Josh Petrie
If this question can be reworded to fit the rules in the help center, please edit the question.

1  
This essentially boils down to the question "when do I use classes versus free functions?" which is not game-development specific and is also a very broad and discussion-oriented topic. Considering editing your question with details about your specific problem to address those issues. –  Josh Petrie Dec 6 '13 at 3:31
    
No, I am talking about when to use them in a game. Specifically a game. So, when do I use a class for my images (e.g. a class for a "monster") or just load a picture onto the screen as a background. It is game-development specific and is not very broad. My specific question and details are written. –  Liam Flaherty Dec 7 '13 at 4:10
    
There no one answer, and the decision making process you would go through is the same as the process you'd use when deciding for any interface not just images. –  Josh Petrie Dec 7 '13 at 16:34

1 Answer 1

up vote 0 down vote accepted

It does often depend on what kind of interface the library/language provides and what kind of game it is there is no real right answer. If for example you have a 2D game using a tilemap, I prefer using some form of class/structure to keep the properties together, but if the background lacks properties that might be used to handle say collision it can as you say just be drawn to the screen as in LibGDX you can store the X and Y coordinate in the Sprite class which will be ultimately used to draw any decoration images which you could store in a collection.

Generally as long as you don't go crazy with inheritance classes will not create much of an overhead if you prefer thinking about things as objects it will probably make it easier for you to make your game.

share|improve this answer
1  
Thank you for your response. So then with my game, I'll use objects for main entities (players and intractable environment, etc.) and just a manager class for the extra art which makes up the background. –  Liam Flaherty Dec 6 '13 at 2:32

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