HTML and CSS Reference
In-Depth Information
iif ( tankX == nextNode . x * 32 && tankY == nextNode . y * 32 ) {
//node change
currentNodeIndex ++ ;
iif ( currentNodeIndex == result . length ) {
finishedPath = true
true ;
}
currentNode = nextNode ;
nextNode = result [ currentNodeIndex ]
tankMoving = false
false ;
}
iif ( ! finishedPath ) {
iif ( nextNode . x > currentNode . x ) {
colDelta = 1 ;
} else
else iif ( nextNode . x < currentNode . x ) {
colDelta =- 1
} else
else {
colDelta = 0
}
iif ( nextNode . y > currentNode . y ) {
rowDelta = 1 ;
} else
else iif ( nextNode . y < currentNode . y ) {
rowDelta =- 1
} else
else {
rowDelta = 0
}
angleInRadians = Math . atan2 ( colDelta , rowDelta );
tankMoving = true
true ;
}
tankX += colDelta ;
tankY += rowDelta ;
}
var
var tankSourceX = Math . floor ( 3 % 5 ) * 32 ;
var
var tankSourceY = Math . floor ( 3 / 5 ) * 32 ;
context . save (); //save current state in stack
context . setTransform ( 1 , 0 , 0 , 1 , 0 , 0 ); // reset to identity
context . translate (( tankY ) + 16 ,( tankX ) + 16 );
context . rotate ( angleInRadians );
context . drawImage ( tileSheet , tankSourceX , tankSourceY , 32 , 32 , - 16 , - 16 , 32 , 32 );
context . restore ();
}
}
Search WWH ::




Custom Search