| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1702 人关注过本帖
标题:这个游戏怎么才能输出到表格!求大神帮忙!
只看楼主 加入收藏
qq995354156
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2016-11-18
结帖率:100%
收藏
 问题点数:0 回复次数:0 
这个游戏怎么才能输出到表格!求大神帮忙!
石头剪刀布.rar (139.87 KB)

<!DOCTYPE html>
<html>

    <head>
        <meta charset="utf-8" />
        <title></title>
        <style type="text/css">
            .p{
                background-image: url(img/背景.jpg);
                background-repeat: no-repeat;
                background-size: 240px 360px;
            }
            #bg {
                padding: 30px 0px 0px 0px;
                width: 240px;
                height: 320px;
                background-color: blanchedalmond;
                font-size: 20px;
            }
            
            #move {
                padding: 5px 0px 15px 0px;
                font-size: 15px;
                position: absolute;
                left: 0px;
                top: 8px;
            }
            #adiv{
                margin-left: 0px;
                margin-top: 60px;
                float: left;
            }
            #bdiv{
                margin-right:0px;
                float: right;
            }
            img {
                width: 50px;
            }
            
            #start{
                width: 50px;
                height: 30px;
                position: absolute;
                left: 100px;
                top:200px;
               
            }
            #answer{
                width: 50px;
                height: 30px;
                position: absolute;
                left: 40px;
                top:300px;
               
            }
            table{
                width: 240px;
                height: 120px;
                border-collapse: collapse;
                position: absolute;
                margin-left: -30px;
                margin-top: -65px;
            }
            
            
        </style>
    </head>

    <body>
        <div id="bg" class="p">
            <div id="move">
                欢迎来玩小游戏
            </div>
            请点击正确方
            <div id="adiv"><img src="img/1.jpg" id="pic" /> </div>
            <div id="bdiv">
                <img src="img/1.jpg"id="pic1"/><br />
                <img src="img/2.jpg"id="pic2"/><br />
                <img src="img/3.jpg"id="pic3"/>
            </div>
            
            <div id="answer">
            <table border="1">
            <tr>
                <th>人物</th>
                <th>赢</th>
                <th>输</th>
                <th>胜率</th>
            </tr>
            <tr>
                <td>A</td>
                <td id=""></td>
                <td id=""></td>
                <td id=""></td>
            </tr>
            <tr>
                <td>B</td>
                <td id=""></td>
                <td id=""></td>
                <td id=""></td>
            </tr>
        </table>

            </div>
        </div>
        
        <script type="text/javascript">
            var move=document.getElementById("move");
            var pic=document.getElementById("pic");
            var pic1=document.getElementById("pic1");
            var pic2=document.getElementById("pic2");
            var pic3=document.getElementById("pic3");
            var start=document.getElementById("start");
            var answer=document.getElementById("answer");
            
            var moveleft=0;
            setInterval(function(){
                moveleft++;
                move.style.left=moveleft+"px";
                if(moveleft>=240) moveleft=0;
            },100);
            
           var j=1;         
            var timer1;
            start.onclick=function(){
                 timer1=setInterval(function(){
                    pic.src="img/"+j+".jpg";
                    j=j+1;
                if(j>3){
                       j=1;
                }
                },200);
            }
            function stbtest(name){
                 var result;
                  switch (name){
                    case 0:
                        result="url(img/1.jpg)";
                        break;
                    case 1:
                       result="url(img/2.jpg)";
                        break;
                    case 2:
                      result1="url(img/.jpg)";
                        break;
                    default:
                        break;
                }
                return result;
            }
            
            function stbtest1(name){
                 var result1;
                switch (name){
                    case 0:
                        result1="url(img/1.jpg)";
                        break;
                    case 1:
                       result1="url(img/2.jpg)";
                        break;
                    case 2:
                      result1="url(img/.jpg)";
                        break;
                    default:
                        break;
                }
                return result1;
            }
            
            var ru1,ru2;
            bdiv.onclick=function (){
                var num1=Math.random()*10+1;
                    num1=Math.floor(num1);
                    ru1=num1%3;
                var g1=stbtest(ru1);
                var gg1=stbtest1(ru1);
//                adiv.innerHTML=g1;
//                adiv.style.backgroundImage=gg1;
            var num2=Math.random()*10+1;
                    num2=Math.floor(num2);
                    ru2=num2%3;
                var g2=stbtest(ru2);
//                bdiv.innerHTML=g2;
//                bdiv.style.backgroundImage=gg2;
//                answer.innerHTML="结果";
            }
            bdiv.onclick=function(){
                var i=ru1-ru2;
                    i=Math.abs(i);
                var ans;
                switch (i){
                    case 0:
                        ans="平手";
                     //   alert(ans);
                        break;  
                    case 1:
                        if (ru1<ru2) {
                            ans="输";
                        } else{
                            ans="赢";
                        }
                    //    alert(ans);
                        break;
                    case 2:
                        if (ru1>ru2) {
                            ans="输";
                        } else{
                            ans="赢";
                        }
                     //   alert(ans);
                        break;
                    default:
                        break;
                }
//                answer.innerHTML=ans;
            }
             pic1.onclick=    function(){
                clearInterval(timer1);
            }
              pic2.onclick=    function(){
                clearInterval(timer1);
            }
               pic3.onclick=function(){
                clearInterval(timer1);
            }
        </script>
    </body>

</html>
搜索更多相关主题的帖子: img jpg div var break 
2018-06-03 23:37
快速回复:这个游戏怎么才能输出到表格!求大神帮忙!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019651 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved