proto p2
authorterom
Mon, 03 Nov 2008 21:36:17 +0000
changeset 3 5a209a8585c9
parent 2 24d2ec240473
child 4 e28b28b8817c
proto p2
proto/p2/Dimension.hh
proto/p2/GameState.hh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/proto/p2/Dimension.hh	Mon Nov 03 21:36:17 2008 +0000
@@ -0,0 +1,33 @@
+#ifndef DIMENSION_HH
+#define DIMENSION_HH
+
+class Dimension {
+	public:
+		uint32_t width;
+		uint32_t height;
+
+		Dimension (uint32_t width, uint32_t height) : width(width), height(height) { }
+};
+
+class Coordinate {
+	public:
+		uint32_t x;
+		uint32_t y;
+
+		Coordinate (uint32_t x, uint32_t y) : x(x), y(y) { }
+
+		Coordinate &operator+= (const PositionDelta &d) {
+			this->x += d.dx;
+			this->y += d.dy;
+		}
+};
+
+class PositionDelta {
+	public:
+		uint32_t dx;
+		uint32_t dy;
+
+		PositionDelta (uint32_t dx, uint32_t dy) : dx(dx), dy(dy) { }
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/proto/p2/GameState.hh	Mon Nov 03 21:36:17 2008 +0000
@@ -0,0 +1,48 @@
+#ifndef GAMESTATE_HH
+#define GAMESTATE_HH
+
+class GameState {
+	public:
+		Dimension map_dimensions;
+		std::list<Player> player_list;
+
+		LocalPlayer &getLocalPlayer (void) {
+			// XXX: jotain
+		}
+};
+
+enum PlayerType {
+	PLAYER_LOCAL = 0x01;
+	PLAYER_REMOTE = 0x02;
+};
+
+class Player {
+	private:
+		Coordinate position;
+
+	public:
+		PlayerType type;
+		Dimensions dimensions;
+
+		Coordinate getPosition (void) {
+			return this->position;
+		}
+};
+
+class LocalPlayer : public Player {
+	public:
+		void doMovement (PositionDelta d) {
+			this->position += d;
+
+			// XXX: notify server
+		}
+};
+
+class RemotePlayer : public Player {
+	public:
+		void updatePosition (Position p) {
+			this->position = p;
+		}
+}
+
+#endif