63 lines
1.8 KiB
Java
63 lines
1.8 KiB
Java
package mygame;
|
|
|
|
import com.jme3.app.DebugKeysAppState;
|
|
import com.jme3.app.SimpleApplication;
|
|
import com.jme3.app.StatsAppState;
|
|
import com.jme3.material.Material;
|
|
import com.jme3.math.ColorRGBA;
|
|
import com.jme3.math.Vector3f;
|
|
import com.jme3.renderer.RenderManager;
|
|
import com.jme3.scene.Geometry;
|
|
import com.jme3.scene.Spatial;
|
|
import com.jme3.scene.shape.Box;
|
|
|
|
/**
|
|
* @author Snowsun
|
|
*/
|
|
public class Main extends SimpleApplication {
|
|
|
|
private Spatial player;
|
|
private PlayerMouseControl playerMouseControl;
|
|
private PlayerShootControl playerShootControl;
|
|
private WeaponProjectileControl weaponProjectileControl;
|
|
|
|
public Main() {
|
|
super(new StatsAppState(), new DebugKeysAppState());
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
Main app = new Main();
|
|
app.start();
|
|
}
|
|
|
|
@Override
|
|
public void simpleInitApp() {
|
|
Box b = new Box(Vector3f.ZERO, 1, 1, 1);
|
|
player = new Geometry("Player",b);
|
|
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
|
mat.setColor("Color", ColorRGBA.Blue);
|
|
player.setMaterial(mat);
|
|
|
|
inputManager.setCursorVisible(false);
|
|
playerMouseControl = new PlayerMouseControl(inputManager,cam);
|
|
player.addControl(playerMouseControl);
|
|
playerMouseControl.setSpeed(2);
|
|
|
|
playerShootControl = new PlayerShootControl(inputManager);
|
|
player.addControl(playerShootControl);
|
|
|
|
weaponProjectileControl = new WeaponProjectileControl(assetManager, rootNode, inputManager);
|
|
player.addControl(weaponProjectileControl);
|
|
|
|
rootNode.attachChild(player);
|
|
}
|
|
|
|
@Override
|
|
public void simpleUpdate(float tpf) {
|
|
}
|
|
|
|
@Override
|
|
public void simpleRender(RenderManager rm) {
|
|
}
|
|
}
|