/// <summary> /// Each time CalculateStreams() is called an updated frame of what the explosion should render as is calculated. /// </summary> /// <param name="rotation">How much it is rotated from the object it originated from.</param> /// <param name="NumberOfStreams">Invariant: Number must always be odd.</param> /// <param name="degreesOfSpan">How wide is the explosion (360 is a complete circle).</param> /// <param name="strengthOfBlast">Determines size, length, and lifetime of blast.</param> public Explosion(float startPositionX, float startPositionY, float rotation, int NumberOfStreams, float degreesOfSpan, float strengthOfBlast) { particles = new Particles(); // color of the explosion as RGB color = new byte[] {255, 170, 40}; Random randomator = new Random(); streams = new List<float[]>(); float degreeChange = 0; float halfWindow = 0; if (degreesOfSpan > 0 && NumberOfStreams > 1) { degreeChange = degreesOfSpan / (NumberOfStreams - 1); halfWindow = degreesOfSpan / 2; } for (int i = 0; i < NumberOfStreams; i++) { float degree = -halfWindow + i * (degreeChange) + rotation + 180; // { ... , ... , where does it start, lifeTime , width streams.Add(new float[] { startPositionX, startPositionY, degree, (strengthOfBlast + randomator.Next((int) -(strengthOfBlast/3), (int) (strengthOfBlast/3 )))}); } strength = strengthOfBlast; }
/// <summary> /// Renders a given particle list. The particles takes on the color given in the parameter. /// </summary> /// <param name="particles"></param> private static void RenderParticles(Particles particles) { List<float[]> streams = particles.RenderParticles(); byte[] color = particles.Color; GL.LoadIdentity(); foreach (float[] stream in streams) { float particleSize = stream[5]; GL.Color4(color[0] / 255, color[0] / 255, color[0] / 255, stream[4]); GL.BindTexture(TextureTarget.Texture2D, explosionTex); GL.Begin(PrimitiveType.Quads); GL.TexCoord2(0, 0); GL.Vertex2(stream[0] - particleSize, stream[1] + particleSize); GL.TexCoord2(1, 0); GL.Vertex2(stream[0] + particleSize, stream[1] + particleSize); GL.TexCoord2(1, 1); GL.Vertex2(stream[0] + particleSize, stream[1] - particleSize); GL.TexCoord2(0, 1); GL.Vertex2(stream[0] - particleSize, stream[1] - particleSize); GL.End(); GL.BindTexture(TextureTarget.Texture2D, 0); } }
/// <summary> /// Construct a ship with given initial specs. /// </summary> /// <param name="VEL">Maximum Velocity</param> /// <param name="ACC">Maximum Acceleration</param> /// <param name="ROT_VEL">Maximum Rotational Velocity</param> /// <param name="ROT_ACC">Maximum Rotational Acceleration</param> public ShipDrone(float VEL, float ACC, float ROT_VEL, float ROT_ACC, float shipSize, float shipStartingHealth, int shipStartingLives) { SetShipMovement(VEL, ACC, ROT_VEL, ROT_ACC); radius = shipSize; canFire = false; isHit = false; idNumber = 0; shipMass = shipSize; sColor = WHITE; pColor = WHITE; shipStream = new Particles(); projectileStream = new Particles(); maxShipHealth = shipStartingHealth; maxShipLives = shipStartingLives; shipHealth = maxShipHealth; shipLives = maxShipLives; freeze = true; }