public bool Shoot(Vector2 position, Vector2 velocity, float angle) { if (cyclesSinceShot < Constants.ShotDeltaCycles) { return(false); } cyclesSinceShot = 0; MyPointF shotPoint = new MyPointF(Constants.ShotVelocity, 0f); MyPointF rotatedPoint = shotPoint.Rotate(angle); Vector2 shotVelocity = new Vector2(rotatedPoint.X, rotatedPoint.Y); if (Constants.ShotAddShipVelocity) { shotVelocity += velocity; } foreach (Shot shot in shots) { if (!shot.Alive) { shot.SetShot(position, shotVelocity); return(true); } } return(false); }
public void SetThrust(bool thrust) { SetFlame(thrust); if (thrust && (state == ShipState.Normal)) { float angle = outline.Angle + 90f; double angleInRadians = angle * (Math.PI / 180.0f); MyPointF acceleration = new MyPointF(Constants.EngineThrust, 0f); acceleration = acceleration.Rotate(angle); velocity += new Vector2(acceleration.X, acceleration.Y); sounds |= Sounds.ShipThrust; } else { if ((sounds & Sounds.ShipThrust) != 0) { sounds ^= Sounds.ShipThrust; } } }
// add a line at all the rotations public static void AddLine(MyPointF end1, MyPointF end2, float scale) { float angleIncrement = 360f / Constants.RotateSteps; float angle = 0.0f; for (int step = 0; step < Constants.RotateSteps; step++) { Shape shape = (Shape) shapes[step]; shape.AddLine(end1.Rotate(angle), end2.Rotate(angle), scale); angle += angleIncrement; } }
// add a line at all the rotations public static void AddLine(MyPointF end1, MyPointF end2, float scale) { float angleIncrement = 360f / Constants.RotateSteps; float angle = 0.0f; for (int step = 0; step < Constants.RotateSteps; step++) { Shape shape = (Shape)shapes[step]; shape.AddLine(end1.Rotate(angle), end2.Rotate(angle), scale); angle += angleIncrement; } }
public bool Shoot(Vector2 position, Vector2 velocity, float angle) { if (cyclesSinceShot < Constants.ShotDeltaCycles) return false; cyclesSinceShot = 0; MyPointF shotPoint = new MyPointF(Constants.ShotVelocity, 0f); MyPointF rotatedPoint = shotPoint.Rotate(angle); Vector2 shotVelocity = new Vector2(rotatedPoint.X,rotatedPoint.Y); if (Constants.ShotAddShipVelocity) { shotVelocity += velocity; } foreach (Shot shot in shots) { if (!shot.Alive) { shot.SetShot(position, shotVelocity); return true; } } return false; }
public void SetThrust(bool thrust) { SetFlame(thrust); if (thrust && (state == ShipState.Normal)) { float angle = outline.Angle + 90f; double angleInRadians = angle * (Math.PI / 180.0f); MyPointF acceleration = new MyPointF(Constants.EngineThrust, 0f); acceleration = acceleration.Rotate(angle); velocity += new Vector2(acceleration.X,acceleration.Y); sounds |= Sounds.ShipThrust; } else { if ((sounds & Sounds.ShipThrust) != 0) sounds ^= Sounds.ShipThrust; } }