]> Dogcows Code - chaz/carfire/commitdiff
More test projectiles in the display class.
authorKyle <Kyle@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Thu, 15 Apr 2010 04:42:09 +0000 (04:42 +0000)
committerKyle <Kyle@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Thu, 15 Apr 2010 04:42:09 +0000 (04:42 +0000)
git-svn-id: https://bd85.net/svn/cs3505_group@85 92bb83a3-7c8f-8a45-bc97-515c4e399668

CarFire/CarFire/CarFire/Display.cs
CarFire/CarFire/CarFire/Projectile.cs

index c65075f3fb3a2209d6364ab00d69ad7bbc656214..98f91ed45eeeb9243301e05d35478b7a32545cf5 100644 (file)
@@ -9,11 +9,16 @@ using Microsoft.Xna.Framework.Input;
 \r
 namespace CarFire\r
 {\r
+    /// <summary>\r
+    /// This class is responsible for controlling what draws to the screen when the game is running.\r
+    /// </summary>\r
     public class Display\r
     {\r
         List<Projectile> mProjectiles = new List<Projectile>();\r
         List<Character> mCharacters = new List<Character>();\r
         Map mMap;\r
+        int currentCenterX = 5;\r
+        int currentCenterY = 5;\r
         public Display()\r
         {\r
             /*\r
@@ -31,9 +36,19 @@ namespace CarFire
             Texture2D everything = contentManager.Load<Texture2D>("cs");\r
             mMap = contentManager.Load<Map>("Maps/stable");\r
             Map.DefaultTile = contentManager.Load<Texture2D>("default");\r
-            mMap.CenterCell = new Vector2(5,5);\r
-            //List<object> entities = mMap.GetAllEntities();\r
+            mMap.CenterCell = new Vector2(currentCenterX,currentCenterY);\r
+            //Debugging... Spawn eight projectiles.\r
+            //Diagonals\r
             mProjectiles.Add(new Projectile(mMap, everything, new Vector2(5,5), 10, 10, 300, 300));\r
+            mProjectiles.Add(new Projectile(mMap, everything, new Vector2(-5, 5), 10, 10, 300, 300));\r
+            mProjectiles.Add(new Projectile(mMap, everything, new Vector2(5, -5), 10, 10, 300, 300));\r
+            mProjectiles.Add(new Projectile(mMap, everything, new Vector2(-5, -5), 10, 10, 300, 300));\r
+            //Vertical and horizontal\r
+            mProjectiles.Add(new Projectile(mMap, everything, new Vector2(0, 5), 10, 10, 300, 300));\r
+            mProjectiles.Add(new Projectile(mMap, everything, new Vector2(-5, 0), 10, 10, 300, 300));\r
+            mProjectiles.Add(new Projectile(mMap, everything, new Vector2(5, 0), 10, 10, 300, 300));\r
+            mProjectiles.Add(new Projectile(mMap, everything, new Vector2(0, -5), 10, 10, 300, 300));\r
+\r
             // TODO: use this.Content to load your game content here\r
         }\r
 \r
@@ -53,7 +68,7 @@ namespace CarFire
         /// <param name="gameTime">Provides a snapshot of timing values.</param>\r
         public void Update(TimeSpan timespan)\r
         {\r
-           \r
+            mMap.CenterCell = new Vector2(currentCenterX, currentCenterY);\r
             foreach (Projectile projectile in mProjectiles)\r
             {\r
                 projectile.Update(timespan);\r
@@ -77,7 +92,7 @@ namespace CarFire
         /// <summary>\r
         /// This is called when the game should draw itself.\r
         /// </summary>\r
-        /// <param name="gameTime">Provides a snapshot of timing values.</param>\r
+        /// <param name="spriteBatch">Used to draw with</param>\r
         public void Draw(SpriteBatch spriteBatch)\r
         {\r
             mMap.Draw(spriteBatch);\r
index c9cce9b14b60d8c131ec744c4aa68ffac092b9fc..1dd5e08eaf1e1ac40a9f5e73e056fe81960eada6 100644 (file)
@@ -1,4 +1,3 @@
-<<<<<<< .mine\r
 using System;\r
 using System.Collections.Generic;\r
 using System.Linq;\r
@@ -100,11 +99,12 @@ namespace CarFire
         /// <param name="topLeftY">The map Y pixel position of the topLeft of the display</param>\r
         public void Draw(SpriteBatch spriteBatch)\r
         {\r
-            Console.WriteLine(gridX + " " + gridY);\r
-            Console.WriteLine(theMap.GetRectangleFromCoordinates(new Vector2(gridX, gridY)));\r
+            //Console.WriteLine(gridX + " " + gridY);\r
+            //Console.WriteLine(theMap.GetRectangleFromCoordinates(new Vector2(gridX, gridY)));\r
             Rectangle position = theMap.GetRectangleFromCoordinates(new Vector2(gridX, gridY));\r
             spriteBatch.Draw(projectileModel, position, Color.White);\r
-            //spriteBatch.Draw(projectileModel, new Vector2(40, 40), Color.White);\r
+            //Rectangle position2 = new Rectangle(pixelX-30, pixelY-30, 60, 60);\r
+            //spriteBatch.Draw(projectileModel, position2, Color.White);\r
         }\r
 \r
         /// <summary>\r
@@ -118,119 +118,3 @@ namespace CarFire
         public int Damage { get { return damage; } set { damage = value; } }\r
     }\r
 }\r
-=======\r
-using System;\r
-using System.Collections.Generic;\r
-using System.Linq;\r
-using System.Text;\r
-using Microsoft.Xna.Framework;\r
-using Microsoft.Xna.Framework.Content;\r
-using Microsoft.Xna.Framework.Graphics;\r
-using Microsoft.Xna.Framework.Input;\r
-\r
-namespace CarFire\r
-{\r
-    /// <summary>\r
-    /// This class represents a projectile object that will be spawned whenever a player or a monster fires.\r
-    /// </summary>\r
-    public class Projectile\r
-    {\r
-        //Member Variables\r
-        Map theMap;\r
-        Vector2 velocity;\r
-        Texture2D projectileModel;\r
-        int damage;\r
-        int gridX;\r
-        int gridY;\r
-        //The pixel position should be the pixel position on the map.  When a projectile is drawn\r
-        //these will have to be transformed to the coordinate system that the drawable screen is using.\r
-        int pixelX;\r
-        int pixelY;\r
-   \r
-        /// <summary>\r
-        /// The Constructor for a projectile object.\r
-        /// </summary>\r
-        /// <param name="_currentMap">The map that this character will interact with</param>\r
-        /// <param name="_projectileModel">The model for this projectile</param>\r
-        /// <param name="_velocity">How fast the projectile moves</param>\r
-        /// <param name="_gridX">The starting X position in the map grid</param>\r
-        /// <param name="_gridY">The starting Y position in the map grid</param>\r
-        /// <param name="_pixelX">The absolute X pixel position on the map</param>\r
-        /// <param name="_pixelY"> The absolute Y pixel position on the map</param>\r
-        public Projectile(Map _currentMap,\r
-                            Texture2D _projectileModel,\r
-                            Vector2 _velocity,\r
-                            int _gridX,\r
-                            int _gridY,\r
-                            int _pixelX,\r
-                            int _pixelY)\r
-        {\r
-            theMap = _currentMap;\r
-            projectileModel = _projectileModel;\r
-            velocity = _velocity;\r
-            gridX = _gridX;\r
-            gridY = _gridY;\r
-            pixelX = _pixelX;\r
-            pixelY = _pixelY;\r
-        }\r
-        public void Update()\r
-        {\r
-            //See if something moved onto this projectile.\r
-            if(theMap.IsCellOpen(gridX, gridY))\r
-            {\r
-                //theMap.damageSquare(gridX, gridY, damage);\r
-            }\r
-            //If the projectile will be moving to a new grid position we need to check to see if it is occupied.\r
-            /*\r
-            if ((int)((pixelX + velocity.X) / theMap.gridToPixelRatio) != gridX || (int)((pixelY + velocity.Y) / Map.gridToPixelRatio) != gridY)\r
-            {\r
-                bool open = theMap.IsCellOpen((pixelX + velocity.X) / theMap.gridToPixelRatio, (pixelY + velocity.Y) / Map.gridToPixelRatio);\r
-                //If open just move this projectile there\r
-                //***Map doesn't need to know that this projectile is there because players/monsters are allowed\r
-                // to move into the path of projectiles.\r
-                if (open)\r
-                {\r
-                    pixelX += (int)velocity.X;\r
-                    pixelY += (int)velocity.Y;\r
-                    gridX = pixelX / theMap.gridToPixelRatio;\r
-                    gridY = pixelY / theMap.gridToPixelRatio;\r
-                }\r
-                //If the square isn't open then just damage whatever is there\r
-                //TODO: A projectile must be deleted after this happens\r
-                else\r
-                {\r
-                    //theMap.damageSquare(gridX, gridY, damage);\r
-                }\r
-            }\r
-            */\r
-            //If it is not moving grid positions just increment pixelX and pixelY\r
-            else\r
-            {\r
-                pixelX += (int)velocity.X;\r
-                pixelY += (int)velocity.Y;\r
-            }\r
-            \r
-        }\r
-        /// <summary>\r
-        /// This method will draw a projectile to the screen\r
-        /// </summary>\r
-        /// <param name="spriteBatch"></param>\r
-        /// <param name="topLeftX">The map X pixel position of the topLeft of the display</param>\r
-        /// <param name="topLeftY">The map Y pixel position of the topLeft of the display</param>\r
-        public void Draw(SpriteBatch spriteBatch, int topLeftX, int topLeftY)\r
-        {\r
-            spriteBatch.Draw(projectileModel, new Vector2(topLeftX - pixelX, topLeftY - pixelY), null, Color.White, 0, new Vector2(0f, 0f), 1f, SpriteEffects.None, 0);\r
-        }\r
-\r
-        /// <summary>\r
-        /// Basic getters and setters\r
-        /// </summary>\r
-        public int GridX { get { return gridX; } set { gridX = value; } }\r
-        public int GridY { get { return gridY; } set { gridY = value; } }\r
-        public int PixelX { get { return pixelX; } set { pixelX = value; } }\r
-        public int PixelY { get { return pixelY; } set { pixelY = value; } }\r
-        public Map TheMap { get { return theMap; } set { theMap = value; } }\r
-        public int Damage { get { return damage; } set { damage = value; } }\r
-    }\r
-}\r
->>>>>>> .r83\r
This page took 0.03168 seconds and 4 git commands to generate.