GameMale
登陆 / 注册 搜索

USERCENTER

SEARCHSITE

搜索

收起左侧

[其他内容] 【试试看如何在网页里面运行网页游戏】

[复制链接] |关注本帖

五花八门版块眼镜蛇图腾牧羊人风雪之家森林羊男



    不知道为什么会失败,把代码保存到本地后缀html可以正常打开,按这个运行代码就是不行。<!DOCTYPE html>
    <html lang="en">
    <head>
        <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
        <meta name="viewport" content="width=device-width,height=device-height,initial-scale=0.0,user-scalable=no,minimum-scale=1.0,maximum-scale=1.0"/>
        <meta name="apple-mobile-web-app-capable" content="yes"/>
        <meta name="apple-mobile-web-app-status-bar-style" content="black"/><meta content="telephone=no" name="format-detection" />
            <meta content="black" name="apple-mobile-web-app-status-bar-style" />
        <script type="text/javascript">


    window.onload=function(){

    var a="https://files.catbox.moe/jzuxat.png";
    var b="https://files.catbox.moe/jzsnod.png";
    var c="https://files.catbox.moe/8x00ff.png";
    var d="https://files.catbox.moe/ugv6oy.png";
    var e="https://files.catbox.moe/7vwef7.png";
    var f="https://files.catbox.moe/5nu0zb.png";
    var colorArray=new Array(a,b,c,d,e,f); //颜色数组
    var x=5; //x轴行数
    var y=7; //y轴行数
    var totalArray=new Array(); //方块总数
    var sameArray=new Array(); //消灭方块数组
    var countmm=new Array(); //消灭方块颜色数组
    var niu;//每个方块
    var timer=null;
    var four=0;
    var five=0;
    var count=0;
    var dixue=500;
    var wxue=500;

    //初始化方块数组
    for(var i=0;i<x;i++){
    totalArray=new Array();
    for(var j=0;j<y;j++){
    var olor=getRound(); //获取随机颜色
    totalArray[j]=new Array();   
    totalArray[j]['color']=olor;
    totalArray[j]['col']=i;
    totalArray[j]['row']=j;

    }
    }
    countmm['0']=0;
    countmm['1']=0;
    countmm['2']=0;
    countmm['3']=0;
    countmm['4']=0;
    countmm['5']=0;
    starTable(); //初始化方块页面
    begano();

    //初始化方块页面
    function starTable(){
    for(var i=0;i<x;i++){
            for(var j=0;j<y;j++){
    niu=document.getElementById("star"+i+j);
    niu.style='background:url('+colorArray[totalArray[j]['color']]+') no-repeat;background-size:contain';
    }
    }
            var processbar = document.getElementById("jy");
            processbar.style.width = '100%';
            processbar = document.getElementById("ly");
            processbar.style.width = '100%';

    }
    //触发点击事件
    function begano(){ if (timer==null){
            timer==1;
    var bbegan= 'ontouchstart' in document ? 'touchstart' : 'mousedown' ;
    var begancl=function (){
            var move = 'ontouchmove' in document ? 'touchmove' : 'mousemove' ;
            var lastscx=null;
            var lastscy=null;
           
    var movecl=function (e){
    var ev = 'ontouchmove' in document ? e.touches[0] : e ;
    var scx = (ev.pageX-document.getElementById('content').offsetLeft)/document.getElementById('content').offsetWidth ;
    var scy = (ev.pageY-document.getElementById('content').offsetTop)/document.getElementById('content').offsetHeight ; // 这样就能在PC 和 手机上都拿到坐标值了
    if (scx<0.143){scx=0;}else if (scx<0.286){scx=1;}else if (scx<0.429){scx=2;}else if (scx<0.572){scx=3;}else if (scx<0.714){scx=4;}else if (scx<0.857){scx=5;}else {scx=6;}
    if (scy<0.62){scy=0;}else if (scy<0.71){scy=1;}else if (scy<0.8){scy=2;}else if (scy<0.89){scy=3;}else {scy=4;}

    if (lastscx==null){
    lastscx=scx;
    lastscy=scy;
            }else if(lastscx&&lastscx==scx&&lastscy==scy){}else{
            var tmpstarc=new Array();
            tmpstarc=totalArray[scy][scx];
            totalArray[scy][scx]=totalArray[lastscy][lastscx];
            totalArray[lastscy][lastscx]=tmpstarc;
            document.getElementById('star'+scy+''+scx).style='background:url('+colorArray[totalArray[scy][scx]['color']]+') no-repeat;background-size:contain';
            document.getElementById('star'+lastscy+''+lastscx).style='background:url('+colorArray[tmpstarc['color']]+') no-repeat;background-size:contain';
           
    lastscx=scx;
    lastscy=scy;
    }

    }
            var moveend = 'ontouchend' in document ? 'touchend' : 'mouseup' ;
            var endcl=function (){
                    var bbegan= 'ontouchstart' in document ? 'touchstart' : 'mousedown' ;
                    var move = 'ontouchmove' in document ? 'touchmove' : 'mousemove' ;
                    document.removeEventListener(move, movecl,false);
                    document.removeEventListener(bbegan, begancl,false);
                    document.removeEventListener(moveend, endcl,false);
                    movecl=null;console.log('jj');
                    onTouchesBegan();
                    }
            document.addEventListener(moveend,endcl,false);
    document.addEventListener(move,movecl,false);
            document.addEventListener(touchcancel,endcl,false);
    }
    document.addEventListener(bbegan,begancl,false);}else{setTimeout(begano(),1200);}
    }

    //消除所有东西
    function onTouchesBegan(){
    checkfive();

    removeSameColorStars(); //移除相同的方块
    }

    //获取随机颜色
    function getRound(){
    var num=Math.round(Math.random()*(colorArray.length-1));
    console.log('随机数'+num)
    return num;
    }

    //检查数组包含元素
    Array.prototype.contains = function(item){
    for(i=0;i<this.length;i++){
    if(this['col']==item['col'] && this['row']==item['row']){
    return true;
    }
    }
    return false;
    }



    function checkfive(){
    var fibin=new Array();
            for (j=0;j<y;j++){
            var ojo2=totalArray[2][j];
    var ojo0=totalArray[0][j];
    var ojo1=totalArray[1][j];
    var ojo4=totalArray[4][j];
            var ojo3=totalArray[3][j];
            if(ojo0['color']==ojo1['color']&&ojo1['color']==ojo2['color']&&ojo2['color']==ojo3['color']){four++;};
            if(ojo4['color']==ojo1['color']&&ojo1['color']==ojo2['color']&&ojo2['color']==ojo3['color']){four++;};
            if(ojo0['color']==ojo1['color']&&ojo1['color']==ojo2['color']&&ojo2['color']==ojo3['color']&&ojo2['color']==ojo4['color']){five++;};
            if(ojo0['color']==ojo1['color']&&ojo2['color']==ojo1['color']){fibin.push(ojo0);fibin.push(ojo1);fibin.push(ojo2);};
            if(ojo3['color']==ojo1['color']&&ojo2['color']==ojo1['color']){fibin.push(ojo3);fibin.push(ojo1);fibin.push(ojo2);};
            if(ojo4['color']==ojo3['color']&&ojo2['color']==ojo3['color']){fibin.push(ojo3);fibin.push(ojo4);fibin.push(ojo2);};
            }
            for (i=0;i<x;i++){
                    var pip0=totalArray[0];
                    var pip1=totalArray[1];
                    var pip2=totalArray[2];
                    var pip3=totalArray[3];
                    var pip4=totalArray[4];
                    var pip5=totalArray[5];
                    var pip6=totalArray[6];
            if(pip0['color']==pip1['color']&&pip2['color']==pip1['color']){fibin.push(pip0);fibin.push(pip1);fibin.push(pip2);
            if(pip0['color']==pip3['color']){four++;if(pip4['color']==pip1['color']){five++;}}};
            if(pip3['color']==pip1['color']&&pip2['color']==pip1['color']){fibin.push(pip3);fibin.push(pip1);fibin.push(pip2);
            if(pip1['color']==pip4['color']){four++;if(pip5['color']==pip1['color']){five++;}}};
            if(pip4['color']==pip3['color']&&pip2['color']==pip3['color']){fibin.push(pip3);fibin.push(pip4);fibin.push(pip2);
            if(pip5['color']==pip3['color']){four++;if(pip6['color']==pip2['color']){five++;}}};
            if(pip3['color']==pip4['color']&&pip5['color']==pip3['color']){fibin.push(pip3);fibin.push(pip4);fibin.push(pip5);
            if(pip6['color']==pip3['color']){four++;}};
            if(pip4['color']==pip5['color']&&pip5['color']==pip6['color']){fibin.push(pip4);fibin.push(pip5);fibin.push(pip6);};
            }
    //统计相同的部分
    if(fibin.length>0){
    for(var j=0;j<fibin.length;j++){
    if(!sameArray.contains(fibin[j])){
    sameArray.push(fibin[j]);
    }}}
            }

    //移除相同的方块
    function removeSameColorStars(){
    //相同颜色的方块是否大于1
    var length=sameArray.length;
    if(length>1){
    for(var k=0;k<length;k++){
    var simpleStar=sameArray[k];
    if(simpleStar){
    var col=simpleStar['col'];
    var row=simpleStar['row'];
    var olor=simpleStar['color'];
    countmm[olor]=countmm[olor]+1;
    console.log(countmm[olor]);
    totalArray[col].splice(row,1,null);
    document.getElementById('star'+col+''+row).style.background='none';
    count++;
    }
    }

    dixue=dixue-3*length-8*four-15*five;
    var processbar = document.getElementById("jy");
            processbar.style.width = dixue/500/0.01+'%';
    if(dixue<0){        //成功进入下一关暂时只是重来
    document.getElementById('greatconfig').style='position:absolute;display:block;width:100%;height:100%;left:0;top:0;background:rgba(216,26,255,0.78)';

    }
    }
    sameArray=[];
    fallStar();
    }

    //转换数组 获取第j列的数组
    function getLtotalArray(j){
    var LtotalArray=new Array();
    for(var i=0;i<x;i++){   
    LtotalArray=new Array();
    if(totalArray[j]==null){
    LtotalArray.splice(i,1,null);
    }else{
    LtotalArray['color']=totalArray[j]['color'];   
    LtotalArray['col']=totalArray[j]['col'];
    LtotalArray['row']=totalArray[j]['row'];
    }
    }
    return LtotalArray;
    }

    //方块掉落 填充空缺
    function fallStar(){
    for(var j=0;j<y;j++){
    //循环得到每一列的数组
    var sprites=getLtotalArray(j);
    var length=sprites.length;
    for(var i=0;i<length;i++){
    var pSprite0=sprites;
    //找到空方块
    if(pSprite0==null){
    var k=i+1;
    while(k<length){
    var upSprite=sprites[k];
    if(upSprite!=null){
    upSprite['col']=i;
    upSprite['row']=j;
    totalArray.splice(j,1,upSprite);
    totalArray[k].splice(j,1,null);
    sprites.splice(i,1,upSprite);
    sprites.splice(k,1,null);
    document.getElementById('star'+i+''+j).style='background:url('+colorArray[upSprite['color']]+') no-repeat;background-size:contain';
    document.getElementById('star'+k+''+j).style.background='none';
    k=length;
    }
    k++;
    }
    }
    }
    }
    //补空
    for(var j=0;j<y;j++){
    var sprites=getLtotalArray(j);
    var length=sprites.length;
    for(var i=0;i<x;i++){
    var upSprite=sprites;
    if(upSprite==null){
            var upSprite=new Array();
    upSprite['col']=i;
    upSprite['row']=j;upSprite['color']=getRound();
    totalArray.splice(j,1,upSprite);
    sprites.splice(i,1,upSprite);
    console.log(upSprite);
    document.getElementById('star'+i+''+j).style='background:url('+colorArray[upSprite['color']]+') no-repeat;background-size:contain;';
    }}}
    document.getElementById('meessg').innerHTML='相同的有'+count+'个,四连'+four+'个,五连'+five+'个。'+countmm['0']+countmm['1']+countmm['2']+countmm['3']+countmm['4']+countmm['5'];
    timer=null;
    begano();
    }

    function deadi(){
            document.getElementById('deadconfig').style='position:absolute;display:block;width:100%;height:100%;left:0;top:0;background:rgba(216,26,255,0.78);';
           
    }
    //超时也算输
    setTimeout("deadi()",120000);
    var dfsh=setInterval(function(){
            wxue=wxue-2;
            var pro = document.getElementById("ly");
            pro.style.width = wxue/500/0.01+'%';
            if (wxue<0){deadi();}
            },600);
    }
    function deadi(){
            document.getElementById('deadconfig').style='position:absolute;display:block;width:100%;height:100%;left:0;top:0;background:rgba(216,26,255,0.78);';
           
    }
    function reee(){window.location.reload();}
    </script>

        <title>三国转珠大战</title>
           
    <title>puzzle</title>
    <style type="text/css">
            body {
    min-width: 320px;
    font-family: 'microsoft yahei',Verdana,Arial,Helvetica,sans-serif;
    color: #fff;
    text-shadow:0px 0px 3px #000;
    overflow:hidden;outline:none;border:none;
    -webkit-text-size-adjust: none ;overflow:hidden; scroll:no;
            -moz-user-select: none;
            -webkit-user-select: none;
            -ms-user-select: none;
            -khtml-user-select: none;
            user-select: none;
    }:focus{outline:none;}
    #content{top:0%;left:0%;border:none;position:absolute;width:480px;height:720px;}
    @media all and (orientation:landscape){#content{color:#fff;font-weight:bold;}}
    @media screen and (orientation:portrait){#content{top:0%;left:0%;border:none;position:absolute;width:100%;height:100%;}}
    #bg{width:100%;height:100%;background:url(https://files.catbox.moe/j76co3.png) no-repeat;background-size:cover;}
    #meessg{width:80%;height:20%;top:35%;left:10%%;position:absolute;font-size:16px;}
    #ssj{width:10%;height:8%;left:1%;top:3%;position:absolute;}
    #jykuang{ width:60%;overflow:hidden;height:2.5%;top:1.5%;left:20%;position:absolute; border-radius:8px;}
    #jy{ background:rgb(165,156,255); left:0%;top:0%;position:relative; height:100%; }
    #big{width:100%;height:30%;left:0%;top:5%;position:absolute;background:url(https://files.catbox.moe/7ad4s1.png) no-repeat;background-size:contain}
    #wjiangkuang{width:50%;height:10%;right:0;top:40.5%;position:absolute;}
    #wjiangkuang .star{width:28%;height:100%;border:none;text-align:right;cursor:pointer;}
    #lykuang{ width:96%;overflow:hidden;height:1.8%;top:51%;left:2%;position:absolute; border-radius:8px;}
    #ly{ background:rgb(39,255,5); left:0%;top:0%;position:relative; height:100%; }
    #contenttab{width:100%;height:45%;position:absolute;bottom:2%;left:1%;}
    #contenttab #sta1{width:100%;height:20%;position:absolute;top:0;left:0;}
    #contenttab #sta2{width:100%;height:20%;position:absolute;top:20%;left:0;}
    #contenttab #sta3{width:100%;height:20%;position:absolute;top:40%;left:0;}
    #contenttab #sta4{width:100%;height:20%;position:absolute;top:60%;left:0;}
    #contenttab #sta5{width:100%;height:20%;position:absolute;top:80%;left:0;}
    #contenttab .star{width:12.5%;height:100%;border:none;text-align:center;cursor:pointer;transition: all 500ms ease-out;
    -webkit-animation: cssAnimation 500ms ;}
    @-webkit-keyframes cssAnimation {from { -webkit-transform:  rotate(270deg) scale(1.276) }  to { -webkit-transform:  rotate(0deg) scale(1)  } }
    #aginanniu{width:60%;height:15%;right:20%;top:65%;position:absolute;}
    </style>

    </head>
    <body>
    <div id="content"><div id="bg"></div>   
    <text id="meessg"></text>
    <img id="ssj" src="https://files.catbox.moe/sbyir0.png">
    <div id="jykuang"><div id="jy"></div>
    </div><audio autoplay="autoplay" loop="loop">
      <source src="https://files.catbox.moe/5qql14.ogg" type="audio/ogg" />
    Your browser does not support this audio format.
    </audio>
    <div id="big">
    </div>
    <div id="wjiangkuang">
    <img class="star" src="https://files.catbox.moe/j8goy1.png">
    <img class="star" src="https://files.catbox.moe/h7xrva.png">
    <img class="star" src="https://files.catbox.moe/lby9vg.png">

    </div>
    <div id="lykuang"><div id="ly"></div>
    </div>
    <div id="contenttab">
    <div id="sta1">
    <button class="star" id="star00" ></button>
    <button class="star" id="star01" ></button>
    <button class="star" id="star02" ></button>
    <button class="star" id="star03" ></button>
    <button class="star" id="star04" ></button>
    <button class="star" id="star05" ></button>
    <button class="star" id="star06" ></button>
    </div>
    <div id="sta2">
    <button class="star" id="star10" ></button>
    <button class="star" id="star11" ></button>
    <button class="star" id="star12" ></button>
    <button class="star" id="star13" ></button>
    <button class="star" id="star14" ></button>
    <button class="star" id="star15" ></button>
    <button class="star" id="star16" ></button>
    </div>
    <div id="sta3">
    <button class="star" id="star20" ></button>
    <button class="star" id="star21" ></button>
    <button class="star" id="star22" ></button>
    <button class="star" id="star23" ></button>
    <button class="star" id="star24" ></button>
    <button class="star" id="star25" ></button>
    <button class="star" id="star26" ></button>
    </div>
    <div id="sta4">
    <button class="star" id="star30" ></button>
    <button class="star" id="star31" ></button>
    <button class="star" id="star32" ></button>
    <button class="star" id="star33" ></button>
    <button class="star" id="star34" ></button>
    <button class="star" id="star35" ></button>
    <button class="star" id="star36" ></button>
    </div>
    <div id="sta5">
    <button class="star" id="star40" ></button>
    <button class="star" id="star41" ></button>
    <button class="star" id="star42" ></button>
    <button class="star" id="star43" ></button>
    <button class="star" id="star44" ></button>
    <button class="star" id="star45" ></button>
    <button class="star" id="star46" ></button>
    </div>
    </div><div id="deadconfig" style="display:none">
    <text style="color:black;font-size:30px;">你已经死了,真是不努力。
    明明这么easy。
    </text>
    <button id="aginanniu" style="background:url(https://files.catbox.moe/5m291h.png) no-repeat;background-size:cover"></button>
    </div><div id="greatconfig" style="display:none">
    <text style="color:gold;font-size:60px;">好耶,过关了!
    </text>
    <button id="aginanniu" style="background:url(https://files.catbox.moe/5m291h.png) no-repeat;background-size:cover"></button>
    </div>
    </div>
    </body>
    </html>
    回复

    使用道具 举报

    巴比伦辞典岛田源氏白野威業火死鬥永远的克叔终归一人『随时随地开启!』『随时随地开启!』奇思妙想小小安全帽

      本帖最后由 user0516 于 2022-9-20 17:18 编辑

      我這邊按下運行代碼後好像出問題了,圖片沒出來,我也不知道該怎麼動
      如果是想要做網頁遊戲,需要讓使用者得到網頁的資料才能跑,目前似乎沒圖片資料

      回复

      使用道具 举报

      王者之盾半生黄金种Birth of Sky雄躯的昇格【夏日限定】夏日的泰凯斯炙热的格拉迪欧拉斯保加利亚妖王業火死鬥性感男神GM

        回复

        使用道具 举报

        裸体克里斯『落樱缤纷』炽天使之拥十周年扭蛋 - 橙邪恶圣杯

          回复

          使用道具 举报

          实现梦想業火死鬥魔法不朽·传奇不熄卡洛斯·奥利维拉白野威十年一梦官复原职男巫之歌永浴爱河虚空之海的鲸

            回复

            使用道具 举报

            黑暗水晶铁牛岛田半藏人鱼之泪暗影烈焰男用贞操带男色风暴虎克船长.格拉迪欧拉斯艾利克斯.

              回复

              使用道具 举报

              风雪之家无尽的怀表被释放的灵魂【圣诞限定】心心念念小雪人十字叶章乘风破浪的武士刀威尔卡斯甘道夫·涅槃重生至死不渝

                本帖最后由 识缘无情 于 2022-9-20 17:48 编辑

                url(../img/zd/'+totalArray[scy][scx]['color']+'.png)
                如果尝试,至少要把图片地址改到自己的地方,现在指向是论坛的图片地址(当然不存在)

                回复

                使用道具 举报

                戴蒙‧萨尔瓦托.星尘龙汤姆·赫兰德.驯化红龙幼崽大古.黑龙幼崽男色风暴堕落之舞

                  回复

                  使用道具 举报

                  凯登‧阿兰科『落樱缤纷』裸体克里斯莱因哈特·威尔海姆最终幻想XIV谜魔法不朽·传奇不熄Dante

                    回复

                    使用道具 举报

                    特殊-家园卫士Ⓡ贝优妮塔特殊-家园卫士Ⓛ卡德加(Khadgar).鬼王酒吞童子驯化黑龙幼崽GM論壇勛章

                      回复

                      使用道具 举报

                      吃饱金币的Doge夏日柯基泰比里厄斯DanteVergil月光骑士月光骑士Joker.自由

                        回复

                        使用道具 举报

                        岛田源氏巴比伦辞典火柴 - Gamemale艾吉奥小小舞台漂洋小船不曾寄出的信件星芒戒指虎克船长.神灯.

                          回复

                          使用道具 举报

                          『住在GM村』破损的旧书格拉迪欧拉斯雪王的心脏『星河碎片』『灰域来音』预知水晶球炽天使之拥『伊黎丝的赞词』纯真护剑

                            回复

                            使用道具 举报

                            天涯‧此时GM論壇初心者畢業證書生化危机:复仇『还乡歌』恶魔城【新手友好】昆進

                              回复

                              使用道具 举报

                              星尘龙黑龙幼崽驯化红龙幼崽达拉然闪耀的赫尔墨斯之杖神奇四叶草幽灵竹筒

                                回复

                                使用道具 举报

                                卡洛斯·奥利维拉致命危机百相千面-殇街头霸王但丁超级无敌名贵金卡艾德尔大恶魔

                                  回复

                                  使用道具 举报

                                  【新手友好】昆進

                                    1. totalArray<i>=new Array();
                                    复制代码
                                    数组的括号写错了吧...
                                      收起(3)
                                    回复

                                    使用道具 举报

                                    【新手友好】昆進

                                      本帖最后由 节操君啊 于 2022-9-25 13:19 编辑


                                      <!DOCTYPE html>
                                      <html lang="en">

                                      <head>
                                      <meta http-equiv="content-type" content="text/html;charset=utf-8" />

                                      <meta name="viewport"
                                      content="width=device-width,height=device-height,initial-scale=0.0,user-scalable=no,minimum-scale=1.0,maximum-scale=1.0" />

                                      <meta name="apple-mobile-web-app-capable" content="yes" />

                                      <meta name="apple-mobile-web-app-status-bar-style" content="black" />
                                      <meta content="telephone=no" name="format-detection" />
                                      <meta content="black" name="apple-mobile-web-app-status-bar-style" />

                                      <script type="text/javascript">
                                      window.onload = function () {
                                      var a = "https://files.catbox.moe/jzuxat.png";
                                      var b = "https://files.catbox.moe/jzsnod.png";
                                      var c = "https://files.catbox.moe/8x00ff.png";
                                      var d = "https://files.catbox.moe/ugv6oy.png";
                                      var e = "https://files.catbox.moe/7vwef7.png";
                                      var f = "https://files.catbox.moe/5nu0zb.png";
                                      var colorArray = new Array(a, b, c, d, e, f); //颜色数组
                                      var x = 5; //x轴行数
                                      var y = 7; //y轴行数
                                      var totalArray = new Array(); //方块总数
                                      var sameArray = new Array(); //消灭方块数组
                                      var countmm = new Array(); //消灭方块颜色数组
                                      var niu; //每个方块
                                      var timer = null;
                                      var four = 0;
                                      var five = 0;
                                      var count = 0;
                                      var dixue = 500;
                                      var wxue = 500;

                                      //初始化方块数组
                                      for (var ix = 0; ix < x; ix++) {
                                      totalArray[ix] = new Array();
                                      for (var j = 0; j < y; j++) {
                                      var olor = getRound(); //获取随机颜色
                                      totalArray[ix][j] = new Array();
                                      totalArray[ix][j]["color"] = olor;
                                      totalArray[ix][j]["col"] = ix;
                                      totalArray[ix][j]["row"] = j;
                                      }
                                      }
                                      countmm["0"] = 0;
                                      countmm["1"] = 0;
                                      countmm["2"] = 0;
                                      countmm["3"] = 0;
                                      countmm["4"] = 0;
                                      countmm["5"] = 0;
                                      starTable(); //初始化方块页面
                                      begano();

                                      //初始化方块页面
                                      function starTable() {
                                      for (var ix = 0; ix < x; ix++) {
                                      for (var j = 0; j < y; j++) {
                                      niu = document.getElementById("star" + ix + j);
                                      niu.style =
                                      "background:url(" +
                                      colorArray[totalArray[ix][j]["color"]] +
                                      ") no-repeat;background-size:contain";
                                      }
                                      }
                                      var processbar = document.getElementById("jy");
                                      processbar.style.width = "100%";
                                      processbar = document.getElementById("ly");
                                      processbar.style.width = "100%";
                                      }
                                      //触发点击事件
                                      function begano() {
                                      if (timer == null) {
                                      timer == 1;
                                      var bbegan =
                                      "ontouchstart" in document ? "touchstart" : "mousedown";
                                      var begancl = function () {
                                      var move = "ontouchmove" in document ? "touchmove" : "mousemove";
                                      var lastscx = null;
                                      var lastscy = null;

                                      var movecl = function (e) {
                                      var ev = "ontouchmove" in document ? e.touches[0] : e;
                                      var scx =
                                      (ev.pageX - document.getElementById("content").offsetLeft) /
                                      document.getElementById("content").offsetWidth;
                                      var scy =
                                      (ev.pageY - document.getElementById("content").offsetTop) /
                                      document.getElementById("content").offsetHeight; // 这样就能在PC 和 手机上都拿到坐标值了
                                      if (scx < 0.143) {
                                      scx = 0;
                                      } else if (scx < 0.286) {
                                      scx = 1;
                                      } else if (scx < 0.429) {
                                      scx = 2;
                                      } else if (scx < 0.572) {
                                      scx = 3;
                                      } else if (scx < 0.714) {
                                      scx = 4;
                                      } else if (scx < 0.857) {
                                      scx = 5;
                                      } else {
                                      scx = 6;
                                      }
                                      if (scy < 0.62) {
                                      scy = 0;
                                      } else if (scy < 0.71) {
                                      scy = 1;
                                      } else if (scy < 0.8) {
                                      scy = 2;
                                      } else if (scy < 0.89) {
                                      scy = 3;
                                      } else {
                                      scy = 4;
                                      }

                                      if (lastscx == null) {
                                      lastscx = scx;
                                      lastscy = scy;
                                      } else if (lastscx && lastscx == scx && lastscy == scy) {
                                      } else {
                                      var tmpstarc = new Array();
                                      tmpstarc = totalArray[scy][scx];
                                      totalArray[scy][scx] = totalArray[lastscy][lastscx];
                                      totalArray[lastscy][lastscx] = tmpstarc;
                                      document.getElementById("star" + scy + "" + scx).style =
                                      "background:url(" +
                                      colorArray[totalArray[scy][scx]["color"]] +
                                      ") no-repeat;background-size:contain";
                                      document.getElementById(
                                      "star" + lastscy + "" + lastscx
                                      ).style =
                                      "background:url(" +
                                      colorArray[tmpstarc["color"]] +
                                      ") no-repeat;background-size:contain";

                                      lastscx = scx;
                                      lastscy = scy;
                                      }
                                      };
                                      var moveend = "ontouchend" in document ? "touchend" : "mouseup";
                                      var endcl = function () {
                                      var bbegan =
                                      "ontouchstart" in document ? "touchstart" : "mousedown";
                                      var move =
                                      "ontouchmove" in document ? "touchmove" : "mousemove";
                                      document.removeEventListener(move, movecl, false);
                                      document.removeEventListener(bbegan, begancl, false);
                                      document.removeEventListener(moveend, endcl, false);
                                      movecl = null;
                                      console.log("jj");
                                      onTouchesBegan();
                                      };
                                      document.addEventListener(moveend, endcl, false);
                                      document.addEventListener(move, movecl, false);
                                      // document.addEventListener(touchcancel, endcl, false);
                                      };
                                      document.addEventListener(bbegan, begancl, false);
                                      } else {
                                      setTimeout(begano(), 1200);
                                      }
                                      }

                                      //消除所有东西
                                      function onTouchesBegan() {
                                      checkfive();

                                      removeSameColorStars(); //移除相同的方块
                                      }

                                      //获取随机颜色
                                      function getRound() {
                                      var num = Math.round(Math.random() * (colorArray.length - 1));
                                      console.log("随机数" + num);
                                      return num;
                                      }

                                      //检查数组包含元素
                                      Array.prototype.contains = function (item) {
                                      for (ix = 0; ix < this.length; ix++) {
                                      if (
                                      this[ix]["col"] == item["col"] &&
                                      this[ix]["row"] == item["row"]
                                      ) {
                                      return true;
                                      }
                                      }
                                      return false;
                                      };

                                      function checkfive() {
                                      var fibin = new Array();
                                      for (j = 0; j < y; j++) {
                                      var ojo2 = totalArray[2][j];
                                      var ojo0 = totalArray[0][j];
                                      var ojo1 = totalArray[1][j];
                                      var ojo4 = totalArray[4][j];
                                      var ojo3 = totalArray[3][j];
                                      if (
                                      ojo0["color"] == ojo1["color"] &&
                                      ojo1["color"] == ojo2["color"] &&
                                      ojo2["color"] == ojo3["color"]
                                      ) {
                                      four++;
                                      }
                                      if (
                                      ojo4["color"] == ojo1["color"] &&
                                      ojo1["color"] == ojo2["color"] &&
                                      ojo2["color"] == ojo3["color"]
                                      ) {
                                      four++;
                                      }
                                      if (
                                      ojo0["color"] == ojo1["color"] &&
                                      ojo1["color"] == ojo2["color"] &&
                                      ojo2["color"] == ojo3["color"] &&
                                      ojo2["color"] == ojo4["color"]
                                      ) {
                                      five++;
                                      }
                                      if (
                                      ojo0["color"] == ojo1["color"] &&
                                      ojo2["color"] == ojo1["color"]
                                      ) {
                                      fibin.push(ojo0);
                                      fibin.push(ojo1);
                                      fibin.push(ojo2);
                                      }
                                      if (
                                      ojo3["color"] == ojo1["color"] &&
                                      ojo2["color"] == ojo1["color"]
                                      ) {
                                      fibin.push(ojo3);
                                      fibin.push(ojo1);
                                      fibin.push(ojo2);
                                      }
                                      if (
                                      ojo4["color"] == ojo3["color"] &&
                                      ojo2["color"] == ojo3["color"]
                                      ) {
                                      fibin.push(ojo3);
                                      fibin.push(ojo4);
                                      fibin.push(ojo2);
                                      }
                                      }
                                      for (ix = 0; ix < x; ix++) {
                                      var pip0 = totalArray[ix][0];
                                      var pip1 = totalArray[ix][1];
                                      var pip2 = totalArray[ix][2];
                                      var pip3 = totalArray[ix][3];
                                      var pip4 = totalArray[ix][4];
                                      var pip5 = totalArray[ix][5];
                                      var pip6 = totalArray[ix][6];
                                      if (
                                      pip0["color"] == pip1["color"] &&
                                      pip2["color"] == pip1["color"]
                                      ) {
                                      fibin.push(pip0);
                                      fibin.push(pip1);
                                      fibin.push(pip2);
                                      if (pip0["color"] == pip3["color"]) {
                                      four++;
                                      if (pip4["color"] == pip1["color"]) {
                                      five++;
                                      }
                                      }
                                      }
                                      if (
                                      pip3["color"] == pip1["color"] &&
                                      pip2["color"] == pip1["color"]
                                      ) {
                                      fibin.push(pip3);
                                      fibin.push(pip1);
                                      fibin.push(pip2);
                                      if (pip1["color"] == pip4["color"]) {
                                      four++;
                                      if (pip5["color"] == pip1["color"]) {
                                      five++;
                                      }
                                      }
                                      }
                                      if (
                                      pip4["color"] == pip3["color"] &&
                                      pip2["color"] == pip3["color"]
                                      ) {
                                      fibin.push(pip3);
                                      fibin.push(pip4);
                                      fibin.push(pip2);
                                      if (pip5["color"] == pip3["color"]) {
                                      four++;
                                      if (pip6["color"] == pip2["color"]) {
                                      five++;
                                      }
                                      }
                                      }
                                      if (
                                      pip3["color"] == pip4["color"] &&
                                      pip5["color"] == pip3["color"]
                                      ) {
                                      fibin.push(pip3);
                                      fibin.push(pip4);
                                      fibin.push(pip5);
                                      if (pip6["color"] == pip3["color"]) {
                                      four++;
                                      }
                                      }
                                      if (
                                      pip4["color"] == pip5["color"] &&
                                      pip5["color"] == pip6["color"]
                                      ) {
                                      fibin.push(pip4);
                                      fibin.push(pip5);
                                      fibin.push(pip6);
                                      }
                                      }
                                      //统计相同的部分
                                      if (fibin.length > 0) {
                                      for (var j = 0; j < fibin.length; j++) {
                                      if (!sameArray.contains(fibin[j])) {
                                      sameArray.push(fibin[j]);
                                      }
                                      }
                                      }
                                      }

                                      //移除相同的方块
                                      function removeSameColorStars() {
                                      //相同颜色的方块是否大于1
                                      var length = sameArray.length;
                                      if (length > 1) {
                                      for (var k = 0; k < length; k++) {
                                      var simpleStar = sameArray[k];
                                      if (simpleStar) {
                                      var col = simpleStar["col"];
                                      var row = simpleStar["row"];
                                      var olor = simpleStar["color"];
                                      countmm[olor] = countmm[olor] + 1;
                                      console.log(countmm[olor]);
                                      totalArray[col].splice(row, 1, null);
                                      document.getElementById(
                                      "star" + col + "" + row
                                      ).style.background = "none";
                                      count++;
                                      }
                                      }

                                      dixue = dixue - 3 * length - 8 * four - 15 * five;
                                      var processbar = document.getElementById("jy");
                                      processbar.style.width = dixue / 500 / 0.01 + "%";
                                      if (dixue < 0) {
                                      //成功进入下一关暂时只是重来
                                      document.getElementById("greatconfig").style =
                                      "position:absolute;display:block;width:100%;height:100%;left:0;top:0;background:rgba(216,26,255,0.78)";
                                      }
                                      }
                                      sameArray = [];
                                      fallStar();
                                      }

                                      //转换数组 获取第j列的数组
                                      function getLtotalArray(j) {
                                      var LtotalArray = new Array();
                                      for (var ix = 0; ix < x; ix++) {
                                      LtotalArray[ix] = new Array();
                                      if (totalArray[ix][j] == null) {
                                      LtotalArray.splice(ix, 1, null);
                                      } else {
                                      LtotalArray[ix]["color"] = totalArray[ix][j]["color"];
                                      LtotalArray[ix]["col"] = totalArray[ix][j]["col"];
                                      LtotalArray[ix]["row"] = totalArray[ix][j]["row"];
                                      }
                                      }
                                      return LtotalArray;
                                      }

                                      //方块掉落 填充空缺
                                      function fallStar() {
                                      for (var j = 0; j < y; j++) {
                                      //循环得到每一列的数组
                                      var sprites = getLtotalArray(j);
                                      var length = sprites.length;
                                      for (var ix = 0; ix < length; ix++) {
                                      var pSprite0 = sprites[ix];
                                      //找到空方块
                                      if (pSprite0 == null) {
                                      var k = ix + 1;
                                      while (k < length) {
                                      var upSprite = sprites[k];
                                      if (upSprite != null) {
                                      upSprite["col"] = ix;
                                      upSprite["row"] = j;
                                      totalArray[ix].splice(j, 1, upSprite);
                                      totalArray[k].splice(j, 1, null);
                                      sprites.splice(ix, 1, upSprite);
                                      sprites.splice(k, 1, null);
                                      document.getElementById("star" + ix + "" + j).style =
                                      "background:url(" +
                                      colorArray[upSprite["color"]] +
                                      ") no-repeat;background-size:contain";
                                      document.getElementById(
                                      "star" + k + "" + j
                                      ).style.background = "none";
                                      k = length;
                                      }
                                      k++;
                                      }
                                      }
                                      }
                                      }
                                      //补空
                                      for (var j = 0; j < y; j++) {
                                      var sprites = getLtotalArray(j);
                                      var length = sprites.length;
                                      for (var ix = 0; ix < x; ix++) {
                                      var upSprite = sprites[ix];
                                      if (upSprite == null) {
                                      var upSprite = new Array();
                                      upSprite["col"] = ix;
                                      upSprite["row"] = j;
                                      upSprite["color"] = getRound();
                                      totalArray[ix].splice(j, 1, upSprite);
                                      sprites.splice(ix, 1, upSprite);
                                      console.log(upSprite);
                                      document.getElementById("star" + ix + "" + j).style =
                                      "background:url(" +
                                      colorArray[upSprite["color"]] +
                                      ") no-repeat;background-size:contain;";
                                      }
                                      }
                                      }
                                      document.getElementById("meessg").innerHTML =
                                      "相同的有" +
                                      count +
                                      "个,四连" +
                                      four +
                                      "个,五连" +
                                      five +
                                      "个。" +
                                      countmm["0"] +
                                      countmm["1"] +
                                      countmm["2"] +
                                      countmm["3"] +
                                      countmm["4"] +
                                      countmm["5"];
                                      timer = null;
                                      begano();
                                      }

                                      function deadi() {
                                      document.getElementById("deadconfig").style =
                                      "position:absolute;display:block;width:100%;height:100%;left:0;top:0;background:rgba(216,26,255,0.78);";
                                      }
                                      //超时也算输
                                      setTimeout("deadi()", 120000);
                                      var dfsh = setInterval(function () {
                                      wxue = wxue - 2;
                                      var pro = document.getElementById("ly");
                                      pro.style.width = wxue / 500 / 0.01 + "%";
                                      if (wxue < 0) {
                                      deadi();
                                      }
                                      }, 600);
                                      };
                                      function deadi() {
                                      document.getElementById("deadconfig").style =
                                      "position:absolute;display:block;width:100%;height:100%;left:0;top:0;background:rgba(216,26,255,0.78);";
                                      }
                                      function reee() {
                                      window.location.reload();
                                      }
                                      </script>
                                      <title>三国转珠大战</title>
                                      <title>puzzle</title>
                                      <style type="text/css">
                                      body {
                                      min-width: 320px;
                                      font-family: "microsoft yahei", Verdana, Arial, Helvetica, sans-serif;
                                      color: #fff;
                                      text-shadow: 0px 0px 3px #000;
                                      overflow: hidden;
                                      outline: none;
                                      border: none;
                                      -webkit-text-size-adjust: none;
                                      overflow: hidden;
                                      scroll: no;
                                      -moz-user-select: none;
                                      -webkit-user-select: none;
                                      -ms-user-select: none;
                                      -khtml-user-select: none;
                                      user-select: none;
                                      }

                                      :focus {
                                      outline: none;
                                      }

                                      #content {
                                      top: 0%;
                                      left: 0%;
                                      border: none;
                                      position: absolute;
                                      width: 480px;
                                      height: 720px;
                                      }

                                      @media all and (orientation: landscape) {
                                      #content {
                                      color: #fff;
                                      font-weight: bold;
                                      }
                                      }

                                      @media screen and (orientation: portrait) {
                                      #content {
                                      top: 0%;
                                      left: 0%;
                                      border: none;
                                      position: absolute;
                                      width: 100%;
                                      height: 100%;
                                      }
                                      }

                                      #bg {
                                      width: 100%;
                                      height: 100%;
                                      background: url('https://files.catbox.moe/j76co3.png') no-repeat;
                                      background-size: cover;
                                      }

                                      #meessg {
                                      width: 80%;
                                      height: 20%;
                                      top: 35%;
                                      left: 10%%;
                                      position: absolute;
                                      font-size: 16px;
                                      }

                                      #ssj {
                                      width: 10%;
                                      height: 8%;
                                      left: 1%;
                                      top: 3%;
                                      position: absolute;
                                      }

                                      #jykuang {
                                      width: 60%;
                                      overflow: hidden;
                                      height: 2.5%;
                                      top: 1.5%;
                                      left: 20%;
                                      position: absolute;
                                      border-radius: 8px;
                                      }

                                      #jy {
                                      background: rgb(165, 156, 255);
                                      left: 0%;
                                      top: 0%;
                                      position: relative;
                                      height: 100%;
                                      }

                                      #big {
                                      width: 100%;
                                      height: 30%;
                                      left: 0%;
                                      top: 5%;
                                      position: absolute;
                                      background: url('https://files.catbox.moe/7ad4s1.png') no-repeat;
                                      background-size: contain;
                                      }

                                      #wjiangkuang {
                                      width: 50%;
                                      height: 10%;
                                      right: 0;
                                      top: 40.5%;
                                      position: absolute;
                                      }

                                      #wjiangkuang .star {
                                      width: 28%;
                                      height: 100%;
                                      border: none;
                                      text-align: right;
                                      cursor: pointer;
                                      }

                                      #lykuang {
                                      width: 96%;
                                      overflow: hidden;
                                      height: 1.8%;
                                      top: 51%;
                                      left: 2%;
                                      position: absolute;
                                      border-radius: 8px;
                                      }

                                      #ly {
                                      background: rgb(39, 255, 5);
                                      left: 0%;
                                      top: 0%;
                                      position: relative;
                                      height: 100%;
                                      }

                                      #contenttab {
                                      width: 100%;
                                      height: 45%;
                                      position: absolute;
                                      bottom: 2%;
                                      left: 1%;
                                      }

                                      #contenttab #sta1 {
                                      width: 100%;
                                      height: 20%;
                                      position: absolute;
                                      top: 0;
                                      left: 0;
                                      }

                                      #contenttab #sta2 {
                                      width: 100%;
                                      height: 20%;
                                      position: absolute;
                                      top: 20%;
                                      left: 0;
                                      }

                                      #contenttab #sta3 {
                                      width: 100%;
                                      height: 20%;
                                      position: absolute;
                                      top: 40%;
                                      left: 0;
                                      }

                                      #contenttab #sta4 {
                                      width: 100%;
                                      height: 20%;
                                      position: absolute;
                                      top: 60%;
                                      left: 0;
                                      }

                                      #contenttab #sta5 {
                                      width: 100%;
                                      height: 20%;
                                      position: absolute;
                                      top: 80%;
                                      left: 0;
                                      }

                                      #contenttab .star {
                                      width: 12.5%;
                                      height: 100%;
                                      border: none;
                                      text-align: center;
                                      cursor: pointer;
                                      transition: all 500ms ease-out;
                                      -webkit-animation: cssAnimation 500ms;
                                      }

                                      @-webkit-keyframes cssAnimation {
                                      from {
                                      -webkit-transform: rotate(270deg) scale(1.276);
                                      }

                                      to {
                                      -webkit-transform: rotate(0deg) scale(1);
                                      }
                                      }

                                      #aginanniu {
                                      width: 60%;
                                      height: 15%;
                                      right: 20%;
                                      top: 65%;
                                      position: absolute;
                                      }
                                      </style>
                                      </head>

                                      <body>
                                      <div id="content">
                                      <div id="bg"></div>

                                      <text id="meessg"></text>
                                      <img id="ssj" src="https://files.catbox.moe/sbyir0.png" />
                                      <div id="jykuang">
                                      <div id="jy"></div>
                                      </div>
                                      <audio autoplay="autoplay" loop="loop">
                                        
                                      <source src="https://files.catbox.moe/5qql14.ogg" type="audio/ogg" />
                                      Your browser does not support this audio format.
                                      </audio>
                                      <div id="big"></div>
                                      <div id="wjiangkuang">
                                      <img class="star" src="https://files.catbox.moe/j8goy1.png" />
                                      <img class="star" src="https://files.catbox.moe/h7xrva.png" />
                                      <img class="star" src="https://files.catbox.moe/lby9vg.png" />
                                      </div>
                                      <div id="lykuang">
                                      <div id="ly"></div>
                                      </div>
                                      <div id="contenttab">
                                      <div id="sta1">
                                      <button class="star" id="star00"></button>
                                      <button class="star" id="star01"></button>
                                      <button class="star" id="star02"></button>
                                      <button class="star" id="star03"></button>
                                      <button class="star" id="star04"></button>
                                      <button class="star" id="star05"></button>
                                      <button class="star" id="star06"></button>
                                      </div>
                                      <div id="sta2">
                                      <button class="star" id="star10"></button>
                                      <button class="star" id="star11"></button>
                                      <button class="star" id="star12"></button>
                                      <button class="star" id="star13"></button>
                                      <button class="star" id="star14"></button>
                                      <button class="star" id="star15"></button>
                                      <button class="star" id="star16"></button>
                                      </div>
                                      <div id="sta3">
                                      <button class="star" id="star20"></button>
                                      <button class="star" id="star21"></button>
                                      <button class="star" id="star22"></button>
                                      <button class="star" id="star23"></button>
                                      <button class="star" id="star24"></button>
                                      <button class="star" id="star25"></button>
                                      <button class="star" id="star26"></button>
                                      </div>
                                      <div id="sta4">
                                      <button class="star" id="star30"></button>
                                      <button class="star" id="star31"></button>
                                      <button class="star" id="star32"></button>
                                      <button class="star" id="star33"></button>
                                      <button class="star" id="star34"></button>
                                      <button class="star" id="star35"></button>
                                      <button class="star" id="star36"></button>
                                      </div>
                                      <div id="sta5">
                                      <button class="star" id="star40"></button>
                                      <button class="star" id="star41"></button>
                                      <button class="star" id="star42"></button>
                                      <button class="star" id="star43"></button>
                                      <button class="star" id="star44"></button>
                                      <button class="star" id="star45"></button>
                                      <button class="star" id="star46"></button>
                                      </div>
                                      </div>
                                      <div id="deadconfig" style="display: none">
                                      <text style="color: black; font-size: 30px">你已经死了,真是不努力。 明明这么easy。
                                      </text>
                                      <button id="aginanniu" style="
                                      background: url('https://files.catbox.moe/5m291h.png') no-repeat;
                                      background-size: cover;
                                      "></button>
                                      </div>
                                      <div id="greatconfig" style="display: none">
                                      <text style="color: gold; font-size: 60px">好耶,过关了! </text>
                                      <button id="aginanniu" style="
                                      background: url('https://files.catbox.moe/5m291h.png') no-repeat;
                                      background-size: cover;
                                      "></button>
                                      </div>
                                      </div>
                                      </body>
                                      </html>
                                        收起(2)
                                      回复

                                      使用道具 举报

                                      收到情书飞天小糖果镜中小鸟香蕉特饮40x43 隐形➀香喷喷的烤鸡月影狼

                                        我知道哦~
                                        把变量i换成其他的就好噜,
                                        因为数组的方括号加上i,会被先识别为bbcode字体标签被转换为html的<i>的了
                                        回复

                                        使用道具 举报

                                        您需要登录后才可以回帖 登录 | 立即注册

                                        本版积分规则

                                        文字版|手机版|小黑屋|GameMale

                                        GMT+8, 2024-11-24 20:38 , Processed in 0.146007 second(s), 133 queries , Redis On.

                                        Copyright © 2013-2024 GameMale

                                        All Rights Reserved.

                                        快速回复 返回列表