栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

java前端15

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

java前端15

 html+css文件




    
    
    
    Whac a Mole
    
        #content{
            width: 960px;
            margin: 0 auto;
            text-align: center;
            position: relative;
        }
        table{
            margin: 0 auto;
            cursor: url('img/chuizi.png'),auto;
        }
        td{
            width: 95px;
            height: 95px;
            background-color: #00ff33;
        }
 
        #start,#end{
            margin: 20px 10px;
            width: 50px;
            height: 50px;
            border-radius: 50%;
            background-color: green;
            font-size: 16px;
            font-weight: bold;
            color: white;
            border: 1px solid #cccccc;
            box-shadow: 2px 2px grey;
            cursor: pointer;
        }
        #start:active{
            border: none;
        }
        #end{
            background-color: red;
        }
        form{
            margin: 0 0 20px 0;
        }
        form > input{
            border-radius: 50%;
            border:none;
            text-align: center;
            font-weight: 16px;
            color: red;
        }
 
        #notice{
            background-color: #eee;
            border-radius: 10%;
            position: relative;
            margin: 0 auto;
            top: -400px;
            box-shadow: 2px 2px #666666;
            transition: all 0.2s ease-in-out;
            text-align: center;
            overflow: hidden;
        }
        .noticeshow{
            width: 340px;
            height: 180px;
        }
        .noticehide{
            width: 0px;
            height: 0px;
        }
        #notice > button{
            width: 80px;
            height: 25px;
            position: absolute;
            bottom: 18px;
            left: 130px;
            background-color: blue;
            color: white;
            font-weight: bold;
            font-size: 18px;
            border-radius: 10%;
            border: none;
            cursor: pointer;
        }
        #notice > .title{
            padding-top: 14px;
        }
        img {
            width: 100%;
        }
    
    
    


    
        
        
        
 
        

 javascript文件

$(function(){
    var appertime,disappertime;
    var game=new Dadishu();
    $("#start").click(function(){
        var level = $("#level").val();
        game.setLevel(level);
    });
    $("#end").click(function(){
        game.GameOver();
    });
    $("td").map(function(){
        $(this).click(function(){
            var elem=this;
            game.hit(elem);
        });
    });
    $("#notice > button").click(function(){
        $("#notice").attr("class","noticehide");
    });
});

~(function(){
    window.Dadishu=dadishu;
    function dadishu(){
        this.playing=false;
        this.intId=null;
        this.timeId=null;
        this.score=0;
        this.beat=0;
        this.knock=0;
        this.success=0;
        this.countdown=30;
        this.appertime=500;
        this.disappertime=1000;
    }
    
    dadishu.prototype.GameStart=function(appertime,disappertime){
        if(this.playing){
            return;
        }else{
            if($("#notice").attr("class")!="noticeshow"){
                var that=this;
                that.playing=true;
                that.intId=setInterval(function(){
                    that.show.call(that);
                },this.appertime);
                document.form1.success.value=this.success;
                document.form1.score.value=this.score;
                that.timeShow();
            }else{
                return;
            }
        }
    }
    
    dadishu.prototype.show=function(){
        if(this.playing){
            var current=Math.floor(Math.random()*25);
            $($("td")[current]).html("");
            setTimeout(function(){                
                $($("td")[current]).html("");
            },this.disappertime);
        }
    }
    
    dadishu.prototype.timeShow=function(){
        if(this.playing){
            document.form1.remtime.value=this.countdown;
            if(this.countdown==0){
                this.GameOver();
                return;
            }else{
                this.countdown-=1;
                var that=this;
                this.timeId=setTimeout(function(){
                    that.timeShow();
                },1000);
            }
        }
    }
    
    dadishu.prototype.GameOver=function(){
        if(!this.playing){
            return;
        }else{
            this.timeStop();
            this.playing=false;
            $("#notice > .title").text("Game Over!");
            $("#notice > .message").html("Your score: "+this.score+"
Your hit rate:"+this.success+""); $("#notice").attr("class","noticeshow"); this.clearMouse(); this.success=0; this.score=0; this.knock=0; this.beat=0; this.countdown=30; } } dadishu.prototype.timeStop=function(){ clearInterval(this.intId); clearTimeout(this.timeId); } dadishu.prototype.clearMouse=function(){ for(var i=0;i<25;i++){ $($("td")[i]).html(""); } } dadishu.prototype.hit=function(elem){ if(!this.playing){ if($("#notice").attr("class")!="noticeshow"){ $("#notice > .title").text("Notice:"); $("#notice > .message").text("Please start the game!"); $("#notice").attr("class","noticeshow"); }else{ return; } }else{ this.beat+=1; if($(elem).html()==""){ this.score-=1; this.success=( Math.round(parseFloat(this.knock/this.beat)*10000)/100 )+"%"; document.form1.score.value=this.score; document.form1.success.value=this.success; }else{ this.knock+=1; this.score+=1; this.success=( Math.round(parseFloat(this.knock/this.beat)*10000)/100 )+"%"; document.form1.score.value=this.score ; document.form1.success.value=this.success; $(elem).html(""); $(elem).css("background-color","red"); setTimeout(() => { $(elem).css("background-color","#00ff33"); }, 200); } } } dadishu.prototype.setLevel=function(level){ if(level==1){ this.appertime=1000; this.disappertime=2000; }else if(level==2){ this.appertime=500; this.disappertime=1500; }else if(level==3){ this.appertime=400; this.disappertime=1000; }else{ this.appertime=200; this.disappertime=600; } this.GameStart(); } })()

因为没有拿别人的老鼠图片,所以用的自己的图片

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/726645.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号