Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Working on player input handling.

  • Loading branch information...
commit 25d1f14861e630c7691c7e92f2977477506d061d 1 parent 54c5200
zzorn authored May 14, 2011
1  src/main/scala/org/jmespike/controls/EntityControl.scala
@@ -14,6 +14,7 @@ import com.jme3.scene.{Node, Spatial}
14 14
  * If a conf is supplied, will listen to changes to it and call confUpdated during an update after it is changed.
15 15
  * NOTE: Should only be used on spatials of type Node.
16 16
  */
  17
+// TODO: Should this class handle input actions also?
17 18
 abstract class EntityControl[T <: ControlConf](conf: T) extends AbstractControl {
18 19
 
19 20
   private var enabledChanged = true // Call onEnabled during first update.
11  src/main/scala/org/jmespike/input/SteeringConf.scala
... ...
@@ -0,0 +1,11 @@
  1
+package org.jmespike.input
  2
+
  3
+import org.jmespike.controls.ControlConf
  4
+
  5
+/**
  6
+ * 
  7
+ */
  8
+
  9
+class SteeringConf extends ControlConf {
  10
+  def createControl(seed: Int) = new SteeringControl()
  11
+}
32  src/main/scala/org/jmespike/input/SteeringControl.scala
... ...
@@ -0,0 +1,32 @@
  1
+package org.jmespike.input
  2
+
  3
+import org.jmespike.controls.EntityControl
  4
+import com.jme3.input.controls.ActionListener
  5
+import java.lang.String
  6
+import InputNames._
  7
+
  8
+/**
  9
+ * Receives steering information from user input (via an activity)
  10
+ * or through direct setting by AIs (or remote players).
  11
+ */
  12
+// TODO: Separate the sourcing of input from a player, an AI, the network, etc, and the use of that input to control something
  13
+// Current planned path of user input is:
  14
+// Keyboard -> JME Input handling -> game Activity -> player entity -> steering control -> propulsion control -> physics control
  15
+// Instead, make EntityControl support registering listeners, and do
  16
+// Keyboard -> JME Input handling -> input distributor app state -> entity control -> player steering control -> propulsion control -> physics control
  17
+class SteeringControl extends EntityControl(null) with ActionListener {
  18
+
  19
+  // Desired target orientation
  20
+
  21
+  // Desired speed, 
  22
+
  23
+
  24
+  def onAction(name: String, isPressed: Boolean, tpf: Float) {
  25
+    name match {
  26
+      case Up =>
  27
+      case Down =>
  28
+      case _ => // Ignore
  29
+    }
  30
+  }
  31
+
  32
+}

0 notes on commit 25d1f14

Please sign in to comment.
Something went wrong with that request. Please try again.