瀏覽代碼

Remapped keys to WASDX.

master
Dejvino 7 年之前
父節點
當前提交
2a4cc65a81
共有 2 個文件被更改,包括 14 次插入8 次删除
  1. +1
    -1
      README.md
  2. +13
    -7
      src/roadtrip/RoadTrip.java

+ 1
- 1
README.md 查看文件

@@ -6,7 +6,7 @@ A game about a journey involving vehicles and obstacles.
## Status
### DONE
* Physics-based vehicles
* Driving controls (UHJKM)
* Driving controls (WASDX)
* Enter / Exit a car (Enter)
* Camera following the player
* Hilly ground


+ 13
- 7
src/roadtrip/RoadTrip.java 查看文件

@@ -70,7 +70,7 @@ public class RoadTrip extends SimpleApplication implements ActionListener {
addMap();
DirectionalLight dl = new DirectionalLight();
dl.setColor(ColorRGBA.White);
dl.setColor(ColorRGBA.LightGray);
dl.setDirection(new Vector3f(1, -1, 1));
rootNode.addLight(dl);
@@ -95,13 +95,15 @@ public class RoadTrip extends SimpleApplication implements ActionListener {
}
private void setupKeys() {
inputManager.addMapping("Lefts", new KeyTrigger(KeyInput.KEY_H));
inputManager.addMapping("Rights", new KeyTrigger(KeyInput.KEY_K));
inputManager.addMapping("Ups", new KeyTrigger(KeyInput.KEY_U));
inputManager.addMapping("Downs", new KeyTrigger(KeyInput.KEY_J));
inputManager.addMapping("Revs", new KeyTrigger(KeyInput.KEY_M));
inputManager.clearMappings();
inputManager.addMapping("Lefts", new KeyTrigger(KeyInput.KEY_A));
inputManager.addMapping("Rights", new KeyTrigger(KeyInput.KEY_D));
inputManager.addMapping("Ups", new KeyTrigger(KeyInput.KEY_W));
inputManager.addMapping("Downs", new KeyTrigger(KeyInput.KEY_S));
inputManager.addMapping("Revs", new KeyTrigger(KeyInput.KEY_X));
inputManager.addMapping("Space", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addMapping("Reset", new KeyTrigger(KeyInput.KEY_RETURN));
inputManager.addMapping("Esc", new KeyTrigger(KeyInput.KEY_ESCAPE));
inputManager.addListener(this, "Lefts");
inputManager.addListener(this, "Rights");
inputManager.addListener(this, "Ups");
@@ -109,6 +111,7 @@ public class RoadTrip extends SimpleApplication implements ActionListener {
inputManager.addListener(this, "Revs");
inputManager.addListener(this, "Space");
inputManager.addListener(this, "Reset");
inputManager.addListener(this, "Esc");
}
private void addCar()
@@ -276,7 +279,7 @@ public class RoadTrip extends SimpleApplication implements ActionListener {
vehicle.addControl(vehicleControl);
getPhysicsSpace().add(vehicleControl);
vehicleControl.setPhysicsLocation(new Vector3f(10f + (float)Math.random() * 20f, 30f, 12f + (float)Math.random() * 20f));
vehicleControl.setPhysicsLocation(new Vector3f(10f + (float)Math.random() * 40f, 28f, 12f + (float)Math.random() * 40f));
vehicles.add(vehicle);
rootNode.attachChild(vehicle);
@@ -458,6 +461,9 @@ public class RoadTrip extends SimpleApplication implements ActionListener {
}
}
}
if (binding.equals("Esc")) {
stop();
}
}
private Node addPerson() {


Loading…
取消
儲存