Word Game Script

Translate

Word Game Script

Word Game Script

 <script language="javascript">


/*

Script by Mike Mcgrath- http://website.lineone.net/~mike_mcgrath

Featured on JavaScript Kit (http://javascriptkit.com)

For this and over 400+ free scripts, visit http://javascriptkit.com

*/


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=" === You Win! ===";

    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("A word is already in play!");

}


function seek(letter)

{

  if (!running) advise(".....Click GO to start !");

  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="You lose - Try again!";

        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("","acrimonious","allegiance","ameliorate","annihilate","antiseptic","articulate","authoritative","benefactor","boisterous","breakthrough","carcinogenic","censorious","chivalrous","collarbone","commendable","compendium","comprehensive","conclusive","conscientious","considerate","deferential","denouement","determinate","diffidence","disruption","earthenware","elliptical","entanglement","escutcheon","extinguish","extradition","fastidious","flamboyant","forethought","forthright","gregarious","handmaiden","honeysuckle","hypocritical","illustrious","infallible","lumberjack","mischievous","mollycoddle","nimbleness","nonplussed","obliterate","obsequious","obstreperous","opalescent","ostensible","pandemonium","paraphernalia","pawnbroker","pedestrian","peremptory","perfunctory","pernicious","perpetrate","personable","pickpocket","poltergeist","precipitous","predicament","preposterous","presumptuous","prevaricate","propensity","provisional","pugnacious","ramshackle","rattlesnake","reciprocate","recrimination","redoubtable","relinquish","remonstrate","repository","reprehensible","resolution","resplendent","restitution","retaliation","retribution","saccharine","salubrious","skulduggery","skyscraper","soothsayer","tearjerker","transcribe","turpentine","unassuming","underscore","undertaker","underwrite","unobtrusive","vernacular","waterfront","watertight");


</script>



<form name="f">


<table bgcolor="#C0C0C0" border="1">

 <tbody><tr>

  <td align="RIGHT" colspan="4">

   Score : <input autofill-information="overall type: UNKNOWN_TYPE

server type: NO_SERVER_DATA

heuristic type: UNKNOWN_TYPE

label: Score :

parseable name: 

section: _1-default

field signature: 1318412689

form signature: 6371384408202656328

form renderer id: 3

field renderer id: 84" autofill-prediction="UNKNOWN_TYPE" name="score" onfocus="score.blur();" size="2" title="overall type: UNKNOWN_TYPE

server type: NO_SERVER_DATA

heuristic type: UNKNOWN_TYPE

label: Score :

parseable name: 

section: _1-default

field signature: 1318412689

form signature: 6371384408202656328

form renderer id: 3

field renderer id: 84" type="TEXT" value="0" />

   <br />

   Fails (6): <input autofill-information="overall type: UNKNOWN_TYPE

server type: NO_SERVER_DATA

heuristic type: UNKNOWN_TYPE

label: Fails (6):

parseable name: 

section: _1-default

field signature: 1318412689

form signature: 6371384408202656328

form renderer id: 3

field renderer id: 85" autofill-prediction="UNKNOWN_TYPE" name="lives" onfocus="lives.blur();" size="2" title="overall type: UNKNOWN_TYPE

server type: NO_SERVER_DATA

heuristic type: UNKNOWN_TYPE

label: Fails (6):

parseable name: 

section: _1-default

field signature: 1318412689

form signature: 6371384408202656328

form renderer id: 3

field renderer id: 85" type="TEXT" value="0" />  

  </td>

  <td align="CENTER" colspan="7">

   <input autofill-information="overall type: UNKNOWN_TYPE

server type: NO_SERVER_DATA

heuristic type: UNKNOWN_TYPE

label: Score :

parseable name: 

section: _1-default

field signature: 1318412689

form signature: 6371384408202656328

form renderer id: 3

field renderer id: 86" autofill-prediction="UNKNOWN_TYPE" name="word" onfocus="word.blur();" size="25" title="overall type: UNKNOWN_TYPE

server type: NO_SERVER_DATA

heuristic type: UNKNOWN_TYPE

label: Score :

parseable name: 

section: _1-default

field signature: 1318412689

form signature: 6371384408202656328

form renderer id: 3

field renderer id: 86" type="TEXT" value=" --- Hangman ---" /> 

    <br />

   <input autofill-information="overall type: UNKNOWN_TYPE

server type: NO_SERVER_DATA

heuristic type: UNKNOWN_TYPE

label: Score :

parseable name: 

section: _1-default

field signature: 1318412689

form signature: 6371384408202656328

form renderer id: 3

field renderer id: 87" autofill-prediction="UNKNOWN_TYPE" name="tried" onfocus="tried.blur();" size="25" title="overall type: UNKNOWN_TYPE

server type: NO_SERVER_DATA

heuristic type: UNKNOWN_TYPE

label: Score :

parseable name: 

section: _1-default

field signature: 1318412689

form signature: 6371384408202656328

form renderer id: 3

field renderer id: 87" type="TEXT" value="Click GO to get a word." />  

  </td>

  <td align="CENTER" colspan="2">

   <input onclick="new_word(this.form);" type="BUTTON" value="GO" />   

  </td>

 </tr>

 <tr>

  <td><input onclick="seek('A');" type="BUTTON" value="A" /></td>

  <td><input onclick="seek('B');" type="BUTTON" value="B" /></td>

  <td><input onclick="seek('C');" type="BUTTON" value="C" /></td>

  <td><input onclick="seek('D');" type="BUTTON" value="D" /></td>

  <td><input onclick="seek('E');" type="BUTTON" value="E" /></td>

  <td><input onclick="seek('F');" type="BUTTON" value="F" /></td>

  <td><input onclick="seek('G');" type="BUTTON" value="G" /></td>

  <td><input onclick="seek('H');" type="BUTTON" value="H" /></td>

  <td><input onclick="seek('I');" type="BUTTON" value="I" /></td>

  <td><input onclick="seek('J');" type="BUTTON" value="J" /></td>

  <td><input onclick="seek('K');" type="BUTTON" value="K" /></td>

  <td><input onclick="seek('L');" type="BUTTON" value="L" /></td>

  <td><input onclick="seek('M');" type="BUTTON" value="M" /></td>

 </tr>

 <tr>

  <td><input onclick="seek('N');" type="BUTTON" value="N" /></td>

  <td><input onclick="seek('O');" type="BUTTON" value="O" /></td>

  <td><input onclick="seek('P');" type="BUTTON" value="P" /></td>

  <td><input onclick="seek('Q');" type="BUTTON" value="Q" /></td>

  <td><input onclick="seek('R');" type="BUTTON" value="R" /></td>

  <td><input onclick="seek('S');" type="BUTTON" value="S" /></td>

  <td><input onclick="seek('T');" type="BUTTON" value="T" /></td>

  <td><input onclick="seek('U');" type="BUTTON" value="U" /></td>

  <td><input onclick="seek('V');" type="BUTTON" value="V" /></td>

  <td><input onclick="seek('W');" type="BUTTON" value="W" /></td>

  <td><input onclick="seek('X');" type="BUTTON" value="X" /></td>

  <td><input onclick="seek('Y');" type="BUTTON" value="Y" /></td>

  <td><input onclick="seek('Z');" type="BUTTON" value="Z" /></td>

 </tr>

</tbody></table>


</form>


Related Posts

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Copyright © 2020
Clicky