本文整理汇总了C++中Turtle::backward方法的典型用法代码示例。如果您正苦于以下问题:C++ Turtle::backward方法的具体用法?C++ Turtle::backward怎么用?C++ Turtle::backward使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Turtle
的用法示例。
在下文中一共展示了Turtle::backward方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tree
// Recursive fractal "tree" structure
void tree(Turtle& turtle, int level, double size, double angle,
double scale) {
if (level == 0) {
turtle.forward(size);
turtle.backward(size);
} else {
turtle.forward(size);
turtle.left(angle);
tree(turtle, level - 1, size * scale, angle, scale);
turtle.right(angle);
turtle.right(angle);
tree(turtle, level - 1, size * scale, angle, scale);
turtle.left(angle);
turtle.backward(size);
}
}
示例2: ccc_win_main
int ccc_win_main() {
Turtle t;
bool running = true;
while (running == true) {
double sides = -1;
while (sides < 1) {
sides = t.getInt("Enter number of sides:");
}
double length = t.getDouble("Enter length of sides:");
if (sides > 1) {
int degrees = DEGREES_IN_CIRCLE / sides;
t.setHeading(LEFT);
/*
Apothem is the distance of the normal of any side of the polygon
to the centerpoint of the polygon. The following code will
center the shape in the window.
*/
double apothem = length / (2 * tan(PI / sides));
t.moveTo(length / 2, -apothem);
int i = 0;
while (i < sides) {
t.forward(length);
t.right(degrees);
i++;
}
}
if (sides == 1) {
t.setHeading(0);
// Creates the upper case letter M.
t.moveTo(NTHREE,NNINE);
t.right(TEN);
t.forward(FORWARD_INC);
t.right(G_TURN2);
t.forward(FORWARD_INC);
t.left(G_TURN2);
t.forward(FORWARD_INC);
t.right(G_TURN2);
t.forward(FORWARD_INC);
// Creates the upper case letter G.
t.moveTo(SEVEN_POINT_FIVE, N_ONE_POINT_FIVE);
t.left(G_TURN);
t.forward(2);
t.backward(2);
t.right(ONE_THIRTY);
t.forward(2);
t.left(G_TURN);
t.forward(2);
t.left(G_TURN);
t.forward(2);
t.left(G_TURN);
t.forward(2);
t.left(G_TURN);
t.forward(2);
t.left(G_TURN);
t.forward(2);
t.left(G_TURN);
t.forward(2);
t.left(SMALL_TURN);
t.forward(1);
t.left(SMALL_TURN);
t.forward(1);
t.left(SMALL_TURN);
t.forward(1);
t.left(SMALL_TURN);
t.forward(1);
t.backward(2);
// Creates the upper case letter J.
t.setHeading(RIGHT_TURN);
t.moveTo(NSEVEN, FIVE);
t.forward(2);
t.right(STRAIGHT);
t.forward(1);
t.left(RIGHT_TURN);
t.forward(2);
t.right(RIGHT_TURN);
t.forward(1);
// Creates the upper case letter W.
t.moveTo(-FOUR, FIVE);
t.right(TWO_THIRTY);
t.forward(W_INC);
t.left(RIGHT_TURN);
t.forward(2);
t.right(RIGHT_TURN);
t.forward(2);
t.left(RIGHT_TURN);
t.forward(W_INC);
// Creates the upper case letter C.
t.moveTo(FOUR, FIVE);
t.right(C_TURN);
t.forward(2);
t.right(STRAIGHT);
t.forward(2);
t.left(RIGHT_TURN);
//.........这里部分代码省略.........