フォーラム@nifty | フォーラム・サークル | サイトマップ | ヘルプ |
掲示板 コラム お役立ち イベント リンク   | FHPGサイトマップ | お問い合わせ |
TOP > お役立ち > JavaScriptのおもちゃ箱 > スロットゲーム  

スロットゲーム

原案:臥龍 鳳雛 氏 (2000/04/01 登録)

 息抜きに楽しんでみてください。

表示サンプル

[Coin]:

ソース記述内容

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="ja">
<head>
<title>スロットゲーム</title>
<script type="text/javascript">
<!--

  var mode=0;
  var coin=100;
  var slptime=0;
  var a,b,c,a1,b1,c1,luck;

  function disp()
  {
    setTimeout("disp()",slptime);
    if (mode == 1)
    {
      a = (a+1) % 10;
      b = (b+1) % 10;
      c = (c+1) % 10;
      document.Slotdisp1.sa.value = a;
      document.Slotdisp2.sb.value = b;
      document.Slotdisp3.sc.value = c;
    }
    if (mode == 2)
    {
      if(a!=a1)
      {
        a= (a+1)%10;
        b= (b+1)%10;
        c= (c+1)%10;
      }
      if(a==a1)
      {
        if(b!=b1)
        {
          b= (b+1)%10;
          c= (c+1)%10;
        }
      }
      if(a==a1&&b==b1)
      {
        if(a==b)
        {
          document.message.mes.value = "!!! Chance !!!";
          if(a==7)
          {
            document.message.mes.value = "!!! Big Chance !!!";
          }
          slptime=1000;
        }
        if(a!=b)
        {
          slptime=100;
        }
        if(c!=c1)
        {
          c= (c+1)%10;
        }
      }
      if(a==a1&&b==b1&&c==c1)
      {
        if(a==b&&b==c)
        {
          if(a==7)
          {
            coin=coin+1000;
            document.message.mes.value = "Your Win [1000]";
          }
          if(a!=7)
          {
            coin=coin+10;
            document.message.mes.value = "Your Win [10]";
          }
          if(a!=b||b!=c||c!=a)
          {
            document.message.mes.value = "Your Lost";
          }
        }
        if(a!=b||b!=c||c!=a)
        {
          document.message.mes.value = "Your Lost";
        }
        mode=0;
        document.coindisp.yourcoin.value = coin;
        slptime=0;
      }
      document.Slotdisp1.sa.value = a;
      document.Slotdisp2.sb.value = b;
      document.Slotdisp3.sc.value = c;
    }
  }
  function slotstart()
  {
    if(coin>0)
    {
      mode=1;
      slptime=100;
      a=Math.floor(Math.random()*10);
      b=Math.floor(Math.random()*10);
      c=Math.floor(Math.random()*10);
      coin=coin-3;
      if(coin<0)
      {
        coin=0
      }
      document.coindisp.yourcoin.value = coin;
      document.message.mes.value = "Start !";
    }
    if(coin==0)
    {
      document.message.mes.value = "Your Lost!";
    }
  }
  function slotstop()
  {
    if(mode==1)
    {
      mode=2;
      slptime=500;
      a1=Math.floor(Math.random()*10);
      b1=Math.floor(Math.random()*10);
      c1=Math.floor(Math.random()*10);
      if(Math.random()<.2)
      {
        luck=Math.floor(Math.random()*10);
        a1=luck;
        b1=luck;
         if(Math.random()<.5)
         {
           c1=luck;
         }
      }
    }
  }

// -->
</script>
</head>
<body>
<table border="0" align="center"> 
  <tr>
    <td align="center">
      <form name="message" style="background-color:#C00000; width:200px;">
        <input name="mes" type="text" value="" size="20" style="text-align:center">
      </form>
      <script type="text/javascript">
<!--
  disp();
// -->
</script>
      <table style="background-color:#C00000; width:200px;">
        <tr>
          <td align="center">
            <table border="1">
              <tr>
                <td align="right">
                  <form name ="Slotdisp1">
                    <input name="sa" type="text" value="" size="2" style="text-align:center">
                  </form>
                </td>
                <td align="center">
                  <form name ="Slotdisp2">
                    <input name="sb" type="text" value="" size="2" style="text-align:center">
                  </form>
                </td>
                <td align="left">
                  <form name ="Slotdisp3">
                    <input name="sc" type="text" value="" size="2" style="text-align:center">
                  </form>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
      <form name ="Start" style="background-color:#C00000; width:200px;">
        <input name="startbtn" type="button" value="Start" onClick="slotstart()">
        <input name="stopbtn" type="button" value="Stop" onClick="slotstop()">
      </form>
      <form name ="coindisp" style="background-color:#C00000; width:200px; color:white;">
        [Coin]:
        <input name="yourcoin" type="text" value="100" size="10" style="text-align:right">
      </form>
    </td>
  </tr>
</table>
個人情報保護ポリシー
Copyright© NIFTY 2006 All Rights Reserved.
Copyright© FHPG 2006 All Rights Reserved.