// This was coded a very long time ago and I put it here for posterity
// Please don't judge me too harshly
// I was young and naive
$(function() {
let x = 100;
let y = 100;
function table_generator() {
for (let i = 0; i < x; i++) {
$('#table').append('
');
for (let j = 0; j < y; j++) {
$('#table tr[class="' + i + '"]').append(' | ');
}
}
}
table_generator();
let case_index = [Math.floor(x/2), Math.floor(y/2)];
let case_table = $('#table tr[class="' + case_index[0] + '"] td[class="' + case_index[1] + '"]');
case_table.css('background-color', 'black');
let direction = 0;
function case_change() {
// up = 0
// left = 1
// bot = 2
// right = 3
switch (direction) {
case 0:
case_index[0] = case_index[0] - 1;
break;
case 1:
case_index[1] = case_index[1] - 1;
break;
case 2:
case_index[0] = case_index[0] + 1;
break;
case 3:
case_index[1] = case_index[1] + 1;
break;
}
}
function update() {
if (case_table.css('background-color') == 'rgb(0, 0, 0)') {
if (direction == 3) {
direction = 0;
} else {
direction = direction + 1;
}
case_table.css('background-color', 'white');
case_change();
case_table = $('#table tr[class="' + case_index[0] + '"] td[class="' + case_index[1] + '"]');
} else {
if (direction == 0) {
direction = 3;
} else {
direction = direction - 1;
}
case_table.css('background-color', 'black');
case_change();
case_table = $('#table tr[class="' + case_index[0] + '"] td[class="' + case_index[1] + '"]');
}
}
setInterval(update, 10);
});