Demo :
Cara membuatnya
Dari Dashboard >> Design >> Edit HTML.
Penempatannya
dibawah <body>
........
diatas </body>
<script type='text/javascript'>
//<![CDATA[
/*
Script by Mike Mcgrath http://website.lineone.net/~mike_mcgrath
*/
var alpha=new Array();
var alpha_index=0;
var bravo=new Array();
var bravo_index=0;
var running=0;
var failnum=0;
var advising=0;
function pick()
{
var choice="";
var blank=0;
for (i=0; i<words[index].length; i++)
{
t=0;
for(j=0; j<=alpha_index; j++)
if(words[index].charAt(i)==alpha[j] || words[index].charAt(i)==alpha[j].toLowerCase()) t=1;
if (t) choice+=words[index].charAt(i)+" ";
else
{
choice+="_ ";
blank=1;
}
}
document.f.word.value=choice;
if (!blank)
{
document.f.tried.value=" === Benar ! ===";
document.f.score.value++;
running=0;
}
}
function new_word(form)
{
if(!running)
{
running=1;
failnum=0;
form.lives.value=failnum;
form.tried.value="";
form.word.value="";
index=Math.round(Math.random()*10000) % 100;
alpha[0]=words[index].charAt(0);
alpha[1]=words[index].charAt(words[index].length-1);
alpha_index=1;
bravo[0]=words[index].charAt(0);
bravo[1]=words[index].charAt(words[index].length-1);
bravo_index=1;
pick();
}
else advise("Kamu lagi bermain !");
}
function seek(letter)
{
if (!running) advise(".....Klik Mulai !");
else
{
t=0;
for (i=0; i<=bravo_index; i++)
{
if (bravo[i]==letter || bravo[i]==letter.toLowerCase()) t=1;
}
if (!t)
{
document.f.tried.value+=letter+" "
bravo_index++;
bravo[bravo_index]=letter;
for(i=0;i<words[index].length;i++)
if(words[index].charAt(i)==letter || words[index].charAt(i)==letter.toLowerCase()) t=1;
if(t)
{
alpha_index++;
alpha[alpha_index]=letter;
}
else failnum++;
document.f.lives.value=failnum;
if (failnum==6)
{
document.f.tried.value="Kamu Kalah - Coba Lagi !";
document.f.word.value=words[index];
document.f.score.value--;
running=0;
}
else pick();
}
else advise("Letter "+letter+" is already used!");
}
}
function advise(msg)
{
if (!advising)
{
advising=-1;
savetext=document.f.tried.value;
document.f.tried.value=msg;
window.setTimeout("document.f.tried.value=savetext; advising=0;",1000);
}
}
var words = new Array("","aneh","asal","angklung","aspal","artikulasi","asem","bapak","blogger","blogspot","biasa","binasa","bengkak","botak","benjol","bencong","badan","bidan","busuk","banjir","binasa","bahasa","borok","canda","cubit","cium","colok","cerita","cewek","centil","celana","dongo","dilema","duda","derita","dalam","dahulu","diam","enak","endang","enklopedia","gajah","gergaji","gusi","guci","gondok","gendang","handal","hipotermia","himpunan","halaman","hajikempret","intan","indah","indung","istana","iseng","janji","juragan","jomplang","jerapah","janda","jambret","jenggot","janggut","kandang","kuping","konsentrasi","kontroversi","kiamat","kijokostupid","kencan","kijang","lupa","lompat","lidah","lambat","lempar","manusia","maling","mangsa","menjaga","monyong","monyet","NanoYulianto","orang","perdana","pertama","panci","pincang","rancang","rencana","rampok","ronda","sumpah","sendal","sial","sompret","siaga","susah","tutorial","tenda","unjuk","untuk","undang","udang","vonis","wanita","waria","zebra");
//]]>
</script>
<form name='f'>
<table bgcolor='#C0C0C0' border='1'>
<tr>
<td colspan='4' align='right'>
Score : <input type='text' name='score' value='0' onfocus='score.blur();' size='2' />
<br/>
Fails (6): <input type='text' name='lives' value='0' onfocus='lives.blur();' size='2'/>
</td>
<td colspan='7' align='center'>
<input type='text' name='word' value='Tebak Kata' onfocus='word.blur();' size='25' />
<br/>
<input type='text' name='tried' value='Klik Mulai' onfocus='tried.blur();' size='25' />
</td>
<td colspan='2' align='center'>
<input type='button' onclick='new_word(this.form);' value=' Mulai '/>
</td>
</tr>
<tr>
<td><input type='button' value=' A ' onclick='seek("A");'/></td>
<td><input type='button' value=' B ' onclick='seek("B");'/></td>
<td><input type='button' value=' C ' onclick='seek("C");'/></td>
<td><input type='button' value=' D ' onclick='seek("D");'/></td>
<td><input type='button' value=' E ' onclick='seek("E");'/></td>
<td><input type='button' value=' F ' onclick='seek("F");'/></td>
<td><input type='button' value=' G ' onclick='seek("G");'/></td>
<td><input type='button' value=' H ' onclick='seek("H");'/></td>
<td><input type='button' value=' I ' onclick='seek("I");'/></td>
<td><input type='button' value=' J ' onclick='seek("J");'/></td>
<td><input type='button' value=' K ' onclick='seek("K");'/></td>
<td><input type='button' value=' L ' onclick='seek("L");'/></td>
<td><input type='button' value=' M ' onclick='seek("M");'/></td>
</tr>
<tr>
<td><input type='button' value=' N ' onclick='seek("N");'/></td>
<td><input type='button' value=' O ' onclick='seek("O");'/></td>
<td><input type='button' value=' P ' onclick='seek("P");'/></td>
<td><input type='button' value=' Q ' onclick='seek("Q");'/></td>
<td><input type='button' value=' R ' onclick='seek("R");'/></td>
<td><input type='button' value=' S ' onclick='seek("S");'/></td>
<td><input type='button' value=' T ' onclick='seek("T");'/></td>
<td><input type='button' value=' U ' onclick='seek("U");'/></td>
<td><input type='button' value=' V ' onclick='seek("V");'/></td>
<td><input type='button' value=' W ' onclick='seek("W");'/></td>
<td><input type='button' value=' X ' onclick='seek("X");'/></td>
<td><input type='button' value=' Y ' onclick='seek("Y");'/></td>
<td><input type='button' value=' Z ' onclick='seek("Z");'/></td>
</tr>
</table>
</form>
Credit : Mike Mcgrath
Alhamdulillah
3 comments:
trimakasih udah share scriptnya..
sederhana banget...
kapan2 bikin "Tutorial Membuat Game dengan JavaScript" Ya...
saya gak bikin... kali entar bikinan orang saja... :)
ohya bang Nano, kunjungan balik ke blog ku ya!!!!
Posting Komentar