summaryrefslogtreecommitdiff
path: root/same-android/src/main/java/com/orbekk/GameController.java
diff options
context:
space:
mode:
Diffstat (limited to 'same-android/src/main/java/com/orbekk/GameController.java')
-rw-r--r--same-android/src/main/java/com/orbekk/GameController.java33
1 files changed, 27 insertions, 6 deletions
diff --git a/same-android/src/main/java/com/orbekk/GameController.java b/same-android/src/main/java/com/orbekk/GameController.java
index 8e1e169..0c11a75 100644
--- a/same-android/src/main/java/com/orbekk/GameController.java
+++ b/same-android/src/main/java/com/orbekk/GameController.java
@@ -6,27 +6,48 @@ import java.util.List;
import android.graphics.Paint;
public class GameController {
- private List<Player> players = new ArrayList<Player>();
+ private List<Player> remotePlayers = new ArrayList<Player>();
private Player localPlayer;
+ private ChangeListener changeListener = null;
public static class Player {
public Paint color;
- public int posX;
- public int posY;
+ public float posX;
+ public float posY;
+ }
+
+ public interface ChangeListener {
+ void playerStatesChanged();
+ }
+
+ public static Player newPlayer() {
+ Player player = new Player();
+ player.color = new Paint();
+ player.color.setARGB(255, 255, 0, 0);
+ player.posX = 0.5f;
+ player.posY = 0.5f;
+ return player;
}
public GameController(Player localPlayer) {
this.localPlayer = localPlayer;
}
+ public void setMyPosition(float x, float y) {
+ this.localPlayer.posX = x;
+ this.localPlayer.posY = y;
+ changeListener.playerStatesChanged();
+ }
+
public Player getLocalPlayer() {
return localPlayer;
}
public List<Player> getRemotePlayers() {
- return players;
+ return remotePlayers;
}
-
-
+ public void setChangeListener(ChangeListener listener) {
+ this.changeListener = listener;
+ }
}