I have just finished a 2D game in Java that I've been working on for a while.
I found that on some computers it runs fine, and on others (which are not particularly slow in general), the game runs a little slower, and with minor interruptions every second or so. Not completely smooth.
Since I am a beginner to making games, and probably since I didn't plan everything about the game in advance, the code of the game is rather long, clumsy and probably inefficient.
I want to improve this in my next projects. So my question is - In general, what would be the main causes for a common 2D game to slow down on a computer?
What should I pay the most attention to, next time, in order to design an efficient game?
- Making a small amount of classes? (Even if the classes are small ones?)
- Avoiding repetition of code? (Even small sections of code, such as
- Avoiding too many threads running?
- Anything else?
Obviously, all of the above are recommended for an efficient program.
But I'd like to know, what in a game's code, could be especially significant for making an efficient application, and what would be less important and will not save significant amounts of memory.
Any advice would be welcome - could be regarding game design, or regarding more specific coding issues.
I don't know if this matters, but please note that I'm talking mainly about real-time games, using a 'game-loop' that constantly updates the game and the dispaly.