Game logic vs visual logic

What's the best approach to implement game logic with JME ? I like to keep things seperated and following some sort of pattern. But i don't feel my current approach is working out.

I basically try to seperate my game logic from my visual logic. But this doesn't seem to be possible all the time. Since game logic(AI/User Interaction) triggers visual logic but at the same time visual logic(collision detection) can trigger game logic.

How do you guys handle this ?

a good data logic seperation is always good for the long run.

what ive been doing is simply keep data inside entity classes and have one or more controller objects which excute entity logic depending if the logic is generic or polyphormic. some times it is not approperate to try to keep all the logic inside one controller class since alot of types of logic really belong to the entities. i personally refer them as data logic.

I tried doing a similar thing, it just comes very messy and difficult to handle. I suggest that you integrate your systems with the jME scene graph, using controller classes to handle game logic, passes/gamestates to do updating, etc. It is very difficult to keep things separated like you say in games since all components depend on each over, the only thing you can do is make it easier for those components to interact.

i'm using the scenegraph both as the view and a part of the model. because it is. in most cases, there is no sensible separation possible. a separation would be like separating the left and right part from a brain.

I've been moving logic to Controllers today.

For my space rts i have made implementations like:

NavigateToController(Spatial spatial,Spatial target) //Navigates spatial to a target spatial

OrbitController(Spatial spatial,Spatial target,float distance) //Orbits spatial around another spatial at given distance

TriggerInRangeController(Spatial spatial,Spatial target,float minDistance,float maxDistance,InRangeListener listener) //Calls InRangeListener when spatial is within given range

I use this as follows(from the top of my head):

class Missle extends Unit implement InRangeListener {


   public Missle(Spatial target) {


     this.addController(new NavigateToController(this,target));

     this.addController(new TriggerInRangeController(this,target,0,1f,this))


   public void onInRange(Spatial target,float distance) {

       //do damage



Does this sound about right ?