]> Dogcows Code - chaz/carfire/blobdiff - CarFire/CarFire/CarFire/Player.cs
Changed speed of player and projectiles
[chaz/carfire] / CarFire / CarFire / CarFire / Player.cs
index b84b04846158bd63d4f04830a4759c6cd7bc61c2..b5312550630b1e64a5c4927ee618e174ca26e34e 100644 (file)
@@ -14,7 +14,7 @@ namespace CarFire
     {\r
         #region Member variables\r
         //The number of frames between each projectile is spawned.\r
-        const float basePlayerSpeed = 4.0f;\r
+        const float basePlayerSpeed = 8.0f;\r
         const int shootCoolDown = 18;\r
         String CharName;\r
         Game game;\r
@@ -38,7 +38,7 @@ namespace CarFire
         public Point Coordinates { get { return mMotion.Coordinates; }\r
             set\r
             {\r
-                Coordinates = value;\r
+                mMotion.Coordinates = value;\r
                 mMotion = new MovementManager(value, basePlayerSpeed);\r
             } }\r
         public char Identifier { get { return mPlayerIndex.ToString()[0]; } }\r
@@ -57,7 +57,7 @@ namespace CarFire
             mPlayerIndex = playerIndex;\r
 \r
             // Speed is the number of grid cells you can move through per second.\r
-            mMotion = new MovementManager(position, 4.0f);\r
+            mMotion = new MovementManager(position, basePlayerSpeed);\r
         }\r
         public void causeDamageTo(int amount)\r
         {\r
@@ -88,22 +88,24 @@ namespace CarFire
             bool moveRight = keysPressed.Contains(Keys.Right);\r
             bool moveUp = keysPressed.Contains(Keys.Up);\r
             bool moveDown = keysPressed.Contains(Keys.Down);\r
-            Point destination = MovementManager.GetNeighborCell(mMotion.Coordinates, moveLeft, moveRight, moveUp, moveDown);\r
-            if (!keysPressed.Contains(Keys.LeftControl))\r
+\r
+            List<Point> possibleDestinations = new List<Point>(3);\r
+            possibleDestinations.Add(MovementManager.GetNeighbor(mMotion.Coordinates, moveLeft, moveRight, moveUp, moveDown));\r
+            possibleDestinations.AddRange(MovementManager.GetNeighbors(mMotion.Coordinates, possibleDestinations[0]));\r
+\r
+            Direction direction = Direction.None;\r
+            foreach (Point destination in possibleDestinations)\r
             {\r
                 if (game.IsCellOpen(destination))\r
                 {\r
-                    mMotion.Update(timeSpan, moveLeft, moveRight, moveUp, moveDown);\r
-                }\r
-                else\r
-                {\r
-                    mMotion.Update(timeSpan);\r
+                    direction = MovementManager.GetDirection(mMotion.Coordinates, destination);\r
+                    break;\r
                 }\r
             }\r
-            else\r
-            {\r
-                mMotion.LockUpdate(timeSpan, moveLeft, moveRight, moveUp, moveDown);\r
-            }\r
+\r
+            if (direction != Direction.None && !keysPressed.Contains(Keys.LeftControl)) \r
+                mMotion.Update(timeSpan, direction);\r
+            else mMotion.LockUpdate(timeSpan, moveLeft, moveRight, moveUp, moveDown);\r
         }\r
         \r
         public void powerUp(int amount)\r
This page took 0.020248 seconds and 4 git commands to generate.