void DrawFireWork(Firework Fw) { Fw.TimeLastChange += (float)elapsedTime.Milliseconds / 1000; if (Fw.TimeLastChange > Fw.TimeForFrame) { Fw.CurFrame += 1; Fw.TimeLastChange = 0; } if (Fw.CurFrame >= Fw.MaxFrame) Fireworks.Remove(Fw); Vector2 origin = new Vector2(FireworkSheet.Height/2); Rectangle frame = new Rectangle(FireworkSheet.Height * Fw.CurFrame, 0, FireworkSheet.Height, FireworkSheet.Height); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend); spriteBatch.Draw(FireworkSheet, Fw.Position, frame, Fw.Color, 0.0f, origin, ssX * 1.0f, SpriteEffects.None, 0.0f); spriteBatch.End(); }
void MakeFireworks() { lastFirework += (float)elapsedTime.Milliseconds / 1000; if (lastFirework > timeBetween) { lastFirework = 0; timeBetween = (float)(0.4f + LV.random.NextDouble() * (1.2f-0.4f)); //float amount = (float)(min + (float)random.NextDouble() * (max - min)); int min = 65; float x = (float)(min + LV.random.NextDouble() * (windowWidth - min - min)); float y = (float)(min + LV.random.NextDouble() * (windowHeight - min - min)); Vector2 pos = new Vector2(x, y); //float amount = (float)(min + (float)random.NextDouble() * (max - min)); int r = (int)(10 + LV.random.NextDouble() * (220 - 10)); int g = (int)(10 + LV.random.NextDouble() * (220 - 10)); int b = (int)(10 + LV.random.NextDouble() * (220 - 10)); Color color = new Color(r, g, b, 255); Firework fw = new Firework(10, 0.05f, pos, color); Fireworks.Add(fw); LV.FireworkCue = parentGame.soundBank.GetCue("firework"); LV.FireworkCue.Play(); } }