summaryrefslogtreecommitdiff
path: root/src/tesseract/objects/remote/RemoteObject.java
blob: 7c3e3be3e28ee5f6acdcad89a20e4d93f5d911a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package tesseract.objects.remote;

import java.awt.event.KeyEvent;

import javax.vecmath.Vector3f;

import tesseract.objects.PhysicalObject;

/**
 * Parent class of network controlled objects.
 * 
 * @author jesse
 */
public abstract class RemoteObject extends PhysicalObject {
	/**
	 * Serial UID.
	 */
	private static final long serialVersionUID = -6966379446377480998L;
	
	/**
	 * Privately used by the key controller.
	 */
	private static final float STEP = 0.01f;
	
	public RemoteObject(Vector3f thePosition, float mass) {
		super(thePosition, mass);
	}

	/**
	 * This method is called when a key event is received.
	 * 
	 * @param event The KeyEvent recieved
	 */
	protected void keyEventReceived(final KeyEvent event) {
		switch (event.getKeyCode()) {
			case KeyEvent.VK_W:
				position.z -= STEP;
				break;
				
			case KeyEvent.VK_S:
				position.z += STEP;
				break;
				
			case KeyEvent.VK_A:
				position.x -= STEP;
				break;
				
			case KeyEvent.VK_D:
				position.x += STEP;
				break;
		}
	}

}