![]() |
|
| |||||||
|
| | Seçenekler |
|
#1
| ||||
| | ||||
sayı tahmin oyunularıHTML-Kodu: <!-- THREE STEPS TO INSTALL GUESS-A-NUMBER: 1. Paste the coding into the HEAD of your HTML document 2. Add the onLoad and unonLoad event handlers to the BODY tag 3. Put the last coding into the BODY of your HTML document --> <!-- STEP ONE: Copy this code into the HEAD of your HTML document --> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com --> <!-- Begin var my_no,count; function load() { window.defaultStatus="JavaScript Guess-a-Number Game"; document.game.help.value="Please set range of numbers and press the Start button."; document.game.from.focus(); } function rnd(scale) { var dd=new Date(); return((Math.round(Math.abs(Math.sin(dd.getTime()))*8.71*scale)%scale)); } function range() { var to=1+1*document.game.to.value; count=0; my_no=rnd(to); while(my_no<document.game.from.value) { my_no=rnd(to); } document.game.help.value="Please guess a number, enter it, and press Guess."; } function guess() { var no=document.game.number.value; count++; if(no<my_no) document.game.help.value="My number is greater than "+no+"."; else if(no>my_no) document.game.help.value="My number is less than "+no+"."; else alert("It takes you "+count+" attempts to guess this number"); } // End --> </SCRIPT> <!-- STEP TWO: Add the onLoad and unonLoad event handlers to the BODY tag --> <BODY onLoad="load()"> <!-- STEP THREE: Copy this code into the BODY of your HTML document --> <CENTER> <FORM name=game> <TABLE border=3> <TR> <TD align=center colspan=2>Range of numbers</TD> <TD align=center rowspan=2><input type=button value=" Start " onclick="range()"></TD> </TR> <TR> <TD align=center>From:<br><input type=text name=from size=10></TD> <TD align=center>To:<br><input type=text name=to size=10></TD> </TD> <TR> <TD></TD> </TR> <TR> <TD align=center colspan=3><input type=text name=help size=70></TD> </TR> <TR> <TD></TD> </TR> <tr><td align=right colspan=3><input type=text name=number size=10><input type=button value=" Guess " onclick="guess()"></TD> </TR> </TABLE> </FORM> </CENTER> <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: 2.16 KB --> |
|
#2
| ||||
| | ||||
| HTML-Kodu: <!-- THREE STEPS TO INSTALL GUESS 1 - 100: 1. Paste the coding into the HEAD of your HTML document 2. Add the onLoad event handler to the BODY tag 3. Put the last coding into the BODY of your HTML document --> <!-- STEP ONE: Copy this code into the HEAD of your HTML document --> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com --> <!-- Begin var js_mult1=3141 var js_mult2=5821 var js_m1=100000000 var js_m2=10000 var js_iseed=0 var js_iseed1=0 var js_iseed2=0 function random(n) { if (js_iseed == 0) { now = new Date() js_iseed = now.getHours() + now.getMinutes() * 60 + now.getSeconds() * 3600 } js_iseed1 = js_iseed / js_m2 js_iseed2 = js_iseed % js_m2 var tmp = (((js_iseed2 * js_mult1 + js_iseed1 * js_mult2) % js_m2) * js_m2 + (js_iseed2 * js_mult2)) % js_m1 js_iseed = (tmp + 1) % js_m1 return (Math.floor((js_iseed/js_m1) * n)) } var nGuesses = 0 function GuessNum() { var response var num = parseInt(document.forms[0].guess.value) document.forms[0].guess.value = num nGuesses++ response = "" if (num < myNumber) response = response + "Higher!" if (num > myNumber) response = response + "Lower!" if (num == myNumber) { respone = "Correct!"; alert ("Right!! Reload the page to start another game...."); } document.forms[1].result.value=response document.forms[1].guesses.value=nGuesses document.forms[0].guess.focus() document.forms[0].guess.select() return true } function GiveUp() { var response nGuesses = 0 alert("The number was " + myNumber +". Reload page to start a new game...."); } // End --> </SCRIPT> <!-- STEP TWO: Add the onLoad event handler to the BODY tag --> <BODY onLoad="document.forms[0].guess.focus();document.forms[0].guess.select()"> <!-- STEP THREE: Put the last code into the BODY of your HTML document --> <CENTER> <H2>Guessing Game</H2><p> <font size=2> Guess the same number that the computer has guessed. The number will range from 1 to 100.<p>Reload the page to start a new game.</font><SCRIPT> myNumber = random(); nGuesses = 0 </SCRIPT> <FORM onSubmit="GuessNum(); return false"> Your Guess: <INPUT TYPE="text" NAME="guess" SIZE=5> <INPUT TYPE="button" VALUE=" Guess... " onClick="GuessNum();"> <INPUT TYPE="button" VALUE=" GiveUp " onClick="GiveUp();"> </FORM> <FORM> <CENTER> #-Guesses: <INPUT TYPE="text" NAME="guesses" SIZE=3> INFO: <INPUT TYPE="text" NAME="result" SIZE=10> </CENTER> </FORM> <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: 2.55 KB --> |
![]() |
| Arama Etiketleri: oyunulari, sayi, tahmin |
| Seçenekler | |
| |
Benzer Konular | ||||
| Konu | Konu Açanlar | Forum | Cevaplar | Güncel Mesajlar |
| Sayı tahmin oyunu | tripio | Javascript kodları | 2 | 03-07-2008 10:16 |
| if değimi ile basitbir tahmin oyunu | W-S | Java | 0 | 10-06-2008 11:58 |
| Sayı Tahmin Oyunu | B737 | Visual Basic & Action script | 0 | 25-01-2008 07:06 |
| Tek Sayı - Çift Sayı Kontrolü | egitimbilgisi | C, c++, c# | 0 | 27-11-2007 08:59 |
| Sayı tahmin oyunu | egitimbilgisi | Java | 0 | 27-11-2007 08:55 |
![]() |