慕雪3673991
2016-09-19 00:55
function moveleft(){
if(!canmoveleft(borde))
return false ;
for(var i=0;i<4;i++)
for(var j=1;j<4;j++){
if(borde[i][j] != 0){
for(var k=0;k<j;k++){
if(borde[i][k]==0 && nobordeHirontal(i,k,j,borde)){
secondAnimation(i,j,i,k);
borde[i][k]=borde[i][j];
borde[i][j]=0;
continue;
}
else if(borde[i][j]==borde[i][k] && nobordeHirontal(i,k,j,borde)){
secondAnimation(i,j,i,k);
borde[i][k]+=borde[i][j];
borde[i][j]=0;
continue;
}
}
}
}
upDateView();
return true;
}
function moveLeft(){
if( !canMoveLeft( board ) )
return false;
//moveLeft
for( var i = 0 ; i < 4 ; i ++ )
for( var j = 1 ; j < 4 ; j ++ ){
if( board[i][j] != 0 ){
for( var k = 0 ; k < j ; k ++ ){
if( board[i][k] == 0 && noBlockHorizontal( i , k , j , board ) ){
//move
showMoveAnimation( i , j , i , k );
board[i][k] = board[i][j];
board[i][j] = 0;
continue;
}
else if( board[i][k] == board[i][j] && noBlockHorizontal( i , k , j , board ) && !hasConflicted[i][k] ){
//move
showMoveAnimation( i , j , i , k );
//add
board[i][k] += board[i][j];
board[i][j] = 0;
//add score
score += board[i][k];
updateScore( score );
hasConflicted[i][k] = true;
continue;
}
}
}
}
setTimeout("updateBoardView()",200);
return true;
}
慕课网2048私人订制
70013 学习 · 588 问题
相似问题