MCPcopy Create free account
hub / github.com/candybox2/candybox2.github.io / updateFlamesArray

Method updateFlamesArray

code/main/Cauldron.ts:515–555  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

513 }
514
515 private updateFlamesArray(): void{
516 // Create the variables
517 var minX: number = 0;
518 var maxX: number = 41;
519 var minY: number;
520 var maxY: number = 14;
521 var howManyFlames: number;
522 var x: number;
523 var y: number;
524
525 // Calculate minY
526 minY = 14 - this.timerTime;
527 if(minY < 5) minY = 5;
528
529 // Caulcate howManyFlames
530 howManyFlames = this.timerTime * 25;
531 if(howManyFlames > 200) howManyFlames = 200;
532
533 // Reset the array
534 this.resetFlamesArray();
535
536 // If we're boiling
537 if(this.currentAction = CauldronAction.BOILING){
538 // Add flames depending on the current timer time
539 for(var i = 0; i < howManyFlames; i++){
540 // Set y
541 y = null;
542 for(var j = maxY; j > minY; j--){
543 if(Random.oneChanceOutOf(3)){
544 y = j;
545 break;
546 }
547 }
548 if(y == null) y = maxY;
549 // Set x
550 x = Random.between(minX + (14-y), maxX - (14-y));
551 // Add the flame
552 this.flames.push(new CauldronFlame(new Pos(x, y), Random.fromArray([")", "(", "`", "'", "."])));
553 }
554 }
555 }
556}

Callers 1

actionIntervalMethod · 0.95

Calls 1

resetFlamesArrayMethod · 0.95

Tested by

no test coverage detected