/** ********************************************************************************************** ********************************************************************************************** **/ public void makeSparks(SparkQueue sparkQueue) { try { if (dead) { return; } Point position = calculatePosition(); //Color color = Color.WHITE; //int size = 5; double newLifeSpan = sparkLifespan + (_rng.NextDouble() - .5d); Spark spark = new Spark(position, color, size, newLifeSpan); sparkQueue.AddSpark(spark); if (time > lifespan) { dead = true; } time += _timeIncrement; } catch (Exception e) { } }
/** ********************************************************************************************** ********************************************************************************************** **/ public void makeSparks(SparkQueue sparkQueue) { try { if (firstRocket == null) { return; } else if (firstRocket.getNextRocket() == null && firstRocket.isDead()) { firstRocket = null; lastRocket = null; return; } Rocket rocket = firstRocket; bool hasMoreRockets = true; while (hasMoreRockets) { // if the rocket is ready to explode, add the new rockets // to the end of the queue for painting rocket.checkExplode(this); rocket.makeSparks(sparkQueue); // loop until we find the next alive rocket, clipping out the finished rockets Rocket nextRocket = rocket.getNextRocket(); bool finished = false; while (!finished) { if (nextRocket == null) { // the end of the queue rocket.setNextRocket(null); lastRocket = rocket; hasMoreRockets = false; finished = true; } else if (nextRocket.isDead()) { nextRocket = nextRocket.getNextRocket(); } else { rocket.setNextRocket(nextRocket); rocket = nextRocket; finished = true; } } // This must be done at the end of the loop incase the last // rocket explodes and adds more rockets to the queue if (rocket == lastRocket) { //hasMoreRockets = false; } } } catch (Exception e) { } }