2024年2月3日发(作者:)
(, 0);(0, );(, );(0, 0);(0, );(, 0);(, );ath();Style="#b4a79d";dth=4;();//设置绘制block时的yle="#201a14";}draw canvasfunction changeWidthAndHeight(w, h){//通过jquery设置cssh+=$("ui_bg").css("height")+$("ui_bg").css("margin-rop")+$("ui_bg").css("margin-bottom")+$("ui_bg").css("padding-top")+$("ui_bg").css("padding-bottom");$(".bg").css({"width":w,"height":h,"top":0, "bottom":0, "right":0, "left":0,"margin":"auto"});}change width and height//draw blocksfunction drawBlocks(){//清空地图for(let i=0; ifor(let j=0;ect(j*CELL_SIZE+1, i*CELL_SIZE+1, CELL_SIZE-2, CELL_SIZE-2);}
if(afterRotateX < 0 || tetris_status[afterRotateY - 1][afterRotateX] != NO_BLOCK){moveRight();afterRotateX = currentFall[2].x + preY - currentFall[2].y;afterRotateY = currentFall[2].y + currentFall[2].x - preX;break;}if(afterRotateX < 0 || tetris_status[afterRotateY-1][afterRotateX] != NO_BLOCK){moveRight();break;}// 如果旋转后的坐标已经超出了最右边边界if(afterRotateX >= TETRIS_COLS - 1 ||tetris_status[afterRotateY][afterRotateX+1] != NO_BLOCK){moveLeft();afterRotateX = currentFall[2].x + preY - currentFall[2].y;afterRotateY = currentFall[2].y + currentFall[2].x - preX;break;}if(afterRotateX >= TETRIS_COLS - 1 ||tetris_status[afterRotateY][afterRotateX+1] != NO_BLOCK){moveLeft();break;}}}if(canRotate){for (var i = 0 ; i < ; i++){var preX = currentFall[i].x;var preY = currentFall[i].y;if(i != 2){
return;}for(let i=0;icurrentFall[i].x++;m("currentFall", ify(currentFall));return;}//左移function moveLeft(){for(let i=0;iif(currentFall[i].x-1<0 || tetris_status[currentFall[i].y][currentFall[i].x-1]!=NO_BLOCK)return;}for(let i=0;icurrentFall[i].x--;m("currentFall", ify(currentFall));return;}//judge can move down and if arrive at end return 1, if touch other blocks return 2, else, return 0function moveDown(){for(let i=0;iif(currentFall[i].y>=TETRIS_ROWS-1 || tetris_status[currentFall[i].y+1][currentFall[i].x]!=NO_BLOCK)return true;}for(let i=0;icurrentFall[i].y+=1;return false;}上下左右移动function gameKeyEvent(evt){switch(e){//向下case 40://↓case 83://S
本文发布于:2024-02-03 13:50:54,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170693945450546.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |