Make your own free website on Tripod.com
 
Home
ActionScript
Blog

Chapter 1

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Fuzzy Dice

<script>

//fuzzyDice
//Catherine Casuat 10/3/07
//Demonstrates switch statement

var roll = 0;
var die = "";

roll = Math.floor(Math.random() * 6) + 1;

switch (roll){

case 1:

die = " |--------| \n";
die +=" | |\n";
die +=" | * |\n";
die +=" | |\n";
die +=" | |\n";
die +=" |--------|\n";
break;

case 2:

die = "|--------|\n";
die +="| * |\n";
die +="| |\n";
die +="| * |\n";
die +="|--------|\n";
break;

case 3:

die = "|--------|\n";
die +="| * |\n";
die +="| * |\n";
die +="| * |\n";
die +="|--------|\n";
break;

case 4:

die = "|--------|\n";
die +="|* *|\n";
die +="| |\n";
die +="| * *|\n";
die +="|--------|\n";
break;

case 5:

die = "|--------|\n";
die +="|* * |\n";
die +="| * |\n";
die +="| * * |\n";
die +="|--------|\n";
break;

case 6:

die = "|--------|\n";
die +="|* * |\n";
die +="|* * |\n";
die +="|* * |\n";
die +="|--------|\n";
break;

default:
die = "ERROR!"
} // end switch
alert(die);

</script>