Начало
Игры
Время реакции - Кнопка
Играйте этот небольшой JavaScript задаются вопросы только, как быстро Вы можете реагировать? Netscape только.
JavaScript Games: Время реакции - Кнопка
<!-- TWO STEPS TO INSTALL REACTION TIME - BUTTON: 1. Put the designated coding into the BODY of your HTML document 2. Paste the last code into the BODY of your HTML document --> <!-- STEP TWO: Copy this code into the BODY of your HTML document --> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <! > <! > <!-- Begin function rnd() { r1=new Date(); num=Math.round(Math.abs(Math.sin(r1.getTime())*10000000))%5; return num; } function start() { if(q==1){return} c=0; ad=0; da=0; setTimeout("spel()",1000+1000*rnd()); document.ful.text8.value="wait..."; } function stop() { if(da==1){return} if(ad==1){return} if(q==1){return} if(c==0){fusk()} if(c==0){return} da=1 rak(); } function rak() { slutTime=new Date(); sltid=slutTime.getTime(); tidpo=(sltid-stid)/1000 if (ad==1)tidpo=2; tidtot=tidtot+tidpo; as="";if (tidtot<1)as="0" document.ful.text6.value="Total time: " +as+Math.round(tidtot*100)/100+" seconds" as=""; if (tidpo<1) as="0" if(ad==0){ if (k==1)document.ful.text1.value="Reaction time 1: "+as+tidpo+" seconds" if (k==2)document.ful.text2.value="Reaction time 2: "+as+tidpo+" seconds" if (k==3)document.ful.text3.value="Reaction time 3: "+as+tidpo+" seconds" if (k==4)document.ful.text4.value="Reaction time 4: "+as+tidpo+" seconds" if (k==5)document.ful.text5.value="Reaction time 5: "+as+tidpo+" seconds" document.ful.text8.value="Push Start"; } as="";if (tidtot<1)as="0" document.ful.text6.value="Total time: " +as+Math.round(tidtot*100)/100+" seconds" as="";if (tidtot/k<1)as="0" document.ful.text7.value="Avg. time: " +as+Math.round(tidtot*10000/(k*100))/100+" seconds" if(k>4){ q=1 document.ful.text8.value="Game Over..."; } } function spel() { if (ad==1)return k=k+1 c=1; startTime=new Date(); stid=startTime.getTime(); document.ful.text8.value="PUSH STOP!!!"; } function fusk() { document.ful.text8.value="Too soon. 2 sec penalty. Push start!" ad=1 stid=0; rak(); } tidtot=0; k=0; q=0; ad=0; // End --> </SCRIPT> <!-- STEP TWO: Copy this code into the BODY of your HTML document --> <BODY> <CENTER> <FORM name=ful> <INPUT SIZE=30 NAME="text1" value="Reaction time 1:"><br> <INPUT SIZE=30 NAME="text2" value="Reaction time 2:"><br> <INPUT SIZE=30 NAME="text3" value="Reaction time 3:"><br> <INPUT SIZE=30 NAME="text4" value="Reaction time 4:"><br> <INPUT SIZE=30 NAME="text5" value="Reaction time 5:"><p> <INPUT SIZE=30 NAME="text6" value="Total time: "><br> <INPUT SIZE=30 NAME="text7" value="Avg. time: "><p> <INPUT SIZE=30 NAME="text8" value="Push Start"><br> <INPUT TYPE="button" VALUE="Start" onClick="start()"> <INPUT TYPE="button" VALUE="STOP" onClick="stop()"><p> <INPUT TYPE="button" VALUE="New Game" onClick="history.go(0)"> </FORM> </CENTER> <!-- Script Size: 2.87 KB -->