]> Dogcows Code - chaz/carfire/commitdiff
Player can now stop and 'aim' by pressing left control.
authorKyle <Kyle@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Tue, 20 Apr 2010 00:49:11 +0000 (00:49 +0000)
committerKyle <Kyle@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Tue, 20 Apr 2010 00:49:11 +0000 (00:49 +0000)
git-svn-id: https://bd85.net/svn/cs3505_group@120 92bb83a3-7c8f-8a45-bc97-515c4e399668

CarFire/CarFire/CarFire/Human.cs
CarFire/CarFire/CarFire/MovementManager.cs

index 8a94fd3822745dcac308baf3e3243d960b615b2f..519d9d02f14908767e150112472c01d7638d6bd1 100644 (file)
@@ -122,13 +122,20 @@ namespace CarFire
                 state = State.down;\r
 \r
             Point destination = MovementManager.GetNeighborCell(mMotion.Coordinates, moveLeft, moveRight, moveUp, moveDown);\r
-            if (theMap.IsCellOpen(destination))\r
+            if (!keysPressed.Contains(Keys.LeftControl))\r
             {\r
-                mMotion.Update(timeSpan, moveLeft, moveRight, moveUp, moveDown);\r
+                if (theMap.IsCellOpen(destination))\r
+                {\r
+                    mMotion.Update(timeSpan, moveLeft, moveRight, moveUp, moveDown);\r
+                }\r
+                else\r
+                {\r
+                    mMotion.Update(timeSpan);\r
+                }\r
             }\r
             else\r
             {\r
-                mMotion.Update(timeSpan);\r
+                mMotion.LockUpdate(timeSpan, moveLeft, moveRight, moveUp, moveDown);\r
             }\r
 \r
 \r
index 3b8dae13a2d0983b3f3b0dfbc4f8f3be39f4da8e..e7002035b6509caec0f80f5e5cf980c21190f8d5 100644 (file)
@@ -153,6 +153,27 @@ namespace CarFire
                 RecalculatePosition(alpha);\r
             }\r
         }\r
+        public void LockUpdate(TimeSpan timeSpan, bool moveLeft, bool moveRight, bool moveUp, bool moveDown)\r
+        {\r
+            float passedTime = (float)timeSpan.TotalSeconds;\r
+            if (moveLeft == true || moveRight == true || moveUp == true || moveDown == true)\r
+            {\r
+                mDirection = GetDirection(moveLeft, moveRight, moveUp, moveDown);\r
+            }\r
+            if (mIsMoving)\r
+            {\r
+                mTimeAccumulator += passedTime;\r
+\r
+                float alpha = mTimeAccumulator / mInverseSpeed;\r
+                if (alpha >= 1.0f)\r
+                {\r
+                    mIsMoving = false;\r
+                    alpha = 1.0f;\r
+                }\r
+\r
+                RecalculatePosition(alpha);\r
+            }\r
+        }\r
 \r
 \r
         /// <summary>\r
This page took 0.027057 seconds and 4 git commands to generate.