本文整理汇总了C++中Turtle类的典型用法代码示例。如果您正苦于以下问题:C++ Turtle类的具体用法?C++ Turtle怎么用?C++ Turtle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Turtle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: main
int main(int argc, char** argv)
{
Win110ct win;
Turtle * t = win.getTurtle();
t->penDown();
t->setPosition(512,200);
t->setColour({128,128,255});
for(int i=0; i<24; ++i)
{
t->setPosition(512,200);
dragon(t, i, 400);
win.render();
SDL_Delay(2000);
win.clearBack();
}
win.getchar();
return 0;
}
开发者ID:MikeMorgan,项目名称:Lib110ctCpp,代码行数:20,代码来源:dragonCurves.cpp
示例17: rand
void UniverseSTL::addRace(){
// init race here
int sx = rand() % board.GetH();
int sy = rand() % board.GetW();
int ex= rand() % board.GetH();
int ey=sy;
Race* Ra = new Race(sx,sy,ex,ey);
RList.push_back(Ra);
for( auto&it: MList ){
if( isA<Rabbit>(it) )
{
Rabbit* r = (Rabbit*)it;
r->triggerRace(Ra);
}
else if( isA<Turtle>(it)){
Turtle* t = (Turtle*)it;
t->triggerRace(Ra);
}
}
}
开发者ID:rmxhaha,项目名称:JagatRaya,代码行数:21,代码来源:UniverseSTL.cpp
示例18: main
int main( int argc, char* args[] )
{
Win110ct win;
int d;
win.setTextColour({64,255,64});
win.setPosition(5,10);
win << "Enter max snowflake depth: ";
win >> d;
win.setTextColour({128,128,255});
Stopwatch s;
Turtle * t = win.getTurtle();
win.render();
win.getchar();
t->setPosition(800, 100);
t->setColour({255,64,64});
win.hideTurtle();
for(int i=1; i<=d; ++i)
{
win.clearBack();
kochFlake(t,i, 600);
win.render();
SDL_Delay(1000);
t->setPosition(800, 100);
t->turn(-120);
}
win.clear();
win.setPosition(10,20);
win << "Press any key to exit program";
win.getchar();
return 0;
}
开发者ID:MikeMorgan,项目名称:Lib110ctCpp,代码行数:40,代码来源:koch.cpp
示例19: rand
void UniverseList::addRace(){
// init race here
int sx = rand() % board.GetH();
int sy = rand() % board.GetW();
int ex= rand() % board.GetH();
int ey=sy;
Race *Ra=new Race(sx,sy,ex,ey);
RList.push_back(Ra);
for( auto its = MList.begin(); its != MList.end(); its = its->next)
{
Organism *it = its->val;
if( isA<Rabbit>(it) )
{
Rabbit* r = (Rabbit*)it;
r->triggerRace(Ra);
}
else if( isA<Turtle>(it)){
Turtle* t = (Turtle*)t;
t->triggerRace(Ra);
}
}
}
开发者ID:rmxhaha,项目名称:JagatRaya,代码行数:23,代码来源:UniverseList.cpp
示例20: 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);
}
}
开发者ID:obiejuan,项目名称:cabrillo-college,代码行数:17,代码来源:turtletest.cpp
注:本文中的Turtle类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论