Created
March 21, 2017 03:29
-
-
Save alexpelan/0d664c2e423f5291f1432a598159f1ca to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=0d664c2e423f5291f1432a598159f1ca
This file contains hidden or 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> | |
| Enter a direction: <input class="direction"> <button class="move">Move!</button><p></p> | |
| <p></p><canvas></canvas> | |
| <p class="message"></p> | |
| </body> | |
| </html> |
This file contains hidden or 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
| {"enabledLibraries":["jquery"]} |
This file contains hidden or 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); | |
| $(".move").click(function() { | |
| var direction = $(".direction").val(); | |
| if (direction === "forward" || direction === "left" || direction === "right") { | |
| $(".message").html("Moved the turtle " + direction); | |
| } else { | |
| $(".message").html("Sorry, we didn't understand that!"); | |
| } | |
| if (direction === "forward") { | |
| forward(90); | |
| } | |
| if (direction === "right") { | |
| right(90); | |
| forward(90); | |
| } | |
| if (direction === "left") { | |
| left(90); | |
| forward(90); | |
| } | |
| }); |
This file contains hidden or 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