Add game source, converter pipeline, and web port
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.jme3.app.SimpleApplication
|
||||
* com.jme3.input.controls.ActionListener
|
||||
* com.jme3.input.controls.AnalogListener
|
||||
* com.jme3.input.controls.InputListener
|
||||
* com.jme3.input.controls.KeyTrigger
|
||||
* com.jme3.input.controls.MouseAxisTrigger
|
||||
* com.jme3.input.controls.MouseButtonTrigger
|
||||
* com.jme3.input.controls.Trigger
|
||||
* com.jme3.light.DirectionalLight
|
||||
* com.jme3.light.Light
|
||||
* com.jme3.material.Material
|
||||
* com.jme3.math.ColorRGBA
|
||||
* com.jme3.math.Vector3f
|
||||
* com.jme3.scene.Geometry
|
||||
* com.jme3.scene.Mesh
|
||||
* com.jme3.scene.Spatial
|
||||
* com.jme3.scene.shape.Box
|
||||
*/
|
||||
package jme3.hello;
|
||||
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.input.controls.AnalogListener;
|
||||
import com.jme3.input.controls.InputListener;
|
||||
import com.jme3.input.controls.KeyTrigger;
|
||||
import com.jme3.input.controls.MouseAxisTrigger;
|
||||
import com.jme3.input.controls.MouseButtonTrigger;
|
||||
import com.jme3.input.controls.Trigger;
|
||||
import com.jme3.light.DirectionalLight;
|
||||
import com.jme3.light.Light;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Mesh;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.shape.Box;
|
||||
|
||||
public class HelloInput
|
||||
extends SimpleApplication {
|
||||
protected Geometry player;
|
||||
boolean isRunning = true;
|
||||
private ActionListener actionListener = new ActionListener(){
|
||||
|
||||
public void onAction(String name, boolean keyPressed, float tpf) {
|
||||
if (name.equals("Pause") && !keyPressed) {
|
||||
HelloInput.this.isRunning = !HelloInput.this.isRunning;
|
||||
}
|
||||
}
|
||||
};
|
||||
private AnalogListener analogListener = new AnalogListener(){
|
||||
|
||||
public void onAnalog(String name, float value, float tpf) {
|
||||
if (HelloInput.this.isRunning) {
|
||||
Vector3f v;
|
||||
if (name.equals("RotateLeft")) {
|
||||
HelloInput.this.player.rotate(0.0f, value * HelloInput.this.speed, 0.0f);
|
||||
}
|
||||
if (name.equals("RotateRight")) {
|
||||
HelloInput.this.player.rotate(0.0f, value * -HelloInput.this.speed, 0.0f);
|
||||
}
|
||||
if (name.equals("Right")) {
|
||||
v = HelloInput.this.player.getLocalTranslation();
|
||||
HelloInput.this.player.setLocalTranslation(v.x + value * HelloInput.this.speed, v.y, v.z);
|
||||
}
|
||||
if (name.equals("Left")) {
|
||||
v = HelloInput.this.player.getLocalTranslation();
|
||||
HelloInput.this.player.setLocalTranslation(v.x - value * HelloInput.this.speed, v.y, v.z);
|
||||
}
|
||||
if (name.equals("Up")) {
|
||||
v = HelloInput.this.player.getLocalTranslation();
|
||||
HelloInput.this.player.setLocalTranslation(v.x, v.y + value * HelloInput.this.speed, v.z);
|
||||
}
|
||||
if (name.equals("Down")) {
|
||||
v = HelloInput.this.player.getLocalTranslation();
|
||||
HelloInput.this.player.setLocalTranslation(v.x, v.y - value * HelloInput.this.speed, v.z);
|
||||
}
|
||||
} else {
|
||||
System.out.println("Press P to unpause.");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static void main(String[] args) {
|
||||
HelloInput app = new HelloInput();
|
||||
app.start();
|
||||
}
|
||||
|
||||
public void simpleInitApp() {
|
||||
Box b = new Box(Vector3f.ZERO, 1.0f, 1.0f, 1.0f);
|
||||
this.player = new Geometry("Player", (Mesh)b);
|
||||
Material mat = new Material(this.assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat.setColor("Color", ColorRGBA.randomColor());
|
||||
this.player.setMaterial(mat);
|
||||
this.rootNode.attachChild((Spatial)this.player);
|
||||
this.initKeys();
|
||||
Spatial gameLevel = this.assetManager.loadModel("Scenes/main.j3o");
|
||||
gameLevel.setLocalTranslation(0.0f, -5.2f, 0.0f);
|
||||
gameLevel.setLocalScale(2.0f);
|
||||
this.rootNode.attachChild(gameLevel);
|
||||
DirectionalLight sun = new DirectionalLight();
|
||||
sun.setColor(ColorRGBA.White);
|
||||
sun.setDirection(new Vector3f(-0.5f, -0.5f, -0.5f).normalizeLocal());
|
||||
this.rootNode.addLight((Light)sun);
|
||||
}
|
||||
|
||||
private void initKeys() {
|
||||
this.inputManager.addMapping("Pause", new Trigger[]{new KeyTrigger(25)});
|
||||
this.inputManager.addMapping("Left", new Trigger[]{new KeyTrigger(36)});
|
||||
this.inputManager.addMapping("Right", new Trigger[]{new KeyTrigger(38)});
|
||||
this.inputManager.addMapping("Up", new Trigger[]{new KeyTrigger(23), new MouseAxisTrigger(2, true)});
|
||||
this.inputManager.addMapping("Down", new Trigger[]{new KeyTrigger(37), new MouseAxisTrigger(2, false)});
|
||||
this.inputManager.addMapping("RotateLeft", new Trigger[]{new KeyTrigger(57), new MouseButtonTrigger(0)});
|
||||
this.inputManager.addMapping("RotateRight", new Trigger[]{new MouseButtonTrigger(1)});
|
||||
this.inputManager.addListener((InputListener)this.actionListener, new String[]{"Pause"});
|
||||
this.inputManager.addListener((InputListener)this.analogListener, new String[]{"Left", "Right", "RotateLeft", "RotateRight", "Up", "Down"});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user