space-game/src/sg/SpaceGame.java

60 lines
1.7 KiB
Java
Raw Normal View History

2009-03-08 17:25:15 +00:00
package sg;
2009-03-10 13:41:26 +00:00
import sg.env.Environment;
2009-03-11 14:56:11 +00:00
import sg.input.FirstPersonHandler;
2009-03-10 17:35:12 +00:00
import sg.util.SGUtil;
2009-03-10 13:41:26 +00:00
2009-03-10 17:35:12 +00:00
import com.jme.scene.Node;
2009-03-09 10:32:07 +00:00
import com.jme.math.Vector3f;
2009-03-10 15:27:00 +00:00
import com.jmex.physics.DynamicPhysicsNode;
import com.jmex.physics.StaticPhysicsNode;
import com.jmex.physics.util.SimplePhysicsGame;
2009-03-09 09:59:22 +00:00
2009-03-10 15:27:00 +00:00
public class SpaceGame extends SimplePhysicsGame {
private StaticPhysicsNode staticNode;
private DynamicPhysicsNode dynamicNode;
2009-03-10 13:41:26 +00:00
private Environment environment;
2009-03-11 14:56:11 +00:00
private Node ship;
private DynamicPhysicsNode shipNode;
private FirstPersonHandler firstPersonHandler;
2009-03-08 17:25:15 +00:00
public static void main(String[] args) {
2009-03-10 17:35:12 +00:00
//Logger.getLogger("").setLevel( Level.WARNING );
2009-03-10 13:04:15 +00:00
SpaceGame game = new SpaceGame();
2009-03-10 15:27:00 +00:00
game.setConfigShowMode(ConfigShowMode.AlwaysShow);
2009-03-10 15:47:13 +00:00
game.start();
2009-03-09 09:59:22 +00:00
}
protected void simpleInitGame() {
display.setTitle("SpaceGame");
2009-03-10 13:41:26 +00:00
//physics
2009-03-10 15:27:00 +00:00
getPhysicsSpace().setDirectionalGravity(new Vector3f(0f, 0f, 0f));
staticNode = getPhysicsSpace().createStaticNode();
rootNode.attachChild(staticNode);
dynamicNode = getPhysicsSpace().createDynamicNode();
rootNode.attachChild(dynamicNode);
2009-03-11 14:56:11 +00:00
shipNode = getPhysicsSpace().createDynamicNode();
rootNode.attachChild(shipNode);
2009-03-10 13:41:26 +00:00
//environment
2009-03-11 14:56:11 +00:00
environment = new Environment(rootNode);
2009-03-10 13:41:26 +00:00
rootNode.attachChild(environment);
2009-03-10 15:27:00 +00:00
2009-03-10 13:58:05 +00:00
//light
//TODO
2009-03-11 11:39:34 +00:00
2009-03-11 14:56:11 +00:00
//ship
ship = SGUtil.loadModel("sg/data/models/ships/G6.3ds");
2009-03-10 17:35:12 +00:00
ship.setLocalTranslation(new Vector3f(0,0,-40));
2009-03-11 14:56:11 +00:00
shipNode.attachChild(ship);
//controll
firstPersonHandler = new FirstPersonHandler(ship, shipNode, cam);
2009-03-09 09:59:22 +00:00
}
2009-03-09 10:32:07 +00:00
2009-03-09 09:59:22 +00:00
public void simpleUpdate(){
2009-03-10 16:32:33 +00:00
environment.update();
2009-03-11 14:56:11 +00:00
firstPersonHandler.update(0.1f);
2009-03-11 11:39:34 +00:00
}
2009-03-09 09:59:22 +00:00
}