]> Dogcows Code - chaz/carfire/commitdiff
Players now spawn projectiles... still kind of buggy.
authorKyle <Kyle@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Mon, 19 Apr 2010 02:59:32 +0000 (02:59 +0000)
committerKyle <Kyle@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Mon, 19 Apr 2010 02:59:32 +0000 (02:59 +0000)
git-svn-id: https://bd85.net/svn/cs3505_group@101 92bb83a3-7c8f-8a45-bc97-515c4e399668

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

index 27f151e583d94c41e42f6d1346e0ed8fd4e26c03..774833b67b7bb875422f7b32d58df4b4000f583a 100644 (file)
@@ -47,7 +47,7 @@ namespace CarFire
             mMap.CenterCell = new Vector2(currentCenterX,currentCenterY);\r
             //Debugging... Spawn eight projectiles.\r
             //Diagonals\r
-            \r
+            /*\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
@@ -57,7 +57,7 @@ namespace CarFire
             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
+            */\r
 \r
             \r
             // TODO: use this.Content to load your game content here\r
@@ -111,7 +111,7 @@ namespace CarFire
                 {\r
                     if(state.keysDown[i].Contains(Keys.Enter))\r
                     {\r
-                        mCharacters[i] = (new Human(mMap, "", everything));\r
+                        mCharacters[i] = (new Human(mMap, "", everything, everything, this));\r
                         mCharacters[i].GridX = mMap.GetStartingPositionForPlayer(i+1).X;\r
                         mCharacters[i].GridY = mMap.GetStartingPositionForPlayer(i+1).Y;\r
                     }\r
@@ -168,12 +168,17 @@ namespace CarFire
                     mCharacters[i].Draw(spriteBatch);\r
             } \r
         }\r
-\r
+        /*\r
         public void AddCharacters(IPlayer player)\r
         {\r
             mCharacters[mCharacters.Length] = player;\r
             //mCharacters.Add(player);\r
         }\r
+         */\r
+        public void AddProjectiles(Projectile projectile)\r
+        {\r
+            mProjectiles.Add(projectile);\r
+        }\r
     }\r
 }\r
 \r
index 7a926a6cafc0c6936178cb61551e3946ec7b41fc..30546f3827db7e1a8c20f4b2af4720d33181516f 100644 (file)
@@ -36,11 +36,14 @@ namespace CarFire
         int pixelY;\r
         bool visible;\r
         int movementCoolDown;\r
+        Display theDisplay;\r
+        int projectileSpeed;\r
 \r
-        public Human(Map _theMap, String Name, Texture2D model)\r
+        public Human(Map _theMap, String Name, Texture2D model, Texture2D projectile, Display mDisplay)\r
         {\r
             theMap = _theMap;\r
             CharName = Name;\r
+            theDisplay = mDisplay;\r
 \r
             movementSpeed = 12; // randomly set now\r
             health = 100;\r
@@ -49,7 +52,9 @@ namespace CarFire
             //default state\r
             state = State.up;\r
             charModel = model;\r
+            projectileModel = projectile;\r
             movementCoolDown = movementSpeed;\r
+            projectileSpeed = 30;\r
         }\r
 \r
         public void LoadContent(ContentManager contentManager)\r
@@ -132,24 +137,28 @@ namespace CarFire
                 // move up\r
                 else if (keysPressed.Contains<Keys>(Keys.Up) && theMap.IsCellOpen(gridX, gridY - 1))\r
                 {\r
+                    state = State.up;\r
                     gridY -= 1;\r
                     movementCoolDown = movementSpeed;\r
                 }\r
                 // move down\r
                 else if (keysPressed.Contains<Keys>(Keys.Down) && theMap.IsCellOpen(gridX, gridY + 1))\r
                 {\r
+                    state = State.down;\r
                     gridY += 1;\r
                     movementCoolDown = movementSpeed;\r
                 }\r
                 // move left\r
                 else if (keysPressed.Contains<Keys>(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY))\r
                 {\r
+                    state = State.left;\r
                     gridX -= 1;\r
                     movementCoolDown = movementSpeed;\r
                 }\r
                 // move right\r
                 else if (keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY))\r
                 {\r
+                    state = State.right;\r
                     gridX += 1;\r
                     movementCoolDown = movementSpeed;\r
                 }\r
@@ -159,7 +168,19 @@ namespace CarFire
                 //TODO spawn projectile... needs to be added to display though\r
                 if (state == State.up)\r
                 {\r
-                    \r
+                    theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, new Vector2(0, -projectileSpeed), GridX, GridY));\r
+                }\r
+                if (state == State.down)\r
+                {\r
+                    theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, new Vector2(0, projectileSpeed), GridX, GridY + 1));\r
+                }\r
+                if (state == State.right)\r
+                {\r
+                    theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, new Vector2(projectileSpeed, 0), GridX +1, GridY));\r
+                }\r
+                if (state == State.left)\r
+                {\r
+                    theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, new Vector2(-projectileSpeed, 0), GridX, GridY));\r
                 }\r
             }\r
         }\r
index cabb38d5ba410b2fb700c79d965f43557c458a41..23e103a2a2127e3536b93993f63ca49e507b3ec9 100644 (file)
@@ -40,17 +40,18 @@ namespace CarFire
                             Texture2D _projectileModel,\r
                             Vector2 _velocity,\r
                             int _gridX,\r
-                            int _gridY,\r
+                            int _gridY)\r
+                            /*,\r
                             int _pixelX,\r
-                            int _pixelY)\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
+            pixelX = _gridX * (int)Map.PixelsToUnitSquares;\r
+            pixelY = _gridY * (int)Map.PixelsToUnitSquares;\r
             damage = 20;\r
         }\r
         public void Update(TimeSpan timespan)\r
This page took 0.032621 seconds and 4 git commands to generate.