Tip for Tron implementation [=> menu]

Hi there,

I hope you guys can help me with my programm i think i have made a mistake in the implementation.

I have a car, this car moves forward as long as it can. The car should be followed by a wall.

My problem is the following:

The car moves, but the wall ( i took a box for it, which i expand in the driveing direction ) is not doing what it should. The wall start at the wrong point, expand too fast and isn't behind the car.So i thought about my implementation and maybe there is a problem.

Here is the code for the expansion:  

// node = car

// node.wall_translation = the start point of the wall which get changed

float distance = node.wall_translation.z-node.getLocalTranslation().z;

node.wall.updateGeometry(new Vector3f(node.wall_translation.x,node.wall_translation.y,node.wall_translation.z-distance), 0.02f, 1.5f, distance);

Here the code for the box at startup

// player = car

Vector3f trans=new Vector3f(player.getLocalTranslation());  

Box box = new Box("wall",new Vector3f(), new Vector3f(0.02f,1.5f,0));


box.setModelBound(new BoundingBox());




What is the better way, to expand my wall? Please post any suggestions!

The game should be like GLTron, sombody knows that ?  ;)


edit Core-Dump: modified Title to be more specific

Couldn’t resist to make a simple example  :D

I commented a lot of the code.

There are still many problems with this code.

The walls don’t connect nicely for example and i think there is a problem with the normals, but i didn’t look further into it.

Maybe you can get some ideas from it or see what you did different.

import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingBox;
import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.math.FastMath;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.CameraNode;
import com.jme.scene.Controller;
import com.jme.scene.Node;
import com.jme.scene.shape.Box;
import com.jme.scene.state.MaterialState;

 * KEY_UP - start moving forward
 * KEY_DOWN - stop
 * KEY_LEFT / RIGHT - steer 90

I guess the player can change direction also?

If so you cannot simply expand a box, because the wall which the player creates, is not a simple box shape right ?

Or do you want to expand the box until a direction change, then create a new box?

okay thats a nice implementation :slight_smile:

thank you a lot :wink:

but i have one problem my wall is blinking all the time. Is there missing any update ?

One problem is currently, that it can happen that a wall part is created with the values:

System.out.println("from:" +to);
System.out.println("to:"   +from);
// from:(12.213438, 0.0, 25.704819)
// to:(12.463438, 0.5, 11.174967)
currentWall.updateGeometry(from, to);

x: from is lesser than x  - ok
y: from is lesser than x  - ok
z: from (25.7 is greater than z-to (11.17)  - bad :(

When calling updateGeometry(from,to) you need to make sure that 'from' is lesser than 'to'. Or some sides of the box are created with wrong normal's which results in strange lighting and stuff.

edit: i have updated the example with a fix for that problem.

okay your's proparly work, but my box was too strait. Both version's work for me now :slight_smile:

thank you a lot, i will post the final version later :smiley:


so after making the basic game, i want to make a simple menu with some options.

I have planed the following implementation for it:

In the middle of the black screen i add some menu points with jme.com.Text. The highlighted menu entry will get another text color and the user can move to another menu point with the arrorw keys.

Is this a good idea, or shall i use the swing staff for the menu?


sounds like an easy and good idea, i wouldn't use the swing (jme desktop) stuff, as it can caus trouble on mac

okay thanks for the tip again