Skip to content

Instantly share code, notes, and snippets.

@arselzer
Created March 29, 2014 14:00
Show Gist options
  • Save arselzer/9854946 to your computer and use it in GitHub Desktop.
Save arselzer/9854946 to your computer and use it in GitHub Desktop.
Circle
function printGrid(xpos, ypos) {
var grid = [];
for (var x = 0; x < 40; x++) {
grid[x] = [];
for (var y = 0; y < 100; y++) {
grid[x][y] = ".";
}
}
grid[Math.round(xpos / 2.5)][Math.round(ypos)] = "o";
grid.forEach(function(row) {
console.log(row.join(""));
});
}
function circle(x, y) {
var i = 0;
(function move() {
i += 0.04;
var nx = Math.sin(i) * 40 + x;
var ny = Math.cos(i) * 40 + y;
printGrid(nx, ny);
console.log("x:", nx, "\t", "y:", ny);
setTimeout(move, 24);
})();
}
circle(50, 50);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment