スロットゲームの質問への回答が分割してあって面倒だとおもって、ここに来た人向け!

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<title>スロットゲーム</title>

<style type="text/css">

#slot div {
  height: 240px;
  width : 60px;
  overflow: hidden;
  position: relative;
  border: 1px #888 solid;
  float:left;
  z-index: 0;
  margin:1px;
}

#slot div img {
  height: 80px;
  width: 60px;
}

#button {
  clear:both;
}

#button input {
  width: 60px;
}

</style>

<div id="slot">
  <div id="s0">&nbsp;</div>
  <div id="s1">&nbsp;</div>
  <div id="s2">&nbsp;</div>
  <div id="s3">&nbsp;</div>
  <div id="s4">&nbsp;</div>
</div>

<p id="button">
  <input type="button" value="Stop" id="sw0">
  <input type="button" value="Stop" id="sw1">
  <input type="button" value="Stop" id="sw2">
  <input type="button" value="Stop" id="sw3">
  <input type="button" value="Stop" id="sw4">
  <input type="button" value="Start" id="swStart">
</p>

<script type="text/javascript">
//@cc_on

//画像の先読み
var ImageLoader = function ( srcList, header ) {
  var rst = [ ];
  var cnt = 0;
  var max = srcList.length;

  while( cnt < max ) {
    rst[ cnt ] = new Image;
    rst[ cnt ].src = ( header ? header + ',': '' ) + srcList[ cnt ];
    rst[ cnt ].alt = cnt + '';
    cnt++;
  }
  return rst;
};



var Drum = function ( ) {
  this.init.apply( this, arguments );
};

//ドラムの初期化
Drum.prototype.init = function ( id, images, setNo, ac ) {
  var cnt = 0;
  var pnt = document.getElementById( id );
  var img, newImg;
  
  this.imgs = [ ];
  
  while( img = images[ cnt++ ] ) {
    newImg = document.createElement( 'img' );
    newImg.src = img.src;
    newImg.alt = img.alt;

    with( newImg.style )
      position = 'absolute',top = left = '0px';

    this.imgs.push( pnt.appendChild( newImg ) );
  }

  this.name = 'Drum';
  this.max = --cnt;
  this.radius  = newImg.offsetHeight / (2 * Math.tan( Math.PI / cnt ) );//半径
  this.center = Math.floor( pnt.offsetHeight / 2 );//中心
  this.n = 360 / cnt; //n角形
  this.angle = setNo || Math.floor( Math.random( ) * cnt ) * this.n; //ドラムの回転角度
  this.step = 0; //回転量(加速量)
  this.ac = ac || .2;//加速度
  this.f = false;//true:加速 false:減速
  this.tmid = null;
  this.view();
};


//ドラムの絵柄表示
Drum.prototype.view = (function ( int, deg, sin ) {
  return function ( ) {
    var cnt = 0;
    var sa = this.angle + this.n / 2;
    var py0, py1, img, style;

    py0 = int( this.center + sin( sa * deg ) * this.radius );

    while( img = this.imgs[ cnt++ ] ) {
      style = img.style;
      sa -= this.n;
      py1 = int( this.center + sin( sa * deg ) * this.radius );

      if( py0 > py1 ) {
        style.top = py1 + 'px';
        style.height = py0 - py1 + 'px';
        style.display = 'inline';
      } else {
        style.display = 'none';
      }
      py0 = py1;
    }
  };
})( Math.floor, Math.PI / 180, Math.sin );


//呼ばれるたびドラムを回転
Drum.prototype.roll = (function ( int ) {
  return function ( ) {
    if( this.f ) {
      //加速
      this.step = Math.min( this.step + this.ac, 15 );
    } else {
      //減速
      this.step = Math.max( this.step - this.ac, 1 );
      if( 1 == this.step && int( this.angle % this.n ) == 0) {
        clearInterval( this.tmid );
        this.tmid = null;
        if( 'function' === typeof this.cbFunc ) {
          this.cbFunc( this.getNumber() );
        }
      }
    }
    this.angle += this.step;
    this.view();
  };
})( Math.floor );


Drum.prototype.start = (function ( ) {
  return function ( ) {
    if( !this.tmid ) {
      this.f = true;
      this.step = 0;
      this.tmid = setInterval( (function ( that ) {
        return function ( ) { that.roll( ); }; })( this ), 30);
    }
  };})();


Drum.prototype.stop = (function ( ) {
  return function ( cbFunc ) {
    this.cbFunc = cbFunc;
    this.f = false;
  };})();


Drum.prototype.getNumber = (function ( ) {
  return function ( ) {
    return this.tmid ? false: Math.floor( ( this.angle % 360 ) / this.n );
  };})();



//スロットを定義
var Slot = function ( ) {
  this.init.apply( this, arguments );
};

Slot.buffer = [ ];//clickでidをキーとして、オブジェクトを調べるため

Slot.prototype.init = (function ( ) {
  return function ( tgsw /*, [ swid, dramObj ], [ ] */ ) {
    this.name = 'Slot';
    this.buf = [ ];
    this.nums = [ ];
    var cnt = 1;
    var ary, id, drum;

    Slot.buffer[ tgsw ] = this;
    
    while( ary = arguments[ cnt++ ] ) {
      id = ary[0], drum = ary[1];
      this.buf[ id ] = drum;
      Slot.buffer[ id ] = this;
    }
  };})();


Slot.prototype.start = (function ( ) {
  return function ( ) {
    for( var k in this.buf )
      if( this.buf.hasOwnProperty( k ) ) {
        this.nums[ k ] = false;
        this.buf[ k ].start();
      }
  };})();


Slot.prototype.idCheck = (function ( ) {
  return function ( id ) {
    var obj;
    
    if( obj = this.buf[ id ] ) {
      obj.stop(
        (function ( that, id ) {
          return function ( num ) {
            that.nums[ id ] = num;
            that.numsCheck();
          };})( this, id )
      );
    } else this.start();
  };})();


Slot.prototype.numsCheck = (function ( ) {
  return function ( ) {
    var nums = '', k;
    for( k in this.nums ) {
      if( this.nums.hasOwnProperty( k ) ) {
        if( this.nums[ k ] === false ) return false;
        nums += this.nums[ k ];
      }
    }
    alert(nums);//結果は文字列
    return nums;
  };})();
  
  
//何が押されたか
Slot.handler = function ( evt ) {
  var e = evt./*@if( @_jscript ) srcElement @else@*/ target /*@end@*/;
  var o;
  e && ( o = Slot.buffer[ e.id ] ) && o.idCheck( e.id );
};

//クリックされたら
(function ( ) {
  document./*@if( @_jscript ) attachEvent( 'on' + @else@*/ addEventListener( /*@end@*/
    'click', Slot.handler, false );
})();

//画像データ
var image_base64_number = [
  'R0lGODlhEAAYAKIAAP///+7u7tTU1LCwsHZ2dkFBQRkZGQAAACwAAAAAEAAYAAADXXi63P4wPkNGqQSSAIYpnNcUQGkoRDk0QwksaVkshvui7oq7sBv0vJ1J0QoeYjKiDZg8FEtMwMy5FEqt0axQQKseXZnFk3micQDlYphREAAElNLacfkQypK8ft9IAAA7',
  'R0lGODlhEAAYAKIAAP///+7u7rCwsHZ2dkFBQRkZGQAAAAAAACwAAAAAEAAYAAADN2i63P4wxkKGIHEEwAGGhNB5kiFyX3SS0ppCbhm33fvMai3rNLr7PdajoOkIBpDBqFNq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mLKuMQsqgoYQCgKBFh0YqpqhycMgRoOCwGwRRkHBFNKwFaABrQFWBEboCdRHiWG2KcoYkYEVWBKoE2drt7mKJjLBM/odAIAOw==',
  'R0lGODlhEAAYAKIAAP///+7u7tTU1LCwsHZ2dkFBQRkZGQAAACwAAAAAEAAYAAADaHi63P4wPkMGKcM+AoAoVPcxXEcsnWcsQnoqKfAe8VwvgYvqysDTqZXC0PKASjJHaVAQFRoGHyBAiHYCzwXSdhUabjBe8xcbKMamXcesyKXD78N2mAoIFQR3tch0GAoEVYFZEoWGhwwJADs=',
  'R0lGODlhEAAYAKIAAP///+7u7tTU1LCwsHZ2dkFBQRkZGQAAACwAAAAAEAAYAAADY3i63P4wPjJGoeQZAYAwRPc1XGcoITAwabe0xTJ0Lkqvyky/dCDTAB7tdGgFbbTYwRCgZYpAZbHpNEqXlAEBFGURpEZWEulhAHGtp+JMJubGB51aYdAJLp05A7S9uCWAgYIMCQA7'
];

var images = ImageLoader( image_base64_number, 'data:image/gif;base64' );//画像の先読みっぽい?
var dram0 = new Drum( 's0', images );
var dram1 = new Drum( 's1', images );
var dram2 = new Drum( 's2', images );
var dram3 = new Drum( 's3', images );
var dram4 = new Drum( 's4', images );//回転ドラムを3個つくる

new Slot( 'swStart', [ 'sw0', dram0 ], [ 'sw1', dram1 ], [ 'sw2', dram2 ], [ 'sw3', dram3 ], [ 'sw4', dram4 ] );//スイッチとセットでスロットを作る

</script>