Created
March 13, 2017 17:39
-
-
Save wismer/a063ea8df7b92e2a81e2ccc402bdb967 to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=a063ea8df7b92e2a81e2ccc402bdb967
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Tiny Turtle</title> | |
<script src="https://toolness.github.io/tiny-turtle/tiny-turtle.js"></script> | |
</head> | |
<body> | |
<h1>Tiny Turtle</h1> | |
<canvas></canvas> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tiny Turtle Setup. Avoid modifying these lines of code! | |
var adjCanvasSize = document.getElementsByTagName('canvas')[0]; | |
adjCanvasSize.width = 400; | |
adjCanvasSize.height = 400; | |
TinyTurtle.apply(window); | |
// Start writing code here | |
function square(){ | |
forward(50); | |
right(90); | |
forward(50); | |
right(90); | |
forward(50); | |
right(90); | |
forward(50); | |
right(90); | |
forward(50); | |
} | |
// Type your function call below | |
function _square() { | |
var instructions = [50, 90, 50, 90, 50, 90, 50, 90, 50]; | |
instructions.forEach(function(instruction, index) { | |
function animate() { | |
if (instruction === 50) { | |
forward(instruction); | |
} else { | |
right(instruction); | |
} | |
stamp(); | |
} | |
setTimeout(animate, index * 1000); | |
}); | |
} | |
_square(); | |
stamp(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
canvas { | |
border: 1px solid black; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment