hangman就是一个猜字游戏,错一个字就划一笔,7笔组成个小人,就死了

解决方案 »

  1.   

    题目 -请看,要是有什么不懂得我6pm以后在线msn.A prompt should be answered by player 1 to establish the word.Then player 2 should take over and try and guess the word.At each turn, player 2 should be prompted for an upper case character with a string which contains the number of lives left (initially 7), the letters tried so far (in order) and the partly guessed word e.g. 7[]=======, 5[SA]=A===A=, etc.
    A life is lost with each incorrect guess.The game should finish with the message "well done" when the word is fully guessed or "bad luck - the word was ......" if the number of lives reaches 0.There should be validation of both players input.Players should be able to type input in upper or lower case letters but the progress of the game should be reported using upper case. 
      

  2.   

    就是写一个小游戏,要求第一个player先输入一个词,完后第2个player猜字。第2个player回答的必须是大写字母,比如说e.g.   7[]=======,   5[SA]=A===A=.    这里面7和5代表的是还剩的生命,player2每输入错一次生命就会减一次。[sa] 代表的是已经输入过的字母,其中A是答案中的一个字母,所以,就会显示在后面,没有显示的未知字母用=代替,7条命用完后,就死了,输出bad luck,成功猜出题目,输出well done
      

  3.   


    <HTML>
    <HEAD>
    <META   http-equiv='Content-Type'   content='text/html;   charset=gb2312'>
    <TITLE> simple  IE only</TITLE>
    </HEAD>
    <BODY   >
    <script   language=javascript>function func(){
    var j=0
      var a=document.getElementsByName("txt1")[0].value
      var b=document.getElementsByName("txt2")[0].value
      if(b.length==0 || b.length>7){
         if(b.length>7){
        document.getElementsByName("txt2")[0].value=document.getElementsByName("txt2")[0].value.substr(0,7)
     }
         return;
      }
      var Str="======="
      var mm=Str.split("")
      var mmm=a.split("")
      for(var i=0;i<b.length;i++){
         
         var c=b.substr(i,1)
     
     for(j;j<a.length;j++){
       //alert(j)
       if(mmm[j]==c){
     mm.splice(j,1,c.toUpperCase())
     mmm.splice(j,1,"=")
     
     break;
       }
     }
      }
      if(mm.join("").indexOf("=")<0){
    document.getElementById("div1").innerHTML=(7-b.length)+"["+b+"]"+mm.join("")+"</br></br></br><B>well   done</B></br>"
      }else{
        document.getElementById("div1").innerHTML=(7-b.length)+"["+b+"]"+mm.join("")
      }}
    function func2(){
        document.getElementsByName("txt1")[0].value=""
        document.getElementsByName("txt2")[0].value=""
        document.getElementById("div1").innerHTML="7[]======="
    }
    </script>
    player 1
    <input type="password" name="txt1">input  7  onle</br> 
    player 2
    <input type="text" name="txt2" onpropertychange ="func()"> max 7
    <div id="div1">7[]=======</div>
    </br>
    </br>
    <input type="button" name="btn" value="Clear" onclick="func2()"> 
    </BODY>
    </HTML>