İPUCU

Java Object Oriented Programming temeline dayanan, çok işlevli, step by step işleyen dilin dökümanlarının paylaşım alanı.

Seçenekler

Gelişmiş adam asmaca oyunu : ) (javascript)

19-04-2011 17:56
#1
Virtual Root - ait Kullanıcı Resmi (Avatar)
E-Mail onayı yapılmamış üye
Üyelik tarihi:
06/2008
Mesajlar:
3.490
Teşekkür (Etti):
37
Teşekkür (Aldı):
295
Konular:
2099
Ticaret:
(0) %
[PHP]<!-- THREE STEPS TO INSTALL HANGMAN: COUNTRIES & CITIES: 1. Copy the coding into the HEAD of your HTML ******** 2. Add the onLoad event handler into the BODY tag 3. Put the last coding into the BODY of your HTML ******** --> <!-- STEP ONE: Paste this code into the HEAD of your HTML ******** --> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com --> <!-- Khalid Bossily salahdiny2k@hotmail.com --> <!-- Begin var Amsterdam=new Array("Amsterdam","Netherlands","Western Europe","Dutch","N&W:North sea. E:Germany. S:Belgium.","16,074,000","95% to 99%","41,526.16 km2","Dutch Guilder. NLG"); var Ankara=new Array("Ankara","Turkey","Asia minor","Turkish","N:Bulgaria, Blacksea, Georgia. E:Armenia, Iran. S:Mediterranean sea, Syria, Iraq. W:Aegean sea, Greece.","68,634,000","76% to 90%","779,452 km2","Turkish Lira. TRL"); var Astana=new Array("Astana","Kazakhstan","Asia","Kazakh","N&W:R ussia. E:Mongolia, China. S:Caspian sea, Uzbekistan, Kyrgyzstan","17,729,000","98%","2,715,900 km2","Kazakhstan Tenge. KZT"); var Athens=new Array("Athens","Greece","Western Europe","Greek","N:Albania, Macedonia, Bulgaria. E: Turkey, Aegean sea. S&W:Mediterranean sea.","10,965,000","94% to 96%","131,957 km2","Greek Drachma. GRD"); var Bandar_Seri_Begawan=new Array("Bandar Seri Begawan","Brunei","Far East","Brunei","N:South China sea. E&S&W:Malaysia.","346,400","85% to 95%","5,765 km2","Brunei Dollar. BND"); var Beijing=new Array("Beijing","China","Asia","Chinese","N:Kazakh stan, Mongolia, Russia. E:North Korea, Pacific ocean. S:Vietnam, Laos, Myanmar, Bhutan, Nepal, W:India, Pakistan, Kyrgyzstan, Tajikistan.","1,328,006,000","73% to 76.5%","9,574,479 km2","Chin. Yuan Renminbi. CNY"); var Belgrade=new Array("Belgrade","Yugoslavia","Eastern Europe","Serbo-Croatian","N:Hungary. E:Romania, Bulgaria. S:Albania, Macedonia. W:Bosnia & Herzegovina.","10,211,000","90% to 93%","102,350 km2","Yugslav Dinar. YUN"); var Berlin=new Array("Berlin","Germany","West Europe","Germany","Nenmark, North sea, Baltic sea. E:Poland, Czech republic. S:Austria, switzerland. W:Netherlands, Luxembourg, Belgium, France.","81,981,000","99%","357,020.79 km2","German Mark. DEM"); var Bern=new Array("Bern","Switzerland","Western Europe","Schwyzerdutsch","N:Germany. E:Austria. S:Italy. W:France.","7,407,000","99%","41,284.58 km2","Swiss Franc. CHF"); var Bogota=new Array("Bogota","Colombia","South America","Spanish","N:Caribbean sea, Venezuela. E:Venezuela, Brazil. S:Peru, Ecuador. W:Pacific ocean, Panama.","42,819,000","70% to 80%","1,141,748 km2","Colombian Peso. COP"); var Brasilia=new Array("Brasilia","Brazil","South America","Portuguese","N:Colombia, Venezuela, Guyana, Surinam, Caribbean sea. E:Atlantic ocean. S:Uruguay. W:Peru, Bolivia, Paraguay, Argentina.","172,885,000","76%","8,544,418 km2","Brazilian Real. BRL"); var Bratislava=new Array("Bratislava","Slovakia","Eastern Europe","Slovak","N:Poland. E:Ukraine. S:Hungary. W:Czech republic, Austria.","5,428,000","99%","49,034 km2","Slovak Koruna SKK"); var Brussels=new Array("Brussels","Belgium","Western Europe","Dutch, French","N:Netherlands. E:Germany, Luxembourg. S:France. E:North sea.","10,255,000","98%","30,518 km2","Belgian Franc. BEF"); var Buenos_aires=new Array("Buenos aires","Argentina","South America","Spanish","N:Bolivia, Paraguay. E:Brazil, Uruguay, Atlantic ocean. S&W:Chile.","37,849,000","92% to 95%","2,777,409 km2","Argentine Peso. ARS"); var Cairo=new Array("Cairo","Arab Republic of Egypt","North Africa","Arabic","N:Mediterranean sea, E:Palistain, Jurdan, Red Sea. S:Sudan, W: Libya.","66,303,000","55%","1,001,450 km2","Egyptian Pound. EGP"); var Copenhagen=new Array("Copenhagen","Denmark","Western Europe","Danish","N&W:North sea. E:Sweden. S:Germany","5,392,000","99%","43,093 km2","Danish Krone. DKK"); var Havana=new Array("Havana","Cuba","Latin America","Spanish","N:Atlantic ocean, Straits of Florida, Gulf of Mexico. E: Atlantic ocean, Haiti. S&W:Caribbean sea.","11,637,000","94%","114,525 km2","Cuban Peso. CUP"); var Helsinki=new Array("Helsinki","Finland","Western Europe - Scandinavia","Finnish","N:Norway. E:Russia. S:Gulf of Finland, Baltic sea. W:Sweden, Gulf of Bothnia.","5,194,000","100%","338,145 km2","Finnish Markka. FIM"); var Islamabad=new Array("Islamabad","Pakistan","Asia","...","N:Afgha nistan, Tajikistan. E:China. S:India, Indian ocean. W:Iran.","145,512,000","26%","880,254 km2","Pakistan Rupee. PKR"); var Lima=new Array("Lima","Peru","South America","Spanish","N:Ecuador, Colombia. E:Brazil, Bolivia. S:Chile. W:Pacific ocean","26,191,000","67% to 79%","1,285,251 km2","Peruvian Nuevo Sol. PEN"); var Lisbon=new Array("Lisbon","Portugal","Western Europe","Portuguese","N&E:Spain. S&E:Atlantic ocean.","10,008,000","83% to 84%","92,391 km2","Portuguese Escudo. PTE"); var Ljubljana=new Array("Ljubljana","Slovenia","Balkan region - Europe","Slovenian","N:Austria, Hungary. E&S:Croatia. W:Italy, Adriatic sea.","1,863,000","98%","20,256 km2","Slovenian Tolar. SIT"); var London=new Array("London","United Kingdom","Western Europe","English","N&E:North sea. S:English Cannal, France. W:Atlantic ocean, Irish sea, Ireland.","59,730,000","97% to 99%","244,910 km2","British Pound. GBP"); var Luxembourg=new Array("Luxembourg","Luxembourg","Weastern Europe","Norwegian, Bokmal","N&W:Belgium. E:Germany. S:France.","440,400","100%","2,586.4 km2","Luxmbourg Franc. LUF"); var Madrid=new Array("Madrid","Spain","Western Europe","Spanish","N:Atlantic ocean, France. E&S:Mediterranean sea. W:Atlantic ocean, Portugal.","40,117,000","...","504,842 km2","Spanish Peseta. ESP") var Mexico_city=new Array("Mexico city","Mexico","Southern North America","Spanish","N:USA. E:Gulf of Mexico. S:Guatemala. W:Pacific ocean.","98,991,000","87% to 88%","1,967,138 km2","Mexican Peso. MXP"); var Moscow=new Array("Moscow","Russia","Europe and Asia","Russian","N:North pole. E:Pacific ocean, Japan. S:North korea, China, Mongolia, Kazakhstan. W:Finland, Baltic States, Belarus, Ukraine.","145,532,000","98%","17,031,900 km2","Russian Rouble. RUB"); var New_delhi=new Array("New delhi","India","Peninsula in Southern Asia","Hindi","N:Pakistan, China, Nepal, Bangladesh. E&N&W:Indian ocean.","1,027,015,000","36% to 52%","3,166,944 km2","Indian Rupee. INR"); var Oslo=new Array("Oslo","Norway","Western Europe - Scandinavia","Norwegian","N&W:Atlantic ocean. E:Sweden. S:North sea.","4,463,000","100%","323,759 km2","Norwegian Kroner. NOK"); var Ottawa=new Array("Ottawa","Canada","North America","English, French","N: S:USA. W:Pacific ocean.","31,198,000","96% to 99%","9,976,137 km2","Canadian Dollar. CAD"); var Paris=new Array("Paris","France","Western Europe","French","N:English cannal, Belgium, Luxembourg. E:Germany, Switzerland, Italy. S:Spain, Mediterranean sea. W:Atlantic ocean.","58,882,000","97%","547,30 km2","French Franc. FRF"); var Prague=new Array("Prague","Czech Republic","Eastern Europe","Czech","N:Germany, Poland. E:Slovakia. S:Austria. W:Germany","10,325,000","99%","78,866 km2","Czech Koruna. CSK"); var Pyongyang=new Array("Pyongyang","North Korea","Easter Asia","Korean","N:China, Russia. E:Sea of Japan. S:South Korea. W:Yellow sea.","24,390,000","91%","122,762 km2","North Korean Won. KPW"); var Reykjavik=new Array("Reykjavik","Iceland","Western Europe","Icelandic","Island - Atlantic ocean","284,000","100%","102,819 km2","Iceland Krona. ISK"); var Riga=new Array("Riga","Latvia","Eastern Europe - Baltic region","Latvian","N:Estonia. E:Russia. S:Lithuania. W:Baltic sea.","2,407,000","99%","64,598 km2","Latvian Lats. LVL"); var Zagreb=new Array("Rome","Italy","Western Europe","Italian","N:Switzerland, Austeria, Slovenia. E:Adriatic sea, Turkey. S:Mediterranean sea. W:France, Monaco,Tyrrhenian sea","57,989,000","97%","301,323 km2","Italian Lira. ITL"); var Santiago=new Array("Santiago","Chile","South America","Spanish","N:Peru, Bolivia. E:Argentina. S&W:Pacific ocean.","15,449,000","92% to 95%","755,482 km2","Chilean Peso. CLP"); var Sarajevo=new Array("Sarajevo","Bosnia & Herzegovina","Eastern Europe - Balkan region","Bosnian","N&W:Croatia. E&S:Yugoslavia.","4,340,000","92%","51,129 km2","..."); var Seoul=new Array("Seoul","South Korea","Eastern Asia","korean","N:North Korea. E&S:Sea of Japan. W:Yellow sea","48,066,000","92%","99,268.36 km2","South Korean WON. KRW"); var Skopje=new Array("Skopje","Macedonia","Eastern Europe","Macedonian","N:Yugoslavia. E:Bulgaria. S:Greece. W:Albania","2,101,500","","25,333 km2",""); var Stockholm=new Array("Stockholm","Sweden","Western Europe - Scandinavia","Swedish","N:Norway, Finland. E:Gulf of Bothnia, Baltic sea. Senmark, North sea. W:Norway.","8,866,1000","99%","449,965 km2","Swedish Krona. SEK"); var Tallinn=new Array("Tallinn","Estonia","Eastern Europe - Baltic region","Estonian","N:Gulf of Finland. E:Russia. S:Latvia. W:Baltic sea.","1,429,000","99%","45,226 km2","Estonian Kroon. EEK"); var Tirane=new Array("Tirane","Albania","Eastern Europe - Balkan region","GHEG & TOSK","N:Yugoslavia. E:Bulgaria. S:Greece. W:Albania","3,608,000","85%","28,748 km2","Albanian Lek. ALL"); var Tokyo=new Array("Tokyo","Japan","Asia - Pacific ocean","Japanees","N&E:Pacific ocean. S:China sea. W: Sea of japan, Russia, China.","128,888,000","99%","377,589 km2","Japanese Yen. JPY"); var Ulan_bator=new Array("Ulan bator","Mongolia","Eastern Asia","Mongolian, Halh","N:Russia. E&S:China. W:Kazakhstan.","2,515,000","88% to 90%","1,564,160 km2","Mongolian Tugrik. MNT"); var Vienna=new Array("Vienna","Austria","Western Europe","German","N:Germany, Czech republic. E:Slovakia, Hungary. S:Slovenia, Itlay. W:Switzerland.","8,119,000","99%","83,858 km2","Austrian Schilling. ATS"); var Vilnius=new Array("Vilnius","Lithuania","Eastern Europe - Baltic region","Lithuanian","N:Latvia. E:Belarus. S:Poland. W:Baltic sea.","3,695,000","99%","65,300 km2","Lithuanian Litas. LTL"); var Washington_DC=new Array("Washington DC","United States of America","North America","English","N:Canada. E:Atlantic ocean. S: Mexico, Gulf of Mexico. W: Pacific ocean.","284,620,000","95% to 99%","9,629,047 km2","US Dollar. USD"); var Warsaw=new Array("Warsaw","Poland","Eastern Europe","Polish, Spanish","N:Baltic sea, Lithuania. E:belarus, Ukraine. S:Slovakia, Czech republic. W:Germany.","38,622,000","98.5%","312,685 km2","Polish Zloty. PLZ"); var Wellington=new Array("Wellington","New Zealand","Australian","English","South Pacific ocean- SE Australia","3,952,000","99%","272,727 km2","New Zealand Dollar. NZD"); var Zagreb=new Array("Zagreb","Croatia","Balkan region - Europe","Croatian","N:Slovenia, Hungary. E:Yugoslavia, Bosnia & Herzegovina. S&W:Adriatic sea.","4,688,000","97%","56,610 km2","Croatian Kuna. HRK"); var guessChoices= new Array(Amsterdam,Ankara,Astana,Athens,Bandar_Seri_B egawan,Beijing,Belgrade,Berlin,Bern,Bogota,Brasili a,Bratislava,Brussels,Buenos_aires,Cairo,Copenhage n,Havana,Helsinki,Islamabad,Lima,Lisbon,Ljubljana, London,Luxembourg,Madrid,Mexico_city,Moscow,New_de lhi,Oslo,Ottawa,Paris,Prague,Pyongyang,Reykjavik,R iga,Santiago,Sarajevo,Seoul,Skopje,Stockholm,Talli nn,Tirane,Tokyo,Ulan_bator,Vienna,Vilnius,Washingt on_DC,Warsaw,Wellington,Zagreb); var len=guessChoices.length - 1; function newGame(){ var badGuess="0"; var IntialInput=""; var x= new Array(); space=/ /g; if (********.myForm.categories[0].checked == false && ********.myForm.categories[1].checked == false) {alert("Select a category first"); }else { m=chooseCategory(x,guessChoices)[Math.round(len * Math.random())]; sweep(); diplayPattern(IntialInput); countRemain(badGuess); ********.myForm.input.focus(); } } function diplayPattern(inputChar){ var pattern =" "; for (i=0; i < m.length; i++) { if (m.charAt(i) == " ") { pattern += " "; } else if (inputChar.indexOf(m.charAt(i).toUpperCase()) != -1) { pattern += m.charAt(i).toUpperCase() + " "; } else pattern += "_ "; } ********.myForm.toGuess.value=pattern; } function chooseCategory(subArray,baseArray){ if (********.myForm.categories[0].checked) { for (i=0; i<baseArray.length; i++) { subArray[i]=baseArray[i][0]; } } if (********.myForm.categories[1].checked) { for (i=0; i<baseArray.length; i++) { subArray[i]=baseArray[i][1]; } } return subArray; } function renameBut(myValue){ if(myValue == "capitals") ********.myForm.start.value="Capital"; if(myValue == "countries") ********.myForm.start.value="Country"; sweep(); } function sweep(){ for (i=0; i < ********.theDetails.length - 1; i++) { ********.theDetails.elements[i].value="";} for(i=3; i!=6 && i < ********.myForm.length; i++) {********.myForm.elements[i].value=""} ********.myForm.counter.value=""; } function winner(){ if (********.myForm.toGuess.value.indexOf("_ ") == -1) return true; } function displayDetails(){ for(i=0; i < guessChoices.length; i++) { if (m == guessChoices[i][0] ) { alert("You won. You are Genius!\n\n"+ "' " +m + " ' The Country is ' " + guessChoices[i][1]+ " '"); for (j=0; j< guessChoices[i].length ; j++) { ********.theDetails.elements[j].value=" " + guessChoices[i][j]; } } else if (m == guessChoices[i][1]) { alert("You won. You are Genius!\n\n"+ "' " +m + " ' The Capital City is ' " + guessChoices[i][0]+ " '"); for (j=0; j< guessChoices[i].length ; j++) { ********.theDetails.elements[j].value=" " + guessChoices[i][j]; } } } } function countRemain(num){ myMatch=m.match(/\w/g); returnWord=m.match(/(\w|\s)/g); if (m.match(space) == null) {space_YorN=m.length;} else {space_YorN= m.length - m.match(space).length;} ********.myForm.counter.value=space_YorN - (num.length-1) / 2; if (space_YorN - (num.length-1) / 2 <= "0") { alert("Oops! you lost. The word you missed is: \n\n \"" + m.toUpperCase() +"\"" ); ********.myForm.toGuess.value=" "; for (i=0; i < m.length; i++) { ********.myForm.toGuess.value += returnWord[i].toUpperCase() + " "; } } } function makeAGuess(){ var indx= new Array("a","b") var myInput=********.myForm.input.value.toUpperCase(); var cc=" "; if (********.myForm.categories[0].checked == false && ********.myForm.categories[1].checked == false) { alert("Select a category then activate Random word."); }else { if (!********.myForm.toGuess.value) { alert("Click on \"" +********.myForm.start.value +"\" Button."); }else { diplayPattern(myInput); ********.myForm.input.focus(); if (!********.myForm.input.value) { alert("Guess a letter.") }else { if ((myInput.substring(0,myInput.length-1)).indexOf(myInput.charAt(myInput.length-1)) != -1) { alert("You already used << "+myInput.charAt(myInput.length-1)+ " >> \n Make another guess."); myInput=myInput.substring(0,myInput.length-1); ********.myForm.input.value=myInput.toLowerCase(); } for (i=0; i<myInput.length; i++) { if (m.toUpperCase().indexOf(myInput.charAt(i)) == -1) {cc +=myInput.charAt(i) + " ";} } if (winner()) { displayDetails(); } } ********.myForm.guessed.value=cc.toUpperCase(); countRemain(cc); } } } // End --> </script> </HEAD> <!-- STEP TWO: Insert the onLoad event handler into your BODY tag --> <BODY onLoad="********.theDetails.gameLength.value=guess Choices.length;"> <!-- STEP THREE: Copy this code into the BODY of your HTML ******** --> <div align=center> <table border=0 cellpadding=3> <tr> <td valign=top align=center><font size=7 face="arial black"><center>Hangman</center></font> <font size=2 face="arial" color="#685dab"><b><div align=left>a- Select a category:</font><br> <table border=1 cellpadding=9 cellspacing=0 bordercolor="black" bgcolor="#ffffc6" width=290> <form name="myForm"> <tr> <td align=center> <font size=2><b> Capital Cities <input type="radio" name="categories" value="capitals" onClick="renameBut(this.value);"> Countries <input type="radio" name="categories" value="countries" onClick="renameBut(this.value);"> </td> </tr> </table><br> <div align=left> <font size="2" color="#685dab"><b>b- Activate Random </b></font><font size="2"><input type="button" name="start" value="Country/Capital" onClick="newGame();"><p> <font size="3" face="arial"><center><input type="text" size="43" name="toGuess" readonly><br> <input type="text" name="guessed" size="43" readonly></center></font> <table><tr><td align=left> <font size=2 color="#685dab"> <u><b>Rules of the game:</b></u><br> a- Choose a category.<br> b- Activate a random word.<br> c- Guess letter one at a time then push "Enter" button.<br> - Bad guesses will be counted against yoou.<br> - You are allowed wrong guesses equal too the length of the mysterious word.<br> - The counter down the page shows how maany bad guesses remain. </font> </td></tr></table> <font size=2 color="#685dab"><b>c- </font><font size=3><input type="text" name="input" size=35></font> <input type="button" value="Enter" onClick="makeAGuess();"><br> <!----> <div align=left> <font size=2 color=red><b><i>Warning!</b></font> <font size=1 color="#000000"><i>You only have </i></font><font size=3 face=arial><input type="text" name="counter" value="" size=2 maxlength=2 disabled></font><font size=1 color="#000000"><i> bad guess before you lose!.</i></font> </form> </td></tr> <tr><td align=center valign="top"> <table border=3 cellpadding=5 cellspacing=0 bordercolor=black bgcolor="white" width=""> <tr><td> <table border=0 cellpadding=1 cellspacing=0 bgcolor="#ffffff"> <div align=right> <form name="theDetails"> <tr><td colspan=2 align=center><font size="5" face="Arial Black"><b>Statistics & Facts</font></td> </tr> <tr> <td align=right width="130"><font size=2>City Capital: </td><td width=><input type="text" name="country" size="35" disabled></td> </tr> <tr> <td align=right><font size=2>Country's Name: </td><td><input type="text" name="capital" size="25" disabled></td> </tr> <tr> <td align=right><font size=2>********: </td><td><input type="text" name="********" size="35" disabled></td> </tr> <tr> <td align=right><font size=2>Langauage: </td><td><input type="text" name="language" size="22" disabled></td> </tr> <tr> <td align=right><font size=2>Neighbours: </td><td><textarea name="neighbours" cols="28" rows="6" disabled wrap></textarea></td> </tr> <tr> <td align=right><font size=2>Population <font size=1>(2001)</font>: </td><td><input type="text" name="population" size="22" disabled></td> </tr> <tr> <td align=right><font size=2>Literacy Rate: </td><td><input type="text" name="literacy" size="22" disabled></td> </tr> <tr> <td align=right><font size=2>Area: </td><td><input type="text" name="area" size="22" disabled></td> </tr> <tr> <td align=right><font size=2>Currency: </td><td><input type="text" name="currency" size="22" disabled></td> </tr> <tr><td colspan=2><center>________________________________ _________</center></td> <tr><td colspan=2><font size=2><b>Note.</b> The number of Countries/Capital Cities enlisted in the Game is: </font><input type="text" name="gameLength" size=3 readonly><font size=2> so far.</font></td> </tr> </form> </div> </table> </td> </tr> </table> </td> </tr> </table> <p><center> <font face="arial, helvetica" size"-2">Free JavaScripts provided<br> by <a href="http://javascriptsource.com">The JavaScript Source</a></font> </center><p> <!-- Script Size: 20.47 KB -->[/PHP]


Bookmarks


« Önceki Konu | Sonraki Konu »
Seçenekler

Yetkileriniz
Sizin Yeni Konu Acma Yetkiniz var yok
You may not post replies
Sizin eklenti yükleme yetkiniz yok
You may not edit your posts

BB code is Açık
Smileler Açık
[IMG] Kodları Açık
HTML-Kodları Kapalı
Trackbacks are Kapalı
Pingbacks are Kapalı
Refbacks are Kapalı