From: Kyle Date: Tue, 27 Apr 2010 19:47:01 +0000 (+0000) Subject: git-svn-id: https://bd85.net/svn/cs3505_group@167 92bb83a3-7c8f-8a45-bc97-515c4e399668 X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=692a2af57c7f1586b8513106acf47ddc0ac12748;p=chaz%2Fcarfire git-svn-id: https://bd85.net/svn/cs3505_group@167 92bb83a3-7c8f-8a45-bc97-515c4e399668 --- diff --git a/CarFire/CarFire/CarFire.sln b/CarFire/CarFire/CarFire.sln index 6cd944d..9fa44c7 100644 --- a/CarFire/CarFire/CarFire.sln +++ b/CarFire/CarFire/CarFire.sln @@ -49,6 +49,12 @@ Global {EA5996C5-17A9-4827-AAB8-884B476B62EE}.Release|Xbox 360.Build.0 = Release|Xbox 360 {EA5996C5-17A9-4827-AAB8-884B476B62EE}.Release|Zune.ActiveCfg = Release|Zune {EA5996C5-17A9-4827-AAB8-884B476B62EE}.Release|Zune.Build.0 = Release|Zune + {4F0BE90F-1E46-4959-80A5-E92B578F6A48}.Debug|x86.ActiveCfg = Debug|x86 + {4F0BE90F-1E46-4959-80A5-E92B578F6A48}.Debug|Xbox 360.ActiveCfg = Debug|x86 + {4F0BE90F-1E46-4959-80A5-E92B578F6A48}.Debug|Zune.ActiveCfg = Debug|x86 + {4F0BE90F-1E46-4959-80A5-E92B578F6A48}.Release|x86.ActiveCfg = Release|x86 + {4F0BE90F-1E46-4959-80A5-E92B578F6A48}.Release|Xbox 360.ActiveCfg = Release|x86 + {4F0BE90F-1E46-4959-80A5-E92B578F6A48}.Release|Zune.ActiveCfg = Release|x86 {C115BBCA-D6FD-42AF-B2A1-3E895808BC14}.Debug|x86.ActiveCfg = Debug|x86 {C115BBCA-D6FD-42AF-B2A1-3E895808BC14}.Debug|Xbox 360.ActiveCfg = Debug|x86 {C115BBCA-D6FD-42AF-B2A1-3E895808BC14}.Debug|Zune.ActiveCfg = Debug|x86 diff --git a/CarFire/CarFire/CarFire/AnimateMelee.cs b/CarFire/CarFire/CarFire/AnimateMelee.cs index 05220ee..bda8912 100644 --- a/CarFire/CarFire/CarFire/AnimateMelee.cs +++ b/CarFire/CarFire/CarFire/AnimateMelee.cs @@ -18,12 +18,17 @@ namespace CarFire private ContentManager contentManager; //private GraphicsDeviceManager graphics; //private SpriteBatch spriteBatch; - + private bool changedGraphic; + private string lastPh; private string ph; private Vector2 position; private SpriteBatch character; Player Player; - + + public void Update(TimeSpan timeSpan) + { + SpriteTexture.UpdateFrame(timeSpan); + } //constructor(s) public AnimateMelee(ContentManager content, Player player) { @@ -32,6 +37,7 @@ namespace CarFire ph = fileNames[3]; position = Vector2.Zero; Player = player; + changedGraphic = true; } @@ -40,9 +46,13 @@ namespace CarFire public void AttackLeft(SpriteBatch spriteBatch, Vector2 drawSpot) { ph = fileNames[0]; + if (lastPh == ph) + changedGraphic = false; + else + changedGraphic = true; + lastPh = ph; //graphics = graphicsDeviceManager; //this.spriteBatch = spriteBatch; - //spriteBatch. //character = new SpriteBatch(spriteBatch.GraphicsDevice); character = spriteBatch; Animate(drawSpot); @@ -56,7 +66,8 @@ namespace CarFire //character = new SpriteBatch(graphics.GraphicsDevice); // "character" is the name of the sprite asset in the project. Console.WriteLine(ph); - SpriteTexture.Load(character.GraphicsDevice, contentManager, ph, 8, 12, true, 1); + if(changedGraphic) + SpriteTexture.Load(character.GraphicsDevice, contentManager, ph, 8, 12, true, 1); //viewport = graphics.GraphicsDevice.Viewport; position = new Vector2(Player.Coordinates.X*Map.PixelsToUnitSquares, Player.Coordinates.Y*Map.PixelsToUnitSquares);//viewport.Width / 2, 0);//viewport.Height / 2f); Console.WriteLine(drawSpot); diff --git a/CarFire/CarFire/CarFire/AnimatedTexture.cs b/CarFire/CarFire/CarFire/AnimatedTexture.cs index f4aab89..ff0daff 100644 --- a/CarFire/CarFire/CarFire/AnimatedTexture.cs +++ b/CarFire/CarFire/CarFire/AnimatedTexture.cs @@ -42,8 +42,9 @@ namespace CarFire } // class AnimatedTexture - public void UpdateFrame(float elapsed) + public void UpdateFrame(TimeSpan timeSpan) { + float elapsed = timeSpan.Milliseconds; if (Paused) return; TotalElapsed += elapsed; @@ -51,7 +52,10 @@ namespace CarFire { Frame++; // Keep the Frame between 0 and the total frames, minus one. - Frame = Frame % framecount; + if (framecount != 0) + Frame = Frame % framecount; + else + Console.WriteLine("AHHH!"); TotalElapsed -= TimePerFrame; } //If loop is false and the current Frame is the last frame @@ -72,6 +76,7 @@ namespace CarFire int FrameWidth = myTexture.Width / framecount; Rectangle sourcerect = new Rectangle(FrameWidth * Frame, Row * 64, FrameWidth, 64); + Console.WriteLine(Frame); Batch.Draw(myTexture, screenpos, sourcerect, Color.White, Rotation, Origin, Scale, SpriteEffects.None, Depth); } diff --git a/CarFire/CarFire/CarFire/GameLogic.cs b/CarFire/CarFire/CarFire/GameLogic.cs index dce9fe3..ee5535a 100644 --- a/CarFire/CarFire/CarFire/GameLogic.cs +++ b/CarFire/CarFire/CarFire/GameLogic.cs @@ -79,7 +79,7 @@ namespace CarFire for (int i = 0; i < mGame.State.NumberOfPlayers; i++) { if(mGame.State.mCharacters[i] != null) - mGame.State.mCharacters[i].UpdateInput(timespan, mGame.State.GetKeysDown(i)); + mGame.State.mCharacters[i].Update(timespan, mGame.State.GetKeysDown(i)); } if (mGame.State.mCharacters[thisPlayer] != null) { diff --git a/CarFire/CarFire/CarFire/Melee.cs b/CarFire/CarFire/CarFire/Melee.cs index b597cb3..c6fb6e8 100644 --- a/CarFire/CarFire/CarFire/Melee.cs +++ b/CarFire/CarFire/CarFire/Melee.cs @@ -57,7 +57,10 @@ namespace CarFire animateMelee.AttackLeft(spriteBatch, drawPosition); } - + public override void UpdateFrame(TimeSpan timeSpan) + { + animateMelee.Update(timeSpan); + } public override void Attack(List keysPressed) { if (coolDown > 0) diff --git a/CarFire/CarFire/CarFire/Player.cs b/CarFire/CarFire/CarFire/Player.cs index b531255..a827ae2 100644 --- a/CarFire/CarFire/CarFire/Player.cs +++ b/CarFire/CarFire/CarFire/Player.cs @@ -63,10 +63,15 @@ namespace CarFire { playerHealth -= amount; } - - public void Update(TimeSpan timeSpan) + public void Update(TimeSpan timespan) { + } + public void Update(TimeSpan timeSpan, List keysPressed) + { + UpdatePosition(timeSpan, keysPressed); + Attack(keysPressed); + UpdateFrame(timeSpan); } /// /// Moves the current player being controlled based on a given set of key presses. @@ -137,6 +142,7 @@ namespace CarFire /// public abstract void Draw(SpriteBatch spriteBatch); public abstract void Attack(List keysPressed); + public abstract void UpdateFrame(TimeSpan timeSpan); #endregion diff --git a/CarFire/CarFire/CarFire/Ranged.cs b/CarFire/CarFire/CarFire/Ranged.cs index 4121f94..cb2689e 100644 --- a/CarFire/CarFire/CarFire/Ranged.cs +++ b/CarFire/CarFire/CarFire/Ranged.cs @@ -92,6 +92,10 @@ namespace CarFire } + } + public override void UpdateFrame(TimeSpan timeSpan) + { + throw new NotImplementedException(); } public override void PlayAttackSound() {