ANA SAYFA | FORUM | BLOG | SİTENİZ İÇİN | İÇERİK EKLE | EN YENİLER | EN POPÜLERLER | EN BEĞENİLENLER | REKLAM | İLETİŞİM
Arama:
Tüm kategorilerde Google Forumda JAVAScript Araçlar
// ÖZELLEŞTİR
E-posta:
Şifre:
Üye Ol
|
Şifremi Unuttum
>> ARŞİVİMİZ FORUM AÇILDI! (0 yorum)>> Ramazan Bayramınız kutlu olsun (2 yorum)>> Kurban Bayramı (0 yorum)>> 10 Kasım (1 yorum)>> CUMHURİYET BAYRAMI (0 yorum)
// EN YENİLER
// EN POPÜLER
// Anasayfa » JAVASCRIPT» Oyunlar ve Eğlence
Oy:
>> Arşivimiz Forum'da Sticks game (ing) ile ilgili açılmış konuları ara>> Veya bu içerik ile ilgili yeni bir konu aç
<html> <head> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Sticks game</title> <script> var maxCount=Math.floor((screen.availWidth-25)/25); var Count=maxCount; // Count= Write your own number here var Colors = new Array("cyan","red","green","blue","magenta","yellow"); var Box=new Array(); var CountTook=0, MCT=3; //MCT - MaxCountTook var size=Math.floor(screen.availWidth/(Count+1))-5; var offset=size+5; var x0=(size-3)/2, y0=10; function PaintButton(bool) { if (bool) { ButtonTake.style.backgroundColor = "lime"; ButtonTake.style.cursor = "hand"; } else { ButtonTake.style.backgroundColor = "gray"; ButtonTake.style.cursor = "default"; } } function Mv(n, Down, id, hide) { Element = document.all["d"+id]; if (Down) Element.style.posTop = y0+n; else Element.style.posTop = y0+30-n; if (n < 30) setTimeout("Mv("+(n+5)+", "+Down+", "+id+", "+hide+")", 0); else if (hide) Hide(id); } function Move(id) { currElement = document.all["d"+id]; if (Box[id] == 0) { if (CountTook < MCT) { if (CountTook == 0) PaintButton(true); CountTook++; TextSelected.innerText = CountTook; Box[id] = 1; Mv(0, true, id, false); } else alert("Too many!"); } else if (Box[id] == 1) { CountTook--; TextSelected.innerText = CountTook; if (CountTook == 0) PaintButton(false); Box[id] = 0; Mv(0, false, id, false); } } function Hide(id) { Box[id] = 2; Element = document.all["d"+id]; Element.style.visibility = "hidden"; } function EndGame(bool) { alert("Game over"); } function Take() { if (CountTook > 0) { for (i=0; i<BeginCount; i++) if (Box[i] == 1) Hide(i); PaintButton(false); Count -= CountTook; CountTook = 0; TextSelected.innerText = "0"; TextCount.innerText = Count; if (Count == 0) EndGame(false); else Turn(); } } function Turn() { if (Count % (MCT+1) == 1) CountTook = Math.round(Math.random()*(MCT-1))+1; else CountTook = (Count % (MCT+1))==0 ? MCT:(Count % (MCT+1))-1; if (CountTook > Count) CountTook = Count; CountDeleted = 0; i = 0; while (CountDeleted < CountTook) { if (Box[i] == 0) { Mv(0, true, i, true); CountDeleted++; } i++; } Count -= CountTook; CountTook = 0; TextCount.innerText = Count; if (Count == 0) EndGame(true); } </script> </head> <body> <div Id=Tab Style="POSITION:absolute; TOP:5px; BACKGROUND-COLOR:gray"></div> <div ID=TableDiv Style="POSITION:absolute; TOP:200px;"> <TABLE cellSpacing=1 cellPadding=1 width="100%" border=1> <tr><td align=right><strong>Remaining:</strong></td> <td id=TextCount></td><td align=right><strong>Choesen:</strong></td> <td id=TextSelected></td></tr></table> <table cellSpacing=1 cellPadding=1 width="100%" border=1> <tr> <td id=ButtonTake onclick=Take() style="FONT-WEIGHT:bold; FONT-SIZE:large; CURSOR:default; FONT-FAMILY:cursive; BACKGROUND-COLOR:gray" align=middle>Take it</td> </tr> </table> <table cellSpacing=1 cellPadding=1 width="100%" border=1> <tr> <td style="FONT-WEIGHT:bold; FONT-SIZE:large; CURSOR:default; FONT-FAMILY:cursive; BACKGROUND-COLOR:gray" align=middle> <a href="javascript:location.reload()">Try again!!!</a></td> </tr> </table> </div> <script> TextCount.innerText=Count; TextSelected.innerText="0"; BeginCount=Count; Tab.style.posHeight=200; for (i=0; i<Count; i++) { document.write('<DIV Id=d'+i+' name=d'+i+' onclick=Move('+i+') Style="POSITION:absolute; CURSOR:hand; LEFT:'+((i*offset)+x0)+'px; TOP:'+y0+'px; WIDTH:'+size+'px; HEIGHT:150px; BACKGROUND-COLOR:'+Colors[i%6]+'"></DIV>'); Box[i] = 0; } </script> </body> </html>
Kodu Kopyala
Hata Bildir | Tavsiye Et
Bu içeriğe oy verin:
Yorumlar / Yeni Yorum Yaz Bu içeriğe yorum yazılmamış.
ANA SAYFA | İÇERİK EKLE | YENİ EKLENENLER | EN POPÜLERLER | EN BEĞENİLENLER | REKLAM | DESTEKLEYENLER | İLETİŞİM
JAVAScript İndir © 2004 - 2008Web Tasarımı: Emir Emiroğlu | Kodlama: Can "FiNaRFiN" HANHAN , Korkut TAHAOĞLU, Göktuğ İÇÖZ