Skip to content

Commit

Permalink
blocklyCrane_lib-1.1: add variant functions
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleBone committed Mar 6, 2024
1 parent 0ced909 commit 6ba6f2f
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions pemFioi/blocklyCrane_lib-1.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,58 @@
var dustUrl = "crane/dust.png";
var spotlightUrl = "crane/spotlight.png";

/* variant functions */

function swapColumns(grid, col1, col2) {
for (var row = 0; row < grid.length; row++) {
tmp = grid[row][col1];
grid[row][col1] = grid[row][col2];
grid[row][col2] = tmp;
}
return grid;
}
function swapRows(grid, row1, row2) {
tmp = grid[row1];
grid[row1] = grid[row2];
grid[row2] = tmp;
return grid;
}
function swapBricks(grid, type1, type2) {
for (var row = 0; row < grid.length; row++) {
for (var col = 0; col < grid[0].length; col++) {
var type = grid[row][col];
if (type == type1) {
type = type2;
} else if (grid[row][col] == type2) {
type = type1;
}
grid[row][col] = type;
}
}
return grid;
}
function revertHorizontal(grid) {
var nbCols = grid[0].length;
for (var row = 0; row < grid.length; row++) {
for (var col = 0; col < nbCols / 2; col++) {
var tmp = grid[row][col];
grid[row][col] = grid[row][nbCols - 1 - col];
grid[row][nbCols - 1 - col] = tmp;
}
}
return grid;
}
function removeRow(grid, row) {
grid.splice(row, 1);
return grid;
}
function removeColumn(grid, column) {
for (var row = 0; row < grid.length; row++) {
grid[row].splice(column, 1);
}
return grid;
}

var getContext = function(display, infos, curLevel) {
var localLanguageStrings = {
fr: {
Expand Down

0 comments on commit 6ba6f2f

Please sign in to comment.