Now uses network to update character position
authorKyle <Kyle@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Mon, 19 Apr 2010 02:11:40 +0000 (02:11 +0000)
committerKyle <Kyle@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Mon, 19 Apr 2010 02:11:40 +0000 (02:11 +0000)
git-svn-id: https://bd85.net/svn/cs3505_group@98 92bb83a3-7c8f-8a45-bc97-515c4e399668

CarFire/CarFire/CarFire/Display.cs

index 8f4fbdc..27f151e 100644 (file)
@@ -1,4 +1,4 @@
-#define SINGLE_TEST\r
+#undef SINGLE_TEST\r
 \r
 using System;\r
 using System.Collections.Generic;\r
@@ -16,8 +16,10 @@ namespace CarFire
     /// </summary>\r
     public class Display\r
     {\r
+        bool playerChosen = false;\r
         List<Projectile> mProjectiles = new List<Projectile>();\r
-        List<IPlayer> mCharacters = new List<IPlayer>();\r
+        //List<IPlayer> mCharacters = new List<IPlayer>();\r
+        IPlayer[] mCharacters = new IPlayer[4];\r
         Texture2D everything;\r
         Map mMap;\r
         int currentCenterX = 5;\r
@@ -75,8 +77,9 @@ namespace CarFire
         /// checking for collisions, gathering input, and playing audio.\r
         /// </summary>\r
         /// <param name="gameTime">Provides a snapshot of timing values.</param>\r
-        public void Update(TimeSpan timespan)\r
+        public void Update(TimeSpan timespan, GameState state)\r
         {\r
+            \r
             //INPUT - testing input... has to be through network later\r
 #if SINGLE_TEST\r
             KeyboardState keyState = Keyboard.GetState();\r
@@ -101,7 +104,24 @@ namespace CarFire
             }\r
             mMap.CenterCell = new Vector2(mCharacters[0].GridX, mCharacters[0].GridY);\r
 #endif\r
-\r
+            \r
+            for (int i = 0; i < 4; i++)\r
+            {\r
+                if (mCharacters[i] == null)\r
+                {\r
+                    if(state.keysDown[i].Contains(Keys.Enter))\r
+                    {\r
+                        mCharacters[i] = (new Human(mMap, "", everything));\r
+                        mCharacters[i].GridX = mMap.GetStartingPositionForPlayer(i+1).X;\r
+                        mCharacters[i].GridY = mMap.GetStartingPositionForPlayer(i+1).Y;\r
+                    }\r
+                }\r
+                else\r
+                {\r
+                    mMap.CenterCell = new Vector2(mCharacters[0].GridX, mCharacters[0].GridY);\r
+                    mCharacters[i].MovePlayer(state.keysDown[i]);\r
+                }\r
+            }\r
             for (int i = 0; i < mProjectiles.Count; i++ )\r
             {\r
                 mProjectiles[i].Update(timespan);\r
@@ -113,10 +133,10 @@ namespace CarFire
                 }\r
             }\r
             //Check for collisons\r
-            for (int j = 0; j < mCharacters.Count; j++) \r
+            for (int j = 0; j < mCharacters.Length; j++) \r
             {\r
                \r
-                \r
+                if(mCharacters[j] != null)\r
                 for (int i = 0; i < mProjectiles.Count; i++)\r
                 {\r
                     if (mProjectiles[i].GridX == mCharacters[j].GridX && mProjectiles[i].GridY == mCharacters[j].GridY)\r
@@ -142,15 +162,17 @@ namespace CarFire
                 projectile.Draw(spriteBatch);\r
                 \r
             }\r
-            foreach(IPlayer character in mCharacters)\r
+            for(int i = 0; i < 4; i++)//IPlayer character in mCharacters)\r
             {\r
-                character.Draw(spriteBatch);\r
+                if(mCharacters[i] != null)\r
+                    mCharacters[i].Draw(spriteBatch);\r
             } \r
         }\r
 \r
         public void AddCharacters(IPlayer player)\r
         {\r
-            mCharacters.Add(player);\r
+            mCharacters[mCharacters.Length] = player;\r
+            //mCharacters.Add(player);\r
         }\r
     }\r
 }\r
This page took 0.027603 seconds and 4 git commands to generate.