From: Kyle Date: Mon, 19 Apr 2010 02:11:40 +0000 (+0000) Subject: Now uses network to update character position X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=577ff3be4678ec954c84d1b7eb3639ac04c08009;p=chaz%2Fcarfire Now uses network to update character position git-svn-id: https://bd85.net/svn/cs3505_group@98 92bb83a3-7c8f-8a45-bc97-515c4e399668 --- diff --git a/CarFire/CarFire/CarFire/Display.cs b/CarFire/CarFire/CarFire/Display.cs index 8f4fbdc..27f151e 100644 --- a/CarFire/CarFire/CarFire/Display.cs +++ b/CarFire/CarFire/CarFire/Display.cs @@ -1,4 +1,4 @@ -#define SINGLE_TEST +#undef SINGLE_TEST using System; using System.Collections.Generic; @@ -16,8 +16,10 @@ namespace CarFire /// public class Display { + bool playerChosen = false; List mProjectiles = new List(); - List mCharacters = new List(); + //List mCharacters = new List(); + IPlayer[] mCharacters = new IPlayer[4]; Texture2D everything; Map mMap; int currentCenterX = 5; @@ -75,8 +77,9 @@ namespace CarFire /// checking for collisions, gathering input, and playing audio. /// /// Provides a snapshot of timing values. - public void Update(TimeSpan timespan) + public void Update(TimeSpan timespan, GameState state) { + //INPUT - testing input... has to be through network later #if SINGLE_TEST KeyboardState keyState = Keyboard.GetState(); @@ -101,7 +104,24 @@ namespace CarFire } mMap.CenterCell = new Vector2(mCharacters[0].GridX, mCharacters[0].GridY); #endif - + + for (int i = 0; i < 4; i++) + { + if (mCharacters[i] == null) + { + if(state.keysDown[i].Contains(Keys.Enter)) + { + mCharacters[i] = (new Human(mMap, "", everything)); + mCharacters[i].GridX = mMap.GetStartingPositionForPlayer(i+1).X; + mCharacters[i].GridY = mMap.GetStartingPositionForPlayer(i+1).Y; + } + } + else + { + mMap.CenterCell = new Vector2(mCharacters[0].GridX, mCharacters[0].GridY); + mCharacters[i].MovePlayer(state.keysDown[i]); + } + } for (int i = 0; i < mProjectiles.Count; i++ ) { mProjectiles[i].Update(timespan); @@ -113,10 +133,10 @@ namespace CarFire } } //Check for collisons - for (int j = 0; j < mCharacters.Count; j++) + for (int j = 0; j < mCharacters.Length; j++) { - + if(mCharacters[j] != null) for (int i = 0; i < mProjectiles.Count; i++) { if (mProjectiles[i].GridX == mCharacters[j].GridX && mProjectiles[i].GridY == mCharacters[j].GridY) @@ -142,15 +162,17 @@ namespace CarFire projectile.Draw(spriteBatch); } - foreach(IPlayer character in mCharacters) + for(int i = 0; i < 4; i++)//IPlayer character in mCharacters) { - character.Draw(spriteBatch); + if(mCharacters[i] != null) + mCharacters[i].Draw(spriteBatch); } } public void AddCharacters(IPlayer player) { - mCharacters.Add(player); + mCharacters[mCharacters.Length] = player; + //mCharacters.Add(player); } } }