Class Distribution?

Hey everyone! I’m starting a new project that will be my first ever actual game. I’ve been a part of the Jmonkey community for about a year now, but I’ve spent all of my time becoming familiar with blender and specific aspects of Jmonkey. Now that I feel as though I’ve mastered most aspects of Jmonkey individually, I’m ready to put it all together.

I know that it’s a very vague question, but I was wondering how you have distributed your classes for your games. What has been your most successful layout?


Well this is my current structure omiting external Projects.
-> I’m especially a fan of separating client and server into projects, as this will force you to cleanly split the logic and put stuff where it actually belongs.

Btw an updated code fragment I found/used for this:

task dependenciesPng() {
 def reportsDir = new File("build/reports")
 def compileDepsDot = file("$reportsDir/")
 inputs.files subprojects.configurations.compile
 outputs.files compileDepsDot
 doFirst {
 if(!reportsDir.exists()) reportsDir.mkdirs()
 doLast {
 ext.dotGraph = "digraph compile{" + System.getProperty("line.separator")
 Set deps = [] as Set 
 subprojects.each {subproject ->
 subproject.configurations.compile.dependencies.each {dependency ->
 if(dependency instanceof ProjectDependency) {
 String dep = "\"$\" -> \"$\";"
 if (deps.add(dep)){ // if was not there before - avoid duplicates
 ext.dotGraph += dep + System.getProperty("line.separator")
 ext.dotGraph += "}"

and then

dot -Tpng ./ -o ./compileDeps_dot.png &&
neato -Tpng ./ -o ./compileDeps_neato.png &&
twopi -Tpng ./ -o ./compileDeps_twopi.png &&
circo -Tpng ./ -o ./compileDeps_circo.png

After that just choose the one you like best.

1 Like

Thank you so much! Your project seems to be much more complicated that mine :smiley:

I would still appreciate anyone else’s input. Thanks a ton!

Really, the class layout should emanate from your over-arching game logic. Try to use AppStates and Controls as they fit and the rest should follow, really. Get acquainted with normal java techniques. Classes are not so much for “ordering” your code but they are logical elements. If you need to make a list of information “packages” or need to pass information around you might make a class for storing one “package”. If you have a completely separate part of your code that manages the UI and you want to separately be able to enable and disable that, a separate AppState class would be a good idea. etc.