Skip to content

Instantly share code, notes, and snippets.

@jhubert
Created September 20, 2013 03:00
Show Gist options
  • Save jhubert/6632790 to your computer and use it in GitHub Desktop.
Save jhubert/6632790 to your computer and use it in GitHub Desktop.
if (!state.initialized) {
state.cur = 0;
state.dir = 1;
state.initialized = true;
state.last_update = false;
state.val = 1;
state.chaser = false;
}
//1:1,2:1,3:1,4:1,4:2,4:3,4:4,4:3,4:2,4:1,3:1,2:1,2:2,2:3,3:3,3:2
//0,1,2,3,7,11,15,14,13,12,8,4,5,6,10,9
// This was going to build the pattern array, but the
// server stopped responding.. so..
function createPatternArray(row_count, col_count) {
var row_wall = 0,
col_wall = 0,
cur = 0,
dots = row_count * col_count;
}
var now = (time / 100) | 0,
pattern = [0, 1, 2, 3, 7, 11, 15, 14, 13, 12, 8, 4, 5, 6, 10, 9];
if (state.last_update == now) {
return;
}
// You can uncomment this to have the lights stay lit
for (var i=0; i < rows*columns; i++) {
grid[i] = 0;
}
// If you want a chaser, you can uncomment this to
// place a dot behind the lead dot.
//
// if (state.cur > 3) {
// state.chaser = state.cur - 3;
// }
//
// if (state.chaser) {
// grid[pattern[state.chaser]] = state.val;
// }
grid[pattern[state.cur]] = state.val;
state.cur = state.cur + state.dir;
if (pattern.length < (state.cur + state.dir)) {
state.dir = -1;
state.val = 1;
} else if (state.cur < 0) {
state.dir = 1;
state.val = 1;
state.cur = 0;
}
state.last_update = now;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment