private bool OutOfBounds(CannonBall c) { if (c.getPosition().X < 0 || c.getPosition().X > graphics.PreferredBackBufferWidth) return true; else if (c.getPosition().Y < 0 || c.getPosition().Y > graphics.PreferredBackBufferHeight) return true; else return false; }
/// <summary> /// Move an object sinusoidally /// </summary> /// <param name="c">The cannon ball who's values are being modified</param> /// <param name="time">Snapshot of timing values to control the sine function</param> /// <returns>Vector representing the new position of the projectile</returns> protected Vector2 MoveSinusoidally(CannonBall c, TimeSpan time) { //The projectiles still move linearly along the x-axis, but sinusodially along the y-axis. float x = (c.Position.X + (c.Direction.X * speed.X)); float y = ((c.Position.Y + (c.Direction.Y * speed.Y)) + (2.5f * (float)Math.Sin((.5f) * MathHelper.TwoPi * time.TotalSeconds))); return new Vector2(x, y); }