]> Dogcows Code - chaz/carfire/commitdiff
git-svn-id: https://bd85.net/svn/cs3505_group@167 92bb83a3-7c8f-8a45-bc97-515c4e399668
authorKyle <Kyle@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Tue, 27 Apr 2010 19:47:01 +0000 (19:47 +0000)
committerKyle <Kyle@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Tue, 27 Apr 2010 19:47:01 +0000 (19:47 +0000)
CarFire/CarFire/CarFire.sln
CarFire/CarFire/CarFire/AnimateMelee.cs
CarFire/CarFire/CarFire/AnimatedTexture.cs
CarFire/CarFire/CarFire/GameLogic.cs
CarFire/CarFire/CarFire/Melee.cs
CarFire/CarFire/CarFire/Player.cs
CarFire/CarFire/CarFire/Ranged.cs

index 6cd944df6c1bbb085485eb0868103d739602b03d..9fa44c71bed6acd8043d0b26675080687a685025 100644 (file)
@@ -49,6 +49,12 @@ Global
                {EA5996C5-17A9-4827-AAB8-884B476B62EE}.Release|Xbox 360.Build.0 = Release|Xbox 360\r
                {EA5996C5-17A9-4827-AAB8-884B476B62EE}.Release|Zune.ActiveCfg = Release|Zune\r
                {EA5996C5-17A9-4827-AAB8-884B476B62EE}.Release|Zune.Build.0 = Release|Zune\r
+               {4F0BE90F-1E46-4959-80A5-E92B578F6A48}.Debug|x86.ActiveCfg = Debug|x86\r
+               {4F0BE90F-1E46-4959-80A5-E92B578F6A48}.Debug|Xbox 360.ActiveCfg = Debug|x86\r
+               {4F0BE90F-1E46-4959-80A5-E92B578F6A48}.Debug|Zune.ActiveCfg = Debug|x86\r
+               {4F0BE90F-1E46-4959-80A5-E92B578F6A48}.Release|x86.ActiveCfg = Release|x86\r
+               {4F0BE90F-1E46-4959-80A5-E92B578F6A48}.Release|Xbox 360.ActiveCfg = Release|x86\r
+               {4F0BE90F-1E46-4959-80A5-E92B578F6A48}.Release|Zune.ActiveCfg = Release|x86\r
                {C115BBCA-D6FD-42AF-B2A1-3E895808BC14}.Debug|x86.ActiveCfg = Debug|x86\r
                {C115BBCA-D6FD-42AF-B2A1-3E895808BC14}.Debug|Xbox 360.ActiveCfg = Debug|x86\r
                {C115BBCA-D6FD-42AF-B2A1-3E895808BC14}.Debug|Zune.ActiveCfg = Debug|x86\r
index 05220ee7c367c29254777ef3db364ce7d29f2faf..bda8912f9bfe602fb7d6f2e28a28fd8dd75d1a73 100644 (file)
@@ -18,12 +18,17 @@ namespace CarFire
         private ContentManager contentManager;\r
         //private GraphicsDeviceManager graphics;\r
         //private SpriteBatch spriteBatch;\r
-\r
+        private bool changedGraphic;\r
+        private string lastPh;\r
         private string ph;\r
         private Vector2 position;\r
         private SpriteBatch character;\r
         Player Player;\r
-\r
+        \r
+        public void Update(TimeSpan timeSpan)\r
+        {\r
+            SpriteTexture.UpdateFrame(timeSpan);\r
+        }\r
         //constructor(s)\r
         public AnimateMelee(ContentManager content, Player player)\r
         {\r
@@ -32,6 +37,7 @@ namespace CarFire
             ph = fileNames[3];\r
             position = Vector2.Zero;\r
             Player = player;\r
+            changedGraphic = true;\r
             \r
         }\r
 \r
@@ -40,9 +46,13 @@ namespace CarFire
         public void AttackLeft(SpriteBatch spriteBatch, Vector2 drawSpot)\r
         {\r
             ph = fileNames[0];\r
+            if (lastPh == ph)\r
+                changedGraphic = false;\r
+            else\r
+                changedGraphic = true;\r
+            lastPh = ph;\r
             //graphics = graphicsDeviceManager;\r
             //this.spriteBatch = spriteBatch;\r
-            //spriteBatch.\r
             //character = new SpriteBatch(spriteBatch.GraphicsDevice);\r
             character = spriteBatch;\r
             Animate(drawSpot);\r
@@ -56,7 +66,8 @@ namespace CarFire
             //character = new SpriteBatch(graphics.GraphicsDevice);\r
             // "character" is the name of the sprite asset in the project.\r
             Console.WriteLine(ph);\r
-            SpriteTexture.Load(character.GraphicsDevice, contentManager, ph, 8, 12, true, 1);\r
+            if(changedGraphic)\r
+                SpriteTexture.Load(character.GraphicsDevice, contentManager, ph, 8, 12, true, 1);\r
             //viewport = graphics.GraphicsDevice.Viewport;\r
             position = new Vector2(Player.Coordinates.X*Map.PixelsToUnitSquares, Player.Coordinates.Y*Map.PixelsToUnitSquares);//viewport.Width / 2, 0);//viewport.Height / 2f);\r
             Console.WriteLine(drawSpot);\r
index f4aab89f93c59103a74c9c10a55a72d36909da75..ff0daffe1047a40d9b8ca2be275e2ac5bf45ac6c 100644 (file)
@@ -42,8 +42,9 @@ namespace CarFire
         }\r
 \r
         // class AnimatedTexture\r
-        public void UpdateFrame(float elapsed)\r
+        public void UpdateFrame(TimeSpan timeSpan)\r
         {\r
+            float elapsed = timeSpan.Milliseconds;\r
             if (Paused)\r
                 return;\r
             TotalElapsed += elapsed;\r
@@ -51,7 +52,10 @@ namespace CarFire
             {\r
                 Frame++;\r
                 // Keep the Frame between 0 and the total frames, minus one.\r
-                Frame = Frame % framecount;\r
+                if (framecount != 0)\r
+                    Frame = Frame % framecount;\r
+                else\r
+                    Console.WriteLine("AHHH!");\r
                 TotalElapsed -= TimePerFrame;\r
             }\r
             //If loop is false and the current Frame is the last frame \r
@@ -72,6 +76,7 @@ namespace CarFire
             int FrameWidth = myTexture.Width / framecount;\r
             Rectangle sourcerect = new Rectangle(FrameWidth * Frame, Row * 64,\r
                 FrameWidth, 64);\r
+            Console.WriteLine(Frame);\r
             Batch.Draw(myTexture, screenpos, sourcerect, Color.White,\r
                 Rotation, Origin, Scale, SpriteEffects.None, Depth);\r
         }\r
index dce9fe33d206bb77111b40c56aeee8cafa121a34..ee5535a433e3274da0484ee5af51404459c3d25e 100644 (file)
@@ -79,7 +79,7 @@ namespace CarFire
             for (int i = 0; i < mGame.State.NumberOfPlayers; i++)\r
             {\r
                 if(mGame.State.mCharacters[i] != null)\r
-                    mGame.State.mCharacters[i].UpdateInput(timespan, mGame.State.GetKeysDown(i));\r
+                    mGame.State.mCharacters[i].Update(timespan, mGame.State.GetKeysDown(i));\r
             }\r
             if (mGame.State.mCharacters[thisPlayer] != null)\r
             {\r
index b597cb37a856cff74290d2f89c269f48a8831f98..c6fb6e82f6aa48ef4094d67628e0ece327d097dc 100644 (file)
@@ -57,7 +57,10 @@ namespace CarFire
             animateMelee.AttackLeft(spriteBatch, drawPosition);\r
             \r
         }\r
-\r
+        public override void UpdateFrame(TimeSpan timeSpan)\r
+        {\r
+            animateMelee.Update(timeSpan);\r
+        }\r
         public override void Attack(List<Keys> keysPressed)\r
         {\r
             if (coolDown > 0)\r
index b5312550630b1e64a5c4927ee618e174ca26e34e..a827ae250001a9afe4997a29bb36d55c3d6886f7 100644 (file)
@@ -63,10 +63,15 @@ namespace CarFire
         {\r
             playerHealth -= amount;\r
         }\r
-\r
-        public void Update(TimeSpan timeSpan)\r
+        public void Update(TimeSpan timespan)\r
         {\r
 \r
+        }\r
+        public void Update(TimeSpan timeSpan, List<Keys> keysPressed)\r
+        {\r
+            UpdatePosition(timeSpan, keysPressed);\r
+            Attack(keysPressed);\r
+            UpdateFrame(timeSpan);\r
         }\r
         /// <summary>\r
         /// Moves the current player being controlled based on a given set of key presses.\r
@@ -137,6 +142,7 @@ namespace CarFire
         /// <param name="spriteBatch"></param>\r
         public abstract void Draw(SpriteBatch spriteBatch);\r
         public abstract void Attack(List<Keys> keysPressed);\r
+        public abstract void UpdateFrame(TimeSpan timeSpan);\r
         #endregion\r
 \r
 \r
index 4121f94129fffc4e568fc850dad6fce21f24de53..cb2689e92388e9ada232efceb33341784d543c74 100644 (file)
@@ -92,6 +92,10 @@ namespace CarFire
             }\r
              \r
                 \r
+        }\r
+        public override void UpdateFrame(TimeSpan timeSpan)\r
+        {\r
+            throw new NotImplementedException();\r
         }\r
         public override void PlayAttackSound()\r
         {\r
This page took 0.028252 seconds and 4 git commands to generate.