Grupa: Viesis

UWM FORUMS · PORTFOLIO · VIETŅU TOP
JAUNĀKAIS FORUMĀ · BIEDRU SARAKSTS · INFO MEKLĒTĀJS · IZSEKOTĀS TĒMAS · NOBALSO


Ierakstus pievienot var tikai reģistrējies lietotājs!
  UWM AKTUĀLI: DISKUSIJA: Reputācijas restarts - DISKUSIJA: Steam spēļu izloze - NODERĪGI: "CW sistēma" uCoz modulī
  • Lappuse 1 no 1
  • 1
Javascript Hangman - vārdu spēle
Korijs
Otrdiena, 16.08.2011, 0:04:46 | Ieraksts #1
FORUMA DIKTATORS
Foruma ieraksti: 5047

UWM Reputācija:

uWEBMEISTARS ordeņi:

1. līmenis

2. līmenis

3. līmenis


Jaunākie apbalvojumi:


@Korijs raksta .. :

Skripts:

Code
<SCRIPT LANGUAGE="javascript">
     
   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","breakthro  ugh","carcinogenic","censorious","chivalrous",
"collarbone","commendable","compendium","comprehensive","conclusive","conscientious","consider  ate",
"deferential","denouement","determinate","diffidence","disruption","earthenware","elliptical","entanglement",
"escutcheon","extinguish",  "extradition","fastidious","flamboyant","forethought","forthright","gregarious",
"handmaiden","honeysuckle","hypocritical","illustrious","inf  allible","lumberjack","mischievous","mollycoddle",
"nimbleness","nonplussed","obliterate","obsequious","obstreperous","opalescent","ostensibl  e","pandemonium",
"paraphernalia","pawnbroker","pedestrian","peremptory","perfunctory","pernicious","perpetrate","personable",
"pickpocket","p  oltergeist","precipitous","predicament","preposterous","presumptuous","prevaricate","propensity",
"provisional","pugnacious","ramshackle","ra  ttlesnake","reciprocate","recrimination","redoubtable","relinquish",
"remonstrate","repository","reprehensible","resolution","resplendent","r  estitution","retaliation","retribution",
"saccharine","salubrious","skulduggery","skyscraper","soothsayer","tearjerker","transcribe","turpent  ine",
"unassuming","underscore","undertaker","underwrite","unobtrusive","vernacular","waterfront","watertight");
     
   </SCRIPT>


aiz kura uzreiz pievienojam spēles uzbūvi:

Code
<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="    --- Hangman ---" onfocus="word.blur();" SIZE=25>    
       <BR>
      <INPUT TYPE=TEXT NAME="tried" VALUE="Nospiediet GO, lai sāktu!" onfocus="tried.blur();" SIZE=25>     
     </TD>
     <TD COLSPAN=2 ALIGN=CENTER>
      <INPUT TYPE=BUTTON onclick="new_word(this.form);" VALUE=" GO ">      
     </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>


Iznākums:

Pielikumi: 7457440.jpg (9.9 Kb)


Proti uzvesties, pateikt paldies un paaugstināt reputāciju tiem, kuri ir to nopelnījuši, palīdzēt tiem, kuriem ir nepieciešama palīdzība, papildināt forumu ar lietderīgām tēmām, līdz ar ko Tu šeit būsi respektabls biedrs! Pretēji tam, ja izteikts stulbums, nekaunība un neadekvāta uzvedība spraucas pāri katrai smadzeņu rievai, ja tāda ir - lūgtum, tiksi nahrenizēts! - Biedrs mācās no biedra / UWM

  • Lappuse 1 no 1
  • 1
Meklēšana:

UWM apmeklēja:

RESPEKTABLĀKIE PORTĀLA FORUMA KLAVIATŪRISTI :
Foruma viszinis
Korijs
UWM karma: 380
Foruma atkarīgais
wuxmachine
UWM karma: 157
Foruma atkarīgais
Robiits
UWM karma: 87
Foruma šamanis
0wn3r
UWM karma: 80
Foruma atkarīgais
H[o_0]LiGaN
UWM karma: 78
Foruma atkarīgais
Spanky
UWM karma: 76
Foruma viszinis
Ar4ssS
UWM karma: 74
Foruma atkarīgais
Profth3tic
UWM karma: 55
Foruma atkarīgais
emciits
UWM karma: 52
Foruma atkarīgais
JackDaniel
UWM karma: 51
Foruma atkarīgais
Antikrists
UWM karma: 51
Foruma atkarīgais
Ken_D
UWM karma: 50
Ielāde...