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/compileDeps.dot")
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 = "\"$subproject.name\" -> \"$dependency.name\";"
if (deps.add(dep)){ // if was not there before - avoid duplicates
ext.dotGraph += dep + System.getProperty("line.separator")
}
}
}
}
ext.dotGraph += "}"
compileDepsDot.write(ext.dotGraph)
}
}
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.