Jump to content
Posted 06 April 2012 - 09:55 AM
Posted 06 April 2012 - 10:03 AM
Posted 06 April 2012 - 11:03 AM
First of all you should use inheritance. Your Enemy and Player classes should extend from a common [abstract] class, seeing as how they are so similar. You could call this "Entity" or "Object". You could create interfaces to support the AI which individual extensions of the class (ie, WolfEnemy) could inherit and edit to their liking.
I wanted to ask if there are any good ressources on how to structure a basic game framework.
I am not completely new to game programming, but all my games tend to have the same "ugly" structure, i.e:
-Player Class (which holds the attributes for the player, i.e. health, movementspeed, position,...)
-Enemy Class (almost the same as player, only with some sort of an AI)
-Game Class (extended from a jpanel, has an instance of player and a collection of enemies, handles input, drawing, looping, etc.)
My problem here is, that the "Game" class becomes bloated rather fast and with that it gets more and more difficult to add things to it.
So, are there any ressources you can recommend to look at, for a decent game framework structure?
Or can you give me some hints and tips on how to structure my games better? How to separate Input from Drawing and everything else?
PS: I doesn't need to be specifically for Java, I would appreciate it though.