var d=!1;a.a=a.fill;a.b=a.fillRect;var e=Math.PI,f="#090",g="#FFF",h="#000",j=100,k,l,m=500,n=0,p=d;c.width=400;c.height=200;a.fillStyle=h;a.b(0,0,500,500);var r=[function(b){q("#FF0");a.moveTo(b-40,j);a.quadraticCurveTo(b,j-50,b+40,j);a.quadraticCurveTo(b,j+50,b-40,j);a.a()},function(b){q("#FC0");a.arc(b,j,30,0,2*e,d);a.a();q(f);a.arc(b+7,j-20,3,0,2*e,d);a.a()},function(b){q("#F00");a.arc(b,j,25,0,2*e,d);a.a();a.beginPath();a.arc(b+30,j-5,30,1.1*e,1.5*e,d);a.strokeStyle=f;a.lineWidth=5;a.stroke()}];function q(b){a.beginPath();a.fillStyle=b}function s(){for(i=1;4>i;i++){l[i]=Math.floor(3*Math.random());var b=100*i;a.fillStyle=g;a.b(b-48,j-48,96,96);r[l[i]](100*i)}30>k++?setTimeout(s,60):(l[1]==l[2]&&l[2]==l[3]?n=30*(l[1]+1):l[1]==l[2]&&(n=15*(l[1]+1)),0<n?t():p=d)}function u(){a.fillStyle=h;a.b(50,165,200,35);a.fillStyle=f;a.font="14px san-serif";a.fillText("Credits: "+m,55,180)}function t(){m+=1;n-=1;u();0<n?setTimeout(t,75):p=d}c.onclick=function(){p||(p=!0,m-=5,n=0,u(),k=0,l=[0,0,0,0],s())};u();
function (x) //orange
{
begin(ORANGE);
a.arc(x, y, 30, 0, 2*P, false);
a.F();
begin(GREEN);
a.arc(x+7, y-20, 3, 0, 2*P, false);
a.F();
},/* Can't get seven minified enough
function(x) //seven
{
begin(RED);
a.font="72px bold serif";
a.fillText('7', x-20, y+28);
},*/
function(x) //cherry
{
begin(RED);
a.arc(x, y, 25, 0, 2*P, false);
a.F();
a.beginPath();
a.arc(x+30, y-5, 30, 1.1*P, 1.5*P, false);
a.strokeStyle=GREEN;
a.lineWidth=5;
a.stroke();
}];
function begin(c) {
a.beginPath();
a.fillStyle=c;
};
function erase (x){
a.fillStyle=WHITE;
a.R(x-48, y-48, 96, 96);
};
function cycle(){
for (i=1;i<4;i++)
{
Holder[i]=rand();
erase(i*100);
Shapes[Holder[i]](i*100);
}
if (SpinCycle++<30) setTimeout(cycle, 60); else afterspin();
};
function rand() {
return Math.floor(Math.random()*3);
};
function spin() {
if (Running) return;
Running=true;
Credits-=5;
Won=0;
display();
SpinCycle=0;
Holder=[0,0,0,0];
cycle();
};
function afterspin() {
if (Holder[1]==Holder[2] && Holder[2]==Holder[3])
{
Won=30*(Holder[1]+1);
} else if (Holder[1]==Holder[2]) {
Won=15*(Holder[1]+1);
}
if (Won>0) {
win();
} else {
Running=false;
}
};
function display() {
a.fillStyle=BLACK;
a.R(50, 165, 200, 35);
a.fillStyle=GREEN;
a.font="14px san-serif";
a.fillText('Credits: ' + Credits, 55, 180);
};
function win() {
Credits+=1;
Won-=1;
display();
if (Won>0) setTimeout(win, 75); else Running=false;
};
c.onclick=spin;
display();