summaryrefslogtreecommitdiff
path: root/same-android/src/main/java/com/orbekk/GameController.java
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-20 11:04:44 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-20 11:04:44 +0100
commit2e0c6dd5ca704b85b15921e9e6707f6c3fcb3c9f (patch)
tree31354e5b2c48a295e1246d0dc9ebf0fb349f4ba3 /same-android/src/main/java/com/orbekk/GameController.java
parent3f5c54d56de87ac2afc51222dfa2373b5bb8238e (diff)
Refactor Android code.
– Make a Controller and a state that supports several players.
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;
+ }
}