I've been poking with game engines for a while now. I've been using Java, and I would like to make some small games. I've been using JMonkey 3 for quite some time, but I am not really sure how to set up the code in the correct way.
So the problem is that I would like to write the game mechanic regardless of the graphic engine itself.
What I need are some classes that will interface with the engine itself, but also act as data storage for saving and modeling levels.
I've already wrote a small game in such a way, but I am not happy with it, it got too complex.
JME has its own classes for storing objects, such as solids. But when writing the game mechanics I don't want to directly interface with jme-s solid class, or any other class from jme, what I want is to have a set of classes that will interface with the game engine, so that I can save the status of those classes, or in future games synchronize them with a server, so that I can have a multiplayer game.
The first time I went to do something like that I used only 2D graphics, and I wrote some code that directly manipulated opengl-s functions, so I could easily implement such a system, and in the end I got that game working over multiplayer, and have friends join.
But now when I have JMonkey, I can't go poke inside the engine code.
So this is how an example of game mechanic should look like in such a system:
Object box=new Object(BOX_MODEL,x,y,z, rx, ry, rz); //Spawns the box
box.addItem(new Item(Soldering_iron)); //adds something into it
box.setSpeed(10,0,5); //sets the box flying
On the other way, I should also be able to serialize that box instance, and save it to a disk, or even send it over a tcp link to a game server.
But the problem is, that the Object class must not contain any specific stuff regarding the 3D game engine, because if it does, if the other side or game session tries to load such an object, it would load references that have nothing to do with the current session.
In my previous attempt I have everything doubled, and a class in the middle that acted as a bridge synchronisig the data in the Object class, and the engine itself, and that was a really complicated and messy solution.
So how do I set up the Object class, or any other interface class like that toward JMonkey, or any other engine so that I can have those features, and yet have a nice and clean implementation?
Any ideas suggestions?