Skip to content

Instantly share code, notes, and snippets.

@alexpelan
Created February 7, 2017 01:33
Show Gist options
  • Select an option

  • Save alexpelan/e5287fb1e8f7fe9040543631acc4ca7a to your computer and use it in GitHub Desktop.

Select an option

Save alexpelan/e5287fb1e8f7fe9040543631acc4ca7a to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=e5287fb1e8f7fe9040543631acc4ca7a
<!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>
<button class="change-color">Change color</button>
</body>
</html>
{"enabledLibraries":["jquery"]}
// 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 here
// 1. This value for a right angle is wrong - fix it so the
// variable 'rightAngle' is equal to the number of degrees
// in a right angle.
var rightAngle = 100;
// 2. Define a variable named sideLength and set it to 90
// 3. We want to draw a square. Finish this code that
// draws the first side of the square so we get a
// complete square. You should only use variables
// as arguments to the functions
forward(sideLength);
right(rightAngle);
// 4. Change the length of the side by doubling the value
// of the variable sideLength. Go back up to 2. and change
// the value.
// 5. YOU DO: Draw another shape with 5 or more sides.
// You can only pass variables as arguments - there should
// not be any numbers. The shape can look however you want
// it to - so you may need several variables.
// penUp() and penDown() may be helpful if you want to move
// the pen to your starting place. stamp() will be helpful for
// troubleshooting.
canvas {
border: 1px solid black;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment