Hello,
iam sorry but iam really new at jME. I programmed before c++.
I found a interisting short tutorial how to program a small pong game http://developers.sun.com/learning/javaoneonline/2008/pdf/TS-5711.pdf?cid=925556 .
But this describes only the important functions, i want to have a running code which i want to understand.
I tryed to make the first steps but it will not work.
package FirstGame;
import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingBox;
import com.jme.bounding.BoundingSphere;
import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.math.Vector3f;
import com.jme.scene.Geometry;
import com.jme.scene.shape.Box;
import com.jme.scene.shape.Sphere;
public class FirstGame extends SimpleGame {
@Override
protected void simpleInitGame() {
Geometry ball = new Sphere("Ball", 8, 8, 2);
ball.setModelBound(new BoundingSphere());
ball.updateModelBound();
Box player1 = new Box("Player1", new Vector3f(), 2, 5, 10);
player1.setModelBound(new BoundingBox());
player1.updateModelBound();
player1.getLocalTranslation().set(-100, 0, 0);
// Tastatureingaben
KeyBindingManager.getKeyBindingManager().set("MOVE_UP", KeyInput.KEY_W);
}
protected void simpleUpdate(Box player1) {
if (KeyBindingManager.getKeyBindingManager()
.isValidCommand("MOVE_UP", true)) {
float player1Speed = 0;
player1.getLocalTranslation().z -= player1Speed * timer.getTimePerFrame();
}
if (player1.hasCollision(ball, false)) {
ballVelocity.x *= -1f;
}
if (sideWalls.hasCollision(ball, false)) {
ballVelocity.z *= -1f;
}
if (player1GoalWall.hasCollision(ball, false)) {
player2Score++;
}
}
}
Thanks :)