| Duello- PoRtaL & ForuM ™ 2009-2010 |
Would you like to react to this message? Create an account in a few clicks or log in to continue.

| Duello- PoRtaL & ForuM ™ 2009-2010 |


 
AnasayfaAnasayfa  GaleriGaleri  AramaArama  Latest imagesLatest images  Giriş yapGiriş yap  Kayıt OlKayıt Ol  
Dynamic Feed Control
Yükleniyor ...

 

 Sticks Game (ing)

Aşağa gitmek 
YazarMesaj
Admin
DueLLoYöneticisi

DueLLoYöneticisi
Admin


<b>Mesaj Sayısı</b> Mesaj Sayısı : 928
<b>Doğum tarihi</b> Doğum tarihi : 06/07/90
<b>Yaşı</b> Yaşı : 34
<b>Nerden</b> Nerden : Antalya
<b>İş/Hobiler</b> İş/Hobiler : Webtasarım - Öğrenci
<b>Lakap</b> Lakap : Site sahibi
<b>Rep Puanı</b> Rep Puanı : 735008

Sticks Game (ing) Empty
MesajKonu: Sticks Game (ing)   Sticks Game (ing) I_icon_minitimeCuma Ara. 04, 2009 8:25 pm

Değişik bir çöp çekme oyunu. Bilgisayara karşı son çöpün sizde kalmasını sağlamanız gerekiyor.

Kod:
<html>
<head>

<style type="text/css">
.inup
  {   
  FONT-SIZE: 12px;
  FONT-FAMILY: Comic Sans MS;
  border: 0;
  }
</style>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Content-Language" content="en-us">

<script language="JavaScript">
 var obj1 = new Array(100),
 mc,mc1,
 cur_obj,
 total_sel,
 win = false,
 cpu_sel,
 ost,
 user_sel,
 game = true;

function RemoveElementByNum(num)
 {
  ename="ch"+num;
  document.getElementById(ename).style.visibility='hidden';
  ename="im"+num;
  document.getElementById(ename).src="none.gif";
 };

function RemoveCpuSel(num)
 {
  del=num;
  for (i=0; i<mc1; i++)
  {
    ename="ch"+i;
    if (del!=0)
    {
      if (document.getElementById(ename).style.visibility!='hidden')
      {
    document.getElementById(ename).style.visibility='hidden';
    ename="im"+i;
    document.getElementById(ename).src="none.gif";
    del-=1;
      };           
    };

  };       
 };

function AI()
 {
  if ( (mc>1) && (win==false) ) { game=true };
  if (game==true)
  {
    if ( (mc-user_sel)==1 )
    {
      win=true;
      game=false;
    };
  if ( (mc%4)!=1 )
    {
    ost=(mc-user_sel)%4;
    if (ost==0) { ost=4; };           
    if (ost>1) { cpu_sel=ost-1; };
    else
      {
      cpu_sel=Math.floor( (3*Math.random()) );
      cpu_sel++;
      if (cpu_sel>mc) {cpu_sel=mc};
      };
    };
  else {cpu_sel=4-user_sel;};
  RemoveCpuSel(cpu_sel);
  mc=mc-(cpu_sel+user_sel);
  document.getElementById("log").value='Computer select '+cpu_sel+' stick(s)';
  };
  if ( (mc==1) || (mc<1))
  {
  game=false;
  if (win==true)
    {
      document.getElementById("log1").style.visibility='hidden';
      document.getElementById("log").style.visibility='hidden';
    alert('Congratulation!!! YOU WIN!!!!');
    game=false;
    };
  else
    {
      document.getElementById("log1").style.visibility='hidden';
      document.getElementById("log").style.visibility='hidden';
      alert('You lost. Artificial intellect WIN!!!! HA- HA- HA!!!!');
      game=false;
    };
  };
 document.getElementById("log1").value=mc+" sticks left";
 }

function GetClickedElement(){   
    total=0;
    result=false;
    for (i=0; i<mc1; i++)
    {
          ename="ch"+i;
          if ((document.getElementById(ename).style.visibility!='hidden') && (document.getElementById(ename).checked)) total++;
            };
    if (total>3)
        {
        alert('Too much sticks selected. You may select not more than 3 sticks!!!');
        result=false;
    }; else
    {
        result=true;
    };
    document.getElementById("log").value="You select "+total+" stick(s)";
    total_sel=total;
    user_sel=total;
    return result;
}

function RemoveSelected(){
    if ((total_sel!=0) && (total_sel<4))
    {
        user_sel=total_sel;
        for (i=0; i<mc1; i++)
        {
            ename="ch"+i;
            if ((document.getElementById(ename).style.visibility!='hidden') && (document.getElementById(ename).checked))  {RemoveElementByNum(i);};
        total_sel=0;
        };
        AI();
    };else
        {
                  if (total_sel>3) alert("Too much selecteed sticks");
        else    alert('Nothing selected');
        };
}

</script>

<title>Sticks game</title>

</head>

<body>
    <script language="JavaScript">

    mc=prompt("Input number of sticks. Number must be between 7 and 50","23");
        if (mc<7) mc=7;
        if (mc>50) mc=50;
    mc1=mc;
    document.write('<center><table><tr>');
    for (i=0; i<mc; i++)
    {
    document.write('<td><img src="http://webdeveloper.earthweb.com/repository/javascripts/2007/04/877231/stick.gif" name="im'+i+'"></td>');
    obj1[i]=1;
    };
    document.write('</tr><tr>');
    for (i=0; i<mc; i++)    {document.write('<td><input type="checkbox" onClick="GetClickedElement();" name="ch'+i+'"></td>');};
    document.write('</tr></table></center>');
    </script>
    <br>
    <center>
    <input type="button" value="Remove selected sticks" onClick="RemoveSelected()">
    </center>
   
    <br><br><br><br><br><br>
    <input type="text" class=inup name="log" size=30><br>
    <input type="text" class=inup name="log1" size=30><br>

    <script>
          document.getElementById("log1").value=mc+" sticks left";
    txt='<p>Autor"s site <a href="http://www.shvaika ic.ck.ua">here</a></p>';
        document.write(txt);
    </script>

</body>
</html>
Sayfa başına dön Aşağa gitmek
http://duello.goalsoccer.net
 
Sticks Game (ing)
Sayfa başına dön 
1 sayfadaki 1 sayfası
 Similar topics
-
» Z: The Game
» Snookey - The JS game (ing)
» BEE MOVİE GAME ( Arı Oyunu ) :::::::>
» Country Guessing Game (ing)
» CALL OF DUTY 4 SAVE GAME

Bu forumun müsaadesi var:Bu forumdaki mesajlara cevap veremezsiniz
| Duello- PoRtaL & ForuM ™ 2009-2010 |  ::    Duello Webmaster :: Hazır Kodlar :: Js (JavaScript)-
Buraya geçin: