]> Dogcows Code - chaz/carfire/blobdiff - CarFire/CarFire/CarFire/Human.cs
Modified Projectiles to work with MovementManager.
[chaz/carfire] / CarFire / CarFire / CarFire / Human.cs
index 0d68d302d07c6d4b186a5d1d36d6c08317622ef1..8a94fd3822745dcac308baf3e3243d960b615b2f 100644 (file)
@@ -138,31 +138,63 @@ namespace CarFire
             {\r
                 if (keysPressed.Contains<Keys>(Keys.Space))\r
                 {\r
-                    //TODO spawn projectile... needs to be added to display though\r
+                    float velocityX = 0;\r
+                    float velocityY = 0;\r
+                    int startX = Coordinates.X;\r
+                    int startY = Coordinates.Y;\r
+                    if (mMotion.Direction == Direction.Down || mMotion.Direction == Direction.LowerLeft || mMotion.Direction == Direction.LowerRight)\r
+                    {\r
+                        velocityY = 1;\r
+                        startY = Coordinates.Y + 1;\r
+                    }\r
+                    else if (mMotion.Direction == Direction.Up || mMotion.Direction == Direction.UpperLeft || mMotion.Direction == Direction.UpperRight)\r
+                    {\r
+                        velocityY = -1;\r
+                        startY = Coordinates.Y - 1;\r
+                    }\r
+                    if (mMotion.Direction == Direction.Right || mMotion.Direction == Direction.LowerRight || mMotion.Direction == Direction.UpperRight)\r
+                    {\r
+                        velocityX = 1;\r
+                        startX = Coordinates.X + 1;\r
+                    }\r
+                    else if (mMotion.Direction == Direction.Left || mMotion.Direction == Direction.LowerLeft || mMotion.Direction == Direction.UpperLeft)\r
+                    {\r
+                        velocityX = -1;\r
+                        startX = Coordinates.X - 1;\r
+                    }\r
+                    Vector2 toShoot = new Vector2(velocityX, velocityY);\r
+                    toShoot.Normalize();\r
+                    toShoot *= projectileSpeed;\r
+                    projectileCoolDown = shootCoolDown;\r
+                    theDisplay.AddProjectiles(new Projectile(theMap, projectileModel,\r
+                        toShoot, new Point(startX, startY)));\r
+\r
+                    /*\r
                     if (state == State.up)\r
                     {\r
                         projectileCoolDown = shootCoolDown;\r
                         theDisplay.AddProjectiles(new Projectile(theMap, projectileModel,\r
-                            new Vector2(0, -projectileSpeed), Coordinates.X, Coordinates.Y - 1));\r
+                            new Vector2(0, -projectileSpeed), new Point(Coordinates.X, Coordinates.Y - 1)));\r
                     }\r
                     if (state == State.down)\r
                     {\r
                         projectileCoolDown = shootCoolDown;\r
                         theDisplay.AddProjectiles(new Projectile(theMap, projectileModel,\r
-                            new Vector2(0, projectileSpeed), Coordinates.X, Coordinates.Y + 1));\r
+                            new Vector2(0, projectileSpeed), new Point(Coordinates.X, Coordinates.Y + 1)));\r
                     }\r
                     if (state == State.right)\r
                     {\r
                         projectileCoolDown = shootCoolDown;\r
                         theDisplay.AddProjectiles(new Projectile(theMap, projectileModel,\r
-                            new Vector2(projectileSpeed, 0), Coordinates.X + 1, Coordinates.Y));\r
+                            new Vector2(projectileSpeed, 0), new Point (Coordinates.X + 1, Coordinates.Y)));\r
                     }\r
                     if (state == State.left)\r
                     {\r
                         projectileCoolDown = shootCoolDown;\r
                         theDisplay.AddProjectiles(new Projectile(theMap, projectileModel,\r
-                            new Vector2(-projectileSpeed, 0), Coordinates.X - 1, Coordinates.Y));\r
+                            new Vector2(-projectileSpeed, 0), new Point(Coordinates.X - 1, Coordinates.Y)));\r
                     }\r
+                     */\r
                 }\r
             }\r
         }\r
This page took 0.01899 seconds and 4 git commands to generate.