package slimpleslickgame;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Input;
import org.newdawn.slick.geom.Vector2f;

import client.ByteMonitor;
import client.MessageWrapper;

public class LocalPlayer extends Player{

	private GameContainer gc;
	private ByteMonitor bm;
	
	public LocalPlayer(GameContainer gc, ByteMonitor bm, byte id){
		this.gc = gc;
		this.bm = bm;
		super.id = id;
	}
	
	public void update(int delta) {
		if(processInput(gc.getInput())){
			if(bm != null){
				bm.putArrayToServer(getPositionBytes(position), id);
			}
			super.updatePosition();
		}
	}
	
	private boolean processInput(Input input) {
		Vector2f direction = new Vector2f(0, 0);
		boolean dirChanged = false;

		if (input.isKeyDown(Input.KEY_LEFT)) {
			direction.add(new Vector2f(-1, 0));
			dirChanged = true;
		}

		if (input.isKeyDown(Input.KEY_RIGHT)) {
			direction.add(new Vector2f(1, 0));
			dirChanged = true;
		}

		if (input.isKeyDown(Input.KEY_UP)) {
			direction.add(new Vector2f(0, -1));
			dirChanged = true;
		}

		if (input.isKeyDown(Input.KEY_DOWN)) {
			direction.add(new Vector2f(0, 1));
			dirChanged = true;
		}
		//System.out.println("Input processed, direction: " + direction);
		// TODO: add shooting capabilities
		super.setDirection(direction);
		return dirChanged;
	}
	
	public byte[] getPositionBytes(Vector2f pos){
		return MessageWrapper.getPositionBytes(pos);
	}

}

@@ -516,16 +516,31 @@
 oServer(
+MessageWrapper.
 getPosit
@@ -1313,107 +1313,8 @@
 ;%0A%09%7D
-%0A%09%0A%09public byte%5B%5D getPositionBytes(Vector2f pos)%7B%0A%09%09return MessageWrapper.getPositionBytes(pos);%0A%09%7D
 %0A%0A%7D%0A

remove nilles useless method