当前位置: 首页>>代码示例>>C++>>正文


C++ Turtle类代码示例

本文整理汇总了C++中Turtle的典型用法代码示例。如果您正苦于以下问题:C++ Turtle类的具体用法?C++ Turtle怎么用?C++ Turtle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Turtle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: drawPolygon

void drawPolygon(Turtle& turtle, double size, int sides) {
    double angle = 360.0 / sides;
    for (int count = 0; count < sides; count++) {
        turtle.forward(size);
        turtle.left(angle);
    }
}
开发者ID:obiejuan,项目名称:cabrillo-college,代码行数:7,代码来源:turtletest.cpp

示例2: Vec3f

void TreeGeneratorApp::update()
{
    screenRotation += (dRotation-screenRotation) / 16.0f;
    Vec3f centerOfEverything = Vec3f(0,0,0);
    if(turtles.size()>0){
    for(int i=0;i<turtles.size();i++){
        centerOfEverything += turtles.at(i).curPos;
    }
    }
    centerOfEverything /= turtles.size();
   // console() << "CENTER: " << centerOfEverything.x << ", " << centerOfEverything.y << "." << endl;
    
    for(int i=0;i<turtles.size();i++) {
        turtles.at(i).update();
        if(turtles.at(i).forwardVelocity<0.05f && turtles.at(i).forwardVelocity>0.0f){
            turtles.at(i).forwardVelocity=0.0f;
            for(int j=0;j<2;j++){
                if(turtles.size()<maxNum){
                Turtle newTurtle = Turtle();
            newTurtle.setup(turtles.at(i).curPos,centerOfEverything);
          
                turtles.push_back(newTurtle);
                }
            }
            }
    }
}
开发者ID:camb416,项目名称:TreeGenerator,代码行数:27,代码来源:TreeGeneratorApp.cpp

示例3: drawSpiral

void drawSpiral(Turtle& turtle, double size) {
    while (size < 1.25) {
        turtle.forward(size);
        turtle.right(15);
        size = size * 1.02;
    }
}
开发者ID:obiejuan,项目名称:cabrillo-college,代码行数:7,代码来源:turtletest.cpp

示例4: rand

void ObjectFactory::spawnSeaCreature(float xPos, float yPos,vector<Station*> *ships)
{
	int seaCreatureSpawnNum = rand() % 7;
	int rotation =  rand() % 360;
	switch (seaCreatureSpawnNum)
	{
	case 0:
	ships->push_back( new Whale(xPos, yPos, rotation));
	break;
	case 1:
	ships->push_back( new Hydra(xPos, yPos, rotation));
	break;
	case 2:
	ships->push_back( new Jellyfish(xPos, yPos, rotation));
	break;
	case 3:
	ships->push_back( new Octopus(xPos, yPos, rotation));
	break;
	case 4:
	ships->push_back( new Squid(xPos, yPos, rotation));
	break;
	case 5:
	ships->push_back( new Serpent(xPos, yPos, rotation));
	break;
	case 6:
	Turtle* myTurtle = new Turtle(xPos ,yPos,rotation);
	Helm* helm = new Helm(0, 10, 32, TextureManager::getManager()->helm,myTurtle);
	myTurtle->getHelms()->push_back(helm);
	ships->push_back(myTurtle);
	break;
	}
}
开发者ID:michael-whelan,项目名称:Skeleton-Crew,代码行数:32,代码来源:ObjectFactory.cpp

示例5: drawStar

void drawStar(Turtle& turtle, double size, int sides) {
    for (int i = 0; i < sides; i++) {
        turtle.forward(size);
        turtle.right(360.0 / sides);
        turtle.forward(size);
        turtle.left(2 * 360.0 / sides);
    }
}
开发者ID:obiejuan,项目名称:cabrillo-college,代码行数:8,代码来源:turtletest.cpp

示例6: drawRosette

void drawRosette(Turtle& turtle, double size, int squares) {
    double angle = 360.0 / squares;
    for (int i = 0; i < squares; i++) {
        for (int j = 0; j < 4; j++) {
            turtle.forward(size);
            turtle.right(90);
        }
        turtle.right(angle);
    }
}
开发者ID:obiejuan,项目名称:cabrillo-college,代码行数:10,代码来源:turtletest.cpp

示例7: Turtle

Turtle* Turtle::create() {
    Turtle *sprite = new Turtle();
    if (sprite && sprite->initWithFile("turtle_1.png")){
        sprite->setup();
        sprite->autorelease();
        return sprite;
    }
    CC_SAFE_DELETE(sprite);
    return nullptr;
}
开发者ID:areschoug,项目名称:LD29,代码行数:10,代码来源:Turtle.cpp

示例8: kochSnowflake

// Use Koch fractal to draw a "snowflake"
void kochSnowflake(Turtle& turtle, int level, double size) {
    double angle = 60;
    turtle.left(angle);
    koch(turtle, level, size, angle);
    turtle.right(angle);
    turtle.right(angle);
    koch(turtle, level, size, angle);
    turtle.right(angle);
    turtle.right(angle);
    koch(turtle, level, size, angle);
}
开发者ID:obiejuan,项目名称:cabrillo-college,代码行数:12,代码来源:turtletest.cpp

示例9: main

int main(){
	Pig pig;
	Turtle turtle;
	pig.eat();
	pig.sleep();
	pig.climb();
	turtle.swim();
	turtle.drool();

	return 0;
}
开发者ID:ginlee,项目名称:cpp,代码行数:11,代码来源:Animal.cpp

示例10: symetric_star

void symetric_star(int number_of_sides, const int IMAGE_SIZE, std::string file_name){

	Turtle turtle (IMAGE_SIZE/2,IMAGE_SIZE/2,IMAGE_SIZE);
	int angle = 180 - 180/number_of_sides;
	turtle.pendown();
	for (int x = 0; x < number_of_sides; ++x)
	{
		turtle.left(angle);
		turtle.forward(5);
	}
	turtle.save(file_name);
}
开发者ID:asketak,项目名称:Domaci-ulohy,代码行数:12,代码来源:A-turtle-test.cpp

示例11: drawArc

void drawArc(Point2 centre, float radius, float startAngle, float sweep)
{
	Turtle t;
	const int n = 30;
	float angle = startAngle * M_PI / 180;
	float angleInc = sweep * M_PI / (180 * n);
	float cx = centre.getX(), cy = centre.getY();
	t.moveTo(Point2(cx + radius*cos(angle), cy + radius*sin(angle)));
	for (int k = 1; k < n; k++, angle += angleInc)
	{
		t.lineTo(Point2(cx + radius*cos(angle), cy + radius*sin(angle)));
	}
}
开发者ID:Tauqeer1,项目名称:Graphics-Lab,代码行数:13,代码来源:Source.cpp

示例12: paint

void WorldPainter::paint(QPainter &p, Turtle &turtle, int xt, int yt) {
	auto oldPen = p.pen();
	auto oldBrush = p.brush();
	p.setPen(pen(turtle.getColor()));
	p.setBrush(brush(turtle.getColor()));

	auto triangle = getTriangle();
	auto position = turtle.getPosition();
	paint(p, triangle, position.getValue(0) + xt, position.getValue(1) + yt, turtle.getAngle(), 5.0);

	p.setPen(oldPen);
	p.setBrush(oldBrush);
}
开发者ID:Ynigvi,项目名称:stibbons,代码行数:13,代码来源:world-painter.cpp

示例13: koch

// Recursive Koch fractal
void koch(Turtle& turtle, int level, double size, double angle) {
    if (level == 0) {
        turtle.forward(size);
    } else {
        koch(turtle, level - 1, size, angle);
        turtle.left(angle);
        koch(turtle, level - 1, size, angle);
        turtle.right(angle);
        turtle.right(angle);
        koch(turtle, level - 1, size, angle);
        turtle.left(angle);
        koch(turtle, level - 1, size, angle);
    }
}
开发者ID:obiejuan,项目名称:cabrillo-college,代码行数:15,代码来源:turtletest.cpp

示例14: drawArc

void drawArc(Point centre, float radius, float startAngle, float sweep)
{
	Turtle t;
	const int n = 30;
	float angle = startAngle * M_PI / 180; //convert to radian
	float angleInc = sweep * M_PI / (180 * n);
	float cx = centre.getX(), cy = centre.getY();	//200,200
	float a, b;
	a = cx + radius*cos(angle);
	b = cy + radius*sin(angle);
	t.moveTo(Point(a, b));
	for (int k = 1; k < n; k++, angle += angleInc)
	{
		t.lineTo(Point(cx + radius*cos(angle), cy + radius*sin(angle)));
	}
}
开发者ID:Tauqeer1,项目名称:Graphics-Lab,代码行数:16,代码来源:Source.cpp

示例15: main

int main(int argc, const char* argv[]) {
    Parser p;
    ifstream f(argv[1]);
    string prod, drawing;
    if (f.is_open()) {
        p.parse(f);
        f.close();
        Lsystem lsys(p.getAlphabet(), p.getAxiom(), p.getRules());
        prod = lsys.produce(p.getIterations());
        Turtle ninja;
        drawing = ninja.rewrite(prod, p.getTurtle(),
            p.getReductionScale(), p.getInitPos(), p.getInitAng());
        cout << drawing;
        return EXIT_SUCCESS;
    } else {
        cout << "error opening file" << endl;
        return EXIT_FAILURE;
    }
}
开发者ID:atrilla,项目名称:lsystem,代码行数:19,代码来源:main.cpp


注:本文中的Turtle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。