forked from berea-college-csc236/Recursive-Spiral-MASTER
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCTurtle-main.cpp
More file actions
34 lines (28 loc) · 832 Bytes
/
Copy pathCTurtle-main.cpp
File metadata and controls
34 lines (28 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* File: Recursive-Spiral.cpp
* Author: Jesse Walker-Schadler
* based on https://runestone.academy/runestone/books/published/cppds/Recursion/pythondsintro-VisualizingRecursion.html
*/
#include "CTurtle.hpp"
namespace ct = cturtle;
#include <iostream> //for input & output
using namespace std; //this makes it possible to use cin and cout without std:
void spiral(ct::Turtle& rt, int len) {
if (len > 0) {
rt.forward(len);
rt.right(90);
spiral(rt, len - 5);
}
}
int main() {
ct::TurtleScreen scr;
ct::Turtle rt(scr);
cout << "You need to change screens and click on the screen." << endl;
scr.onclick([&](int x, int y) {
rt.penup();
rt.goTo(x, y);
rt.pendown();
spiral(rt, 100);
}, ct::MOUSEB_LEFT);
scr.mainloop();
return 0;
}