jquery实现30个关卡闯关跳跃类游戏代码
代码语言:html
所属分类:游戏
代码描述:jquery实现30个关卡闯关跳跃类游戏代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <style type="text/css"> * { margin:0; padding:0; } #canvas { display:block; margin:10px auto; border:1px solid #bbb; outline:none; } .box { position:relative; } </style> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/jquery.17.js"></script> </head> <body> <div class="box"> <canvas id="canvas" tabindex="0"></canvas> </div> <script type="text/javascript"> $(document).ready(function(e) { var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); var c = $("#canvas"); var cur = c.css('cursor'); var w = 600, h = 600, dx = 0, dy = 0, x = 0, y = 0; var x2 = x; var y2 = y; var w2 = w/2; var h2 = h/2; var mf = [w2,h2]; var fadewh = 0; var le = 1; var lea = 30; var tle = le; var lv = ''; var mr = 20; var mr2 = mr/2; var start = true, fade = false, level1 = false, lev = false, mov = false, choose = false, pause = false; var kaishisize = '20px'; var tm = 1; var ya = []; var chu = []; var bu = []; var yd = []; var bd = []; var yc = []; var ly = []; var yq = []; var zb = []; var bc = []; var lt = []; var th = []; var cs = []; var cd = []; var ty = []; var hb = []; var zz = []; var v = 0; var a = .2; var mxl = 0, mxr = 0; var xv = 2; var sv = -7; var sx = 0; var sy = 0; var sx2 = 0; var sy2 = 0; var xa = 0; var xaj = .2; var bingf = 1; var pi2 = Math.PI/2; var jian = false; var kong = false; var isStart = true; var ov = false; var nanc = false; var fa = 10; var yi = true; var dkong = false; var choosestyle = '#fff'; var menustyle = '#999'; var restyle = '#999'; var tingstyle = '#999'; var backstyle = '#fff'; var cox = 100, coy = 100, cow = 60, coh = 30, coxk = 85, coyk = 40; var coy2 = coy; var cox2 = cox; var cohang = 0; var choo = []; canvas.width = w; canvas.height = h; ctx.fillStyle = '#000'; ctx.fillRect(0,0,w,h); function begin(){ ctx.fillStyle = '#fff'; ctx.fillRect(0,0,w,h); if(start)toStart(); if(choose)toChoose(); if(level1)toLevel1(); if(lev)toLev(); if(mov)move(); if(ov)over(); if(fade)toFade(); if(pause)toPause(); if(isStart)window.requestAnimationFrame(begin); } c.mousemove(function(e){ dx = e.pageX - c.offset().left - parseInt(c.css('border-left-width')); dy = e.pageY - c.offset().top - parseInt(c.css('border-top-width')); mm(); }); function mm(){ if(start){ if(dx >= 250 && dx <= 350 && dy >= 288 && dy <= 318){ kaishisize = '22px'; c.css('cursor','pointer'); }else if(dx >= 270 && dx <= 330 && dy >= 362 && dy <= 386){ c.css('cursor','pointer'); choosestyle = '#000'; } else{ kaishisize = '20px'; choosestyle = '#fff'; c.css('cursor',cur); } } if(choose && choo.length){ if(dx >= 270 && dx <= 330 && dy >= 482 && dy <= 506){ backstyle = '#000'; c.css('cursor','pointer'); }else{ backstyle = "#fff"; for(var i=0;i<lea;i++){ if(dx >= choo[i].x && dx <= choo[i].x+cow && dy >= choo[i].y && dy <= choo[i].y+coh){ choo[i].c = "#000"; c.css('cursor','pointer'); break; }else{ choo[i].c = "#fff"; c.css('cursor',cur); } } } } if(level1){ if(dx >= 560 && dx <= 590 && dy >= 10 && dy <= 35){ menustyle = '#bbb'; c.css('cursor','pointer'); }else if(dx >= 520 && dx <= 540 && dy >= 12 && dy <= 32){ restyle = '#bbb'; c.css('cursor','pointer'); }else if(dx >= 478 && dx <= 502 && dy >= 9 && dy <= 37){ tingstyle = '#bbb'; c.css('cursor','pointer'); }else{ menustyle = '#999'; restyle = '#999'; tingstyle = '#999'; c.css('cursor',cur); } } if(pause){ if(Math.sqrt(Math.pow(dx-300,2)+Math.pow(dy-300,2)) <= 100){ c.css('cursor','pointer'); }else{ c.css('cursor',cur); } } } c.click(function(){ if(start){ if(dx >= 250 && dx <= 350 && dy >= 288 && dy <= 318){ start = false; kaishisize = '20px'; c.css('cursor',cur); fade = true; }else if(dx >= 270 && dx <= 330 && dy >= 362 && dy <= 386){ start = false; kaishisize = '20px'; choosestyle = '#fff'; c.css('cursor',cur); choose = true; } } if(choose && choo.length){ for(var i=0;i<lea;i++){ if(dx >= choo[i].x && dx <= choo[i].x+cow && dy >= choo[i].y && dy <= choo[i].y+coh){ le = i+1; c.css('cursor',cur); fade = true; choose = false; break; } } if(dx >= 270 && dx <= 330 && dy >= 482 && dy <= 506){ choose = false; start = true; } } if(level1){ if(dx >= 560 && dx <= 590 && dy >= 10 && dy <= 35){ start = true; mov = false; level1 = false; lev = false; le = 1; tle = 1; }else if(dx >= 520 && dx <= 540 && dy >= 12 && dy <= 32){ xuan(); }else if(dx >= 478 && dx <= 502 && dy >= 9 && dy <= 37){ isStart = false; pause = true; } } if(pause){ if(Math.sqrt(Math.pow(dx-300,2)+Math.pow(dy-300,2)) <= 100){ isStart = true; pause = false; level1 = true; mov = true; begin(); } } }); function toPause(){ level1 = false; mov = false; ctx.fillStyle = 'rgba(0,0,0,.5)'; ctx.fillRect(0,0,w,h); ctx.beginPath(); ctx.fillStyle = '#000'; ctx.arc(300,300,100,0,4*pi2); ctx.closePath(); ctx.fill(); ctx.beginPath(); ctx.fillStyle = '#fff'; ctx.arc(300,300,96,0,4*pi2); ctx.closePath(); ctx.fill(); ctx.beginPath(); ctx.fillStyle = '#000'; ctx.moveTo(370,300); ctx.lineTo(250,230); ctx.lineTo(250,370); ctx.closePath(); ctx.fill(); } function toChoose(){ ctx.fillStyle = '#999'; ctx.fillRect(0,0,w,h); for(var i=0;i<lea;i++){ if(!choo[i]){ choo[i] = {}; } choo[i].x = cox+(cohang*coxk); choo[i].y = coy; ctx.beginPath(); ctx.strokeStyle = choo[i].c ||'#fff'; ctx.strokeRect(cox+(cohang*coxk),coy,cow,coh); ctx.closePath(); ctx.fillStyle = choo[i].c ||'#fff'; ctx.font = '16px 微软雅黑'; ctx.fillText(i+1, cox+(cohang*coxk)+cow/2,coy+coh*2/3); cohang++; if((i+1)%5 == 0 && i != 1){ coy+=coyk cox = cox2; cohang = 0; } } ctx.fillStyle = backstyle; ctx.font = '16px 微软雅黑'; ctx.fillText('返回',300,500); ctx.beginPath(); ctx.strokeStyle = backstyle; ctx.strokeRect(270,482,60,24); ctx.closePath(); coy = coy2; cox = cox2; cohang = 0; } function toStart(){ ctx.fillStyle = '#999'; ctx.fillRect(0,0,w,h); ctx.font = kaishisize+' 微软雅黑'; ctx.fillStyle = '#fff'; ctx.textAlign = 'center'; ctx.fillText("开始游戏", 300, 310); ctx.fillStyle = choosestyle; ctx.font = '16px 微软雅黑'; ctx.fillText("选关", 300, 380); ctx.beginPath(); ctx.strokeStyle = '#fff'; ctx.strokeRect(250,288,100,30); ctx.closePath(); ctx.beginPath(); ctx.strokeStyle = choosestyle; ctx.strokeRect(270,362,60,24); ctx.closePath(); } function toFade(){ ctx.fillStyle = '#fff'; ctx.fillRect(0,0,w,h); if(tle != 1){ if(yi){ fadewh = Math.max.apply(null, mf) - fa; fa*=-1; yi = false; } if(fadewh <= 0)fa*=-1; fadewh += fa; }else{ fadewh += fa; } ctx.fillStyle = '#999'; ctx.fillRect(0-fadewh,0-fadewh,w2,h2); ctx.fillRect(w2+fadewh,0-fadewh,w2,h2); ctx.fillRect(0-fadewh,h2+fadewh,w2,h2); ctx.fillRect(w2+fadewh,h2+fadewh,w2,h2); if(fadewh >= w2 && fadewh >= h2){ yi = true; fadewh = 0; xuan(); } } function xuan(){ fade = false; lev = true; level1 = true; mov = true; ya = []; chu = []; bu = []; bd = []; yd = []; // 移动 bc = []; yc = []; // 隐藏 ly = []; // 全屏 yq = []; // 圆圈 zb = []; // 钟摆 lt = []; // 落体 th = []; // 弹簧 cs = []; // 传送 cd = []; // 传送带 ty = []; // 跳跃 hb = []; // 滑冰 zz = []; // 沼泽 tm = 1; v = 0; lv = le; if(le == 0){ /*ya[1] = [200,400,200,10]; bu.push([450,400,50,10]); yd.push([101,300,200,10,'x',100,300,4,1,0,.2]); // [7].最大速度 [8] 方向 [9] 随意 [10]最小速度 [10]>=[7]时匀速 bd.push([101,250,50,30,'x',100,450,3,1,0,2]); yc.push([200,400,200,10,.05,5,1,false]); // [4]隐藏速度 [5]隐藏后多久出来 后面固定值 ly.push([40,40,40,40,4,3]); // [4]x+ [5]y+ yq.push([300,300,100,40,40,1,pi2,0.03]); // 中心 半径 方块宽高 正反 初始位置 速度 zb.push([500,300,100,20,20,-1,pi2+0.8,pi2+1,0.05,0.001]); // 中心 半径 方块宽高 正反 初始位置 最高位置 速度 最小速度 bc.push([200,400,200,10,.01,1,1]); // [6]/[4]显示的时间 [5]/[4]隐藏的时间 lt.push([0,-40,40,40,680,0.1,0.5,0,true]); // [4] 落体y距离 [5]加速度 [6]停留时间 [7]初始速度 th.push([0,450,50,50,12,true]); // [4]速度 cs.push([0,480,mr,mr,300,480,mr,mr,true]); cd.push([200,400,200,10,1,true]); ty.push([200,460,40,40,2,5,1,100,500,true]); // [4] x速度 [5] y速度 [6]方向 [x边距] hb.push([0,500,150,100,2]); zz.push([250,400,100,10]); */ }else if(le == 1){ ya.push([0,500,200,100]); ya.push([200,400,200,200]); ya.push([400,300,200,300]); chu = [560,280,mr,mr]; x = 20; y = 400; }else if(le == 2){ ya.push([0,500,250,100]); ya.push([350,500,250,100]); chu = [500,480,mr,mr]; x = 100; y = 400; }else if(le == 3){ ya.push([0,500,w,100]); bu.push([290,100,20,400]); th.push([240,460,40,40,12.5,true]); chu = [560,480,mr,mr]; x = 20; y = 400; }else if(le == 4){ hb.push([0,500,150,100,2]); hb.push([290,500,20,100,2]); hb.push([450,500,600,100,2]); chu = [560,480,mr,mr]; x = 20; y = 400; }else if(le == 5){ ya.push([0,500,200,100]); ya.push([500,300,100,10]); yc.push([200,400,40,10,.05,5,1,false]); yc.push([300,400,40,10,.05,5,1,false]); yc.push([400,400,40,10,.05,5,1,false]); chu = [560,280,mr,mr]; x = 20; y = 400; }else if(le == 6){ ya.push([0,500,100,100]); zz.push([200,500,500,100]); bu.push([300,460,40,40]); bu.push([440,460,40,40]); chu = [560,480,mr,mr]; x = 20; y = 400; }else if(le == 7){ ya.push([0,500,100,100]); ya.push([500,400,100,10]); cd.push([200,500,100,10,1.5,true]); cd.push([360,500,100,10,-1.5,true]); chu = [560,380,mr,mr]; x = 20; y = 400; }else if(le == 8){ ya.push([0,500,w,100]); bu.push([200,420,40,80]); bu.push([400,420,40,80]); chu = [500,480,mr,mr]; x = 100; y = 400; }else if(le == 9){ ya.push([0,500,w,100]); ty.push([200,460,40,40,2,5,1,100,500,true]); chu = [560,480,mr,mr]; x = 20; y = 400; }else if(le == 10){ ya.push([0,500,100,100]); ya.push([500,500,100,100]); hb.push([200,500,150,10,4]); bu.push([350,440,30,70]); cd.push([380,500,100,10,-1.5,true]); chu = [560,480,mr,mr]; x = 20; y = 400; }else if(le == 11){ ya.push([100,0,300,h]); ya.push([0,500,100,10]); ya.push([400,500,200,10]); ya.push([400,400,200,10]); cs.push([80,480,mr,mr,400,480,mr,mr,true]); cs.push([580,480,mr,mr,400,380,mr,mr,true]); zb.push([500,405,80,20,20,-1,pi2+0.8,pi2+1,0.06,0.002]); chu = [560,380,mr,mr]; x = 20; y = 400; }else if(le == 12){ ya.push([0,500,100,100]); ya.push([500,500,100,100]); th.push([60,460,40,40,12,true]); hb.push([100,100,400,10,5]); bu.push([100,0,400,10]); ty.push([240,60,40,40,2,4,1,240,358,true]); chu = [560,480,mr,mr]; x = 20; y = 400; }else if(le == 13){ ya.push([0,500,100,100]); ya.push([500,500,100,100]); yd.push([201,400,50,10,'x',100,250,4,-1,0,1]); cd.push([380,400,100,10,-1.8,true]); chu = [560,480,mr,mr]; x = 20; y = 400; }else if(le == 14){ ya.push([0,550,50,50]); ya.push([50,500,150,100]); ya.push([250,500,400,200]); ya.push([200,550,50,50]); bd.push([0,260,400,200,'y',200,300,3,-1,0,1]); bd.push([450,260,150,200,'y',200,300,3,-1,0,1]); bd.push([400,260,50,150,'y',200,300,3,-1,0,1]); chu = [560,480,mr,mr]; x = 20; y = 520; }else if(le == 15){ ya.push([0,500,100,100]); hb.push([100,500,100,100,7]); ya.push([200,500,100,100]); lt.push([145,-10,10,10,620,0,0,15,true]); cd.push([300,500,200,10,4,true]); ya.push([500,500,100,10]); bu.push([480,460,40,40]); chu = [560,480,mr,mr]; x = 20; y = 400; }else if(le == 16){ ya.push([0,500,170,100]); ya.push([300,500,200,100]); ya.push([500,100,100,10]); th.push([460,460,40,40,12,true]); bd.push([450,250,20,20,'x',400,500,3,1,0,2]); chu = [560,80,mr,mr]; x = 20; y = 400; }else if(le == 17){ ya.push([0,500,150,10]); ya.push([280,500,100,10]); ya.push([510,500,90,10]); ya.push([0,200,100,10]); cd.push([230,200,100,10,1,true]); ya.push([460,200,140,10]); zb.push([270,205,240,80,80,-1,pi2+0.8,pi2+1,0.05,0.001]); cs.push([580,480,mr,mr,0,180,mr,mr,true]); chu = [560,180,mr,mr]; x = 40; y = 400; }else if(le == 18){ ya.push([0,500,100,100]); ya.push([500,500,100,100]); yd.push([201,400,50,10,'x',100,260,3,-1,0,1.5]); yd.push([301,400,50,10,'x',300,450,4,1,0,3]); chu = [560,480,mr,mr]; x = 20; y = 400; }else if(le == 19){ ya.push([0,500,100,100]); ya.push([500,100,100,10]); yd.push([201,400,50,10,'x',100,260,3,-1,0,1.5]); yd.push([400,400,50,10,'y',200,450,4,1,0,3]); chu = [560,80,mr,mr]; x = 20; y = 400; }else if(le == 20){ ya.push([0,500,100,100]); ya.push([200,500,50,100]); ya.push([350,500,50,100]); ya.push([0,200,400,20]); bu.push([120,180,60,20]); bu.push([360,140,20,60]); yd.push([500,400,50,10,'y',200,550,4,1,0,3]); bd.push([140,450,20,20,'y',350,500,3,1,0,2]); bd.push([290,450,20,20,'y',350,500,4,1,0,1]); chu = [80,180,mr,mr]; x = 20; y = 400; }else if(le == 21){ ya.push([0,500,w,100]); ya.push([0,300,500,10]); ya.push([550,400,50,10]); bd.push([200,480,20,20,'x',100,300,3,1,0,3]); bd.push([200,400,40,60,'x',100,300,4,1,0,4]); bd.push([400,480,20,20,'x',340,500,8,1,0,3]); bd.push([515,400,20,20,'y',240,440,5,1,0,3]); bd.push([200,260,40,40,'x',100,460,12,1,0,1]); chu = [20,280,mr,mr]; x = 20; y = 400; }else if(le == 22){ ya.push([0,500,20,20]); ya.push([100,400,20,20]); ya.push([200,284,20,20]); ya.push([300,166,20,20]); ya.push([400,400,200,20]); bu.push([79,405,20,20]); bu.push([179,289,20,20]); bu.push([233,275,20,20]); bu.push([455,380,20,20]); bu.push([505,380,20,20]); chu = [480,380,mr,mr]; x = 0; y = 400; }else if(le == 23){ ya.push([0,300,100,10]); ya.push([200,300,50,10]); ya.push([350,300,50,10]); ya.push([500,300,100,10]); bu.push([60,280,30,20]); bu.push([210,280,30,20]); bu.push([360,280,30,20]); bu.push([525,280,20,20]); bu.push([575,280,20,20]); chu = [550,280,mr,mr]; x = 20; y = 200; }else if(le == 24){ ya.push([450,580,40,20]); ya.push([100,350,50,10]); ya.push([250,250,50,10]); ya.push([400,400,50,10]); yc.push([320,430,60,10,.05,5,1,false]); yd.push([20,401,60,10,'y',200,450,5,-1,0,3]); yd.push([170,401,60,10,'y',100,450,6,-1,0,6]); yd.push([500,501,50,10,'y',450,550,2,-1,0,.5]); bu.push([100,0,50,300]); bu.push([100,360,50,240]); bu.push([250,0,50,200]); bu.push([250,260,50,340]); bu.push([400,0,50,350]); bu.push([400,410,50,200]); bu.push( [550,410,50,200]); bu.push([450,410,50,50]); chu = [460,560,mr,mr]; x = 40; y = 160; }else if(le == 25){ ya.push([0,580,w,20]); ya.push([400,50,200,50]); bu.push([0,420,400,50]); bu.push([450,420,150,50]); bu.push([0,250,50,50]); bu.push([100,250,500,50]); bu.push([0,50,350,50]); yc.push([120,240,50,10,.05,5,1,false]); yc.push([180,160,50,10,.05,5,1,false]); yc.push([270,220,50,10,.05,5,1,false]); yd.push([400,500,50,10,'y',420,520,3,1,0,0.5]); yd.push([300,380,50,10,'x',120,340,3,1,0,2]); yd.push([50,300,50,10,'y',250,380,2,1,0,0.5]); yd.push([350,120,50,10,'y',100,200,2,1,0,0.5]); yq.push([475,75,50,20,20,-1,pi2,0.03]); chu = [560,30,mr,mr]; x = 100; y = 540; }else if(le == 26){ ya.push([0,500,100,100]); ya.push([0,100,500,10]); ya.push([550,200,50,10]); yc.push([150,400,50,10,.05,5,1,false]); yc.push([270,330,50,10,.05,5,1,false]); yc.push([400,260,50,10,.05,5,1,false]); yq.push([175,405,40,20,20,1,pi2,0.03]); yq.push([425,265,40,20,20,-1,pi2,0.05]); zb.push([200,0,80,40,40,-1,pi2+0.8,pi2+1,0.05,0.001]); lt.push([270,-50,50,50,700,0.1,0.5,0,true]); chu = [20,80,mr,mr]; x = 20; y = 400; }else if(le == 27){ ya.push([0,500,100,100]); ya.push([150,480,50,10]); ya.push([250,460,50,10]); ya.push([350,440,50,10]); ya.push([450,420,50,10]); ya.push([550,400,50,10]); ya.push([550,300,50,10]); ya.push([550,200,50,10]); ya.push([450,180,50,10]); ya.push([350,160,50,10]); ya.push([250,140,50,10]); ya.push([150,120,50,10]); ya.push([0,100,100,10]); lt.push([115,-20,20,20,620,0.2,0.5,1,true]); lt.push([215,-20,20,20,620,0.5,1,1,true]); lt.push([315,-20,20,20,620,1,0,0,true]); lt.push([415,-20,20,20,620,0.1,1,3,true]); lt.push([500,-20,20,20,620,0.2,0.2,3,true]); lt.push([530,-20,20,20,620,0.1,0,5,true]); chu = [20,80,mr,mr]; x = 20; y = 400; }else if(le == 28){ ya.push([250,580,100,20]); ya.push([250,50,100,10]); yd.push([101,500,50,10,'x',100,450,2,1,0,2]); yd.push([300,400,40,10,'x',100,460,2.5,1,0,2.5]); yd.push([400,300,30,10,'x',100,470,3,-1,0,3]); yd.push([400,200,20,10,'x',100,480,4,1,0,4]); yc.push([200,100,20,10,.05,5,1,false]); yc.push([380,100,20,10,.05,5,1,false]); bu.push([200,480,20,20]); bu.push([380,480,20,20]); bu.push([280,380,20,20]); bu.push([180,280,20,20]); bu.push([420,280,20,20]); bu.push([100,140,60,60]); bu.push([440,140,60,60]); bd.push([225,60,20,20,'y',0,100,3,1,0,0.1]); bd.push([355,80,20,20,'y',0,100,2.5,-1,0,0.5]); chu = [290,30,mr,mr]; x = 290; y = 540; }else if(le == 29){ ya.push([400,500,200,100]); ya.push([380,400,160,10]); ya.push([360,300,180,10]); ya.push([340,200,200,10]); ya.push([100,100,440,10]); ya.push([280,200,10,400]); ya.push([530,100,10,400]); ya.push([100,100,10,410]); ya.push([150,200,130,10]); ya.push([150,300,130,10]); ya.push([150,400,130,10]); ya.push([150,500,130,10]); ya.push([110,450,130,10]); ya.push([110,350,130,10]); ya.push([110,250,130,10]); bc.push([540,400,60,60,.01,1,1]); yc.push([0,150,50,10,.05,5,1,false]); yc.push([0,250,50,10,.05,5,1,false]); yc.push([0,350,50,10,.05,5,1,false]); yc.push([0,450,50,10,.05,5,1,false]); yc.push([50,500,50,10,.05,5,1,false]); yc.push([50,400,50,10,.05,5,1,false]); yc.push([50,300,50,10,.05,5,1,false]); yc.push([50,200,50,10,.05,5,1,false]); yd.push([101,550,50,10,'x',0,200,3,1,0,2]); lt.push([170,-40,40,40,640,0.1,0.5,0,true]); zb.push([200,100,88,20,20,-1,pi2+0.8,pi2+1,0.05,0.003]); zb.push([400,0,78,40,40,1,pi2-0.8,pi2+1,0.1,0.002]); yq.push([225,455,40,10,10,1,pi2,0.05]); chu = [560,480,mr,mr]; x = 440; y = 440; }else if(le == 30){ ya.push([0,590,w,10]); ya.push([0,490,500,10]); ya.push([100,390,500,10]); ya.push([0,290,500,10]); ya.push([100,190,500,10]); ya.push([0,90,500,10]); yq.push([495,495,50,10,10,1,pi2,0.03]); yq.push([105,395,50,10,10,-1,pi2,0.05]); yq.push([495,295,50,10,10,1,pi2,0.07]); yq.push([105,195,50,10,10,-1,pi2,0.09]); yq.push([495,95,50,10,10,1,pi2,0.11]); bd.push([150,450,40,90,'y',400,500,4,1,0,.2]); bd.push([350,306,40,90,'y',300,400,5,1,0,.2]); bd.push([300,286,40,90,'y',200,300,2,1,0,1.5]); bd.push([200,86,40,90,'y',0,200,8,1,0,1.5]); bd.push([400,1,40,90,'y',0,100,2,1,0,1.5]); zb.push([300,0,68,40,40,-1,pi2+0.8,pi2+1,0.08,0.002]); ly.push([40,40,40,40,3,3]); chu = [20,70,mr,mr]; x = 20; y = 560; }else{ ov = true; } x2 = x; y2 = y; } function toLevel1(){ ctx.fillStyle = '#999'; for(var i=0;i<ya.length;i++){ ctx.fillRect(ya[i][0],ya[i][1],ya[i][2],ya[i][3]); } ctx.fillStyle = '#B9CDF6'; for(var i=0;i<hb.length;i++){ ctx.fillRect(hb[i][0],hb[i][1],hb[i][2],hb[i][3]); } ctx.fillStyle = '#222'; for(var i=0;i<zz.length;i++){ ctx.fillRect(zz[i][0],zz[i][1],zz[i][2],zz[i][3]); } ctx.fillStyle = '#999'; for(var i=0;i<yc.length;i++){ if(yc[i][7]){ yc[i][6]-=yc[i][4]; } if(yc[i][6] < -yc[i][5]){ yc[i][6] = 1; yc[i][7] = false; } if(yc[i][6] >= 0 ){ ctx.fillStyle = 'rgba(205,198,115,'+yc[i][6]+')'; ctx.fillRect(yc[i][0],yc[i][1],yc[i][2],yc[i][3]); } } for(var i=0;i<cd.length;i++){ ctx.fillStyle = '#cdb5cd'; ctx.fillRect(cd[i][0],cd[i][1],cd[i][2],cd[i][3]); ctx.fillStyle = '#ad85ad'; if(cd[i][4]>=0){ if(cd[i][5]){ cd[i][5]=false; cd[i][6]=cd[i][0]; cd[i][7]=cd[i][0]+(cd[i][2]/2); cd[i][8]=cd[i][2]/4; } cd[i.........完整代码请登录后点击上方下载按钮下载查看
网友评论0