HTML and CSS Reference
In-Depth Information
break;
case 38: // Up
case 87: // W
// Make sure that we can't scroll past our minimum value (0)
if (scrollY > 0) {
scrollY -= 10;
}
break;
case 40: // Down
case 83: // S
// Make sure that we can't scroll past our maximum value
// (Height of the Cell * Number of Rows)
if (scrollX < (cellHeight * gridRows)) {
scrollY += 10;
}
break;
}
// Set those cells as "modified", therefore we need to redraw them
var i = (scrollY / cellHeight) >> 0,
j = (scrollX / cellWidth) >> 0,
lastRow = ((canvas.height + scrollY) / cellHeight) >> 0, // Grab the last row
lastCol = ((canvas.width + scrollX) / cellWidth) >> 0; // Grab the last column
for ( ; i < lastRow ; ++i ) {
for ( j = ((scrollX / cellWidth) >> 0) ; j < lastCol ; ++j ) {
// Handle the initialisation of new cells, in case they are not created
if (Grid[i] === undefined) {
// Has the row been declared?
Grid[i] = [];
}
Grid[i][j] = 1;
}
}
shouldRepaint = true;
}, false);
Search WWH ::




Custom Search