X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fcarfire;a=blobdiff_plain;f=CarFire%2FCarFire%2FCarFire%2FHuman.cs;h=8a94fd3822745dcac308baf3e3243d960b615b2f;hp=0d68d302d07c6d4b186a5d1d36d6c08317622ef1;hb=b32b73746f5bf95771eb5f9db95763ce2a44049f;hpb=f7a63ea90e2dc0ada860e8240799073ab2734337 diff --git a/CarFire/CarFire/CarFire/Human.cs b/CarFire/CarFire/CarFire/Human.cs index 0d68d30..8a94fd3 100644 --- a/CarFire/CarFire/CarFire/Human.cs +++ b/CarFire/CarFire/CarFire/Human.cs @@ -138,31 +138,63 @@ namespace CarFire { if (keysPressed.Contains(Keys.Space)) { - //TODO spawn projectile... needs to be added to display though + float velocityX = 0; + float velocityY = 0; + int startX = Coordinates.X; + int startY = Coordinates.Y; + if (mMotion.Direction == Direction.Down || mMotion.Direction == Direction.LowerLeft || mMotion.Direction == Direction.LowerRight) + { + velocityY = 1; + startY = Coordinates.Y + 1; + } + else if (mMotion.Direction == Direction.Up || mMotion.Direction == Direction.UpperLeft || mMotion.Direction == Direction.UpperRight) + { + velocityY = -1; + startY = Coordinates.Y - 1; + } + if (mMotion.Direction == Direction.Right || mMotion.Direction == Direction.LowerRight || mMotion.Direction == Direction.UpperRight) + { + velocityX = 1; + startX = Coordinates.X + 1; + } + else if (mMotion.Direction == Direction.Left || mMotion.Direction == Direction.LowerLeft || mMotion.Direction == Direction.UpperLeft) + { + velocityX = -1; + startX = Coordinates.X - 1; + } + Vector2 toShoot = new Vector2(velocityX, velocityY); + toShoot.Normalize(); + toShoot *= projectileSpeed; + projectileCoolDown = shootCoolDown; + theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, + toShoot, new Point(startX, startY))); + + /* if (state == State.up) { projectileCoolDown = shootCoolDown; theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, - new Vector2(0, -projectileSpeed), Coordinates.X, Coordinates.Y - 1)); + new Vector2(0, -projectileSpeed), new Point(Coordinates.X, Coordinates.Y - 1))); } if (state == State.down) { projectileCoolDown = shootCoolDown; theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, - new Vector2(0, projectileSpeed), Coordinates.X, Coordinates.Y + 1)); + new Vector2(0, projectileSpeed), new Point(Coordinates.X, Coordinates.Y + 1))); } if (state == State.right) { projectileCoolDown = shootCoolDown; theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, - new Vector2(projectileSpeed, 0), Coordinates.X + 1, Coordinates.Y)); + new Vector2(projectileSpeed, 0), new Point (Coordinates.X + 1, Coordinates.Y))); } if (state == State.left) { projectileCoolDown = shootCoolDown; theDisplay.AddProjectiles(new Projectile(theMap, projectileModel, - new Vector2(-projectileSpeed, 0), Coordinates.X - 1, Coordinates.Y)); + new Vector2(-projectileSpeed, 0), new Point(Coordinates.X - 1, Coordinates.Y))); } + */ } } }