space-game/src/sg/SpaceGame.java
2009-03-11 14:56:11 +00:00

60 lines
No EOL
1.7 KiB
Java

package sg;
import sg.env.Environment;
import sg.input.FirstPersonHandler;
import sg.util.SGUtil;
import com.jme.scene.Node;
import com.jme.math.Vector3f;
import com.jmex.physics.DynamicPhysicsNode;
import com.jmex.physics.StaticPhysicsNode;
import com.jmex.physics.util.SimplePhysicsGame;
public class SpaceGame extends SimplePhysicsGame {
private StaticPhysicsNode staticNode;
private DynamicPhysicsNode dynamicNode;
private Environment environment;
private Node ship;
private DynamicPhysicsNode shipNode;
private FirstPersonHandler firstPersonHandler;
public static void main(String[] args) {
//Logger.getLogger("").setLevel( Level.WARNING );
SpaceGame game = new SpaceGame();
game.setConfigShowMode(ConfigShowMode.AlwaysShow);
game.start();
}
protected void simpleInitGame() {
display.setTitle("SpaceGame");
//physics
getPhysicsSpace().setDirectionalGravity(new Vector3f(0f, 0f, 0f));
staticNode = getPhysicsSpace().createStaticNode();
rootNode.attachChild(staticNode);
dynamicNode = getPhysicsSpace().createDynamicNode();
rootNode.attachChild(dynamicNode);
shipNode = getPhysicsSpace().createDynamicNode();
rootNode.attachChild(shipNode);
//environment
environment = new Environment(rootNode);
rootNode.attachChild(environment);
//light
//TODO
//ship
ship = SGUtil.loadModel("sg/data/models/ships/G6.3ds");
ship.setLocalTranslation(new Vector3f(0,0,-40));
shipNode.attachChild(ship);
//controll
firstPersonHandler = new FirstPersonHandler(ship, shipNode, cam);
}
public void simpleUpdate(){
environment.update();
firstPersonHandler.update(0.1f);
}
}