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


C++ Dot类代码示例

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


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

示例1: blit

bool bScreen::blit(Dot in)
{
	SDL_Surface *temp = NULL;
	SDL_Surface *nScreen = NULL;
	SDL_Rect *player = new SDL_Rect;
	SDL_Rect pos;
	SDL_Rect offset;
	SDL_Rect camera;
	bool success = false;
	camera = in.getCamera();

	offset.x = 0;
	offset.y = 0;
	
	pos.x = (in.getx()) - (camera.x);
	pos.y = (in.gety())- (camera.y);
	temp = in.getPlayerImage(0);
	player->x = 10 + ((in.phase/2)*PLAYERSPRITEW);
	player->y = 3 + ((in.direction)*PLAYERSPRITEH);
	player->w = 20;
	player->h = 30;
	
	SDL_BlitSurface(this->background, &camera, this->screen, &offset);

	SDL_BlitSurface(temp , player, this->screen, &pos );
	
	
	//rember to ask about possible memory leak here 
	//	delete temp;

	return success;

}
开发者ID:weardo05,项目名称:guiclasses,代码行数:33,代码来源:bScrenn.cpp

示例2: StoryScreen

void
Worldmap::update_locked_nodes()
{
  // FIXME: This shouldn't be a polling function
  path_graph->graph.for_each_node(unlock_nodes(path_graph.get()));

#if 0
  bool credits_unlocked = false;
  StatManager::instance()->get_bool(worldmap.get_short_name() + "-endstory-seen", credits_unlocked);

  if (!credits_unlocked)
  {
    // See if the last level is finished
    Dot* dot = path_graph->get_dot(final_node);
    if (dot)
    {
      if (dot->finished())
      {
        ScreenManager::instance()->push_screen(new StoryScreen(worldmap.get_end_story()));
      }
    }
    else
    {
      log_info("Error: Worldmap: Last level missing");
    }
  }
#endif
}
开发者ID:fsantanna,项目名称:pingus,代码行数:28,代码来源:worldmap.cpp

示例3: rand

Asteroid::Asteroid(int ast_size){
    int i, gen, dots, interval, angle, radius, min_radius, delta_radius;
    Asteroid* ast;
    Dot d;

    item = NULL;

    dots = 3*pow(2,ast_size);
    interval = 360/dots;
    min_radius = 10*pow(2,ast_size);
    delta_radius = 1.25*min_radius;

    //Generating vertex
    for(i=0; i<dots; i++){
        angle = rand()%interval + i*interval;
        radius = rand()%delta_radius + min_radius;

        d.setX(radius*cos(angle*PI/180));
        d.setY(radius*sin(angle*PI/180));
        loop_vertex.push_back(d);
    }


    if(ast_size != SMALL){

        //Generating subparts
        gen = rand()%2+2;
        while(gen>0){
            ast = new Asteroid(ast_size-1);
            d.setX(rand()%4-2);
            d.setY(rand()%4-2);
            ast->setSpeed(d);
            parts.push_back(ast);
            gen--;
        }
    }

    if(ast_size == BIG){
        //Generating item
        gen = rand()%(NUM_ITEMS*3);
        if(gen%3 == 0){
            item = new Item(gen/3);
            item->setSpeed(rand()%360, 0.25);
        }
    }

    //Adjusting centroid
    centralize();

    //setColor(0, 1, (float)(BIG - ast_size)/BIG);
    setColor(0, (GLfloat)(ast_size*0.125 + 0.75), (GLfloat)(0.25-ast_size*0.125));
    setHandling(1);

    if(rand()%2 == 0){
        commands[TURN_LEFT] = true;
    }
    else{
        commands[TURN_RIGHT] = true;
    }
}
开发者ID:vitorbnov,项目名称:SpaceBattle,代码行数:60,代码来源:Asteroid.cpp

示例4: whichSide

float Dot::whichSide(Dot a, Dot b){
    float xa = a.getX();
    float ya = a.getY();
    float xb = b.getX();
    float yb = b.getY();

    return (xa*yb - ya*xb + y*(xb-xa) + x*(ya-yb));
}
开发者ID:vitorbnov,项目名称:SpaceBattle,代码行数:8,代码来源:Dot.cpp

示例5: nearestCenter

void GraphicsScene::connectToNearest(Dot *start){
    if(!centersPointers.isEmpty()){
        Dot *end = nearestCenter(start);

        QGraphicsItem *newConnection = new Connection(start->getPosPointer(),end->getPosPointer());

        addItem(newConnection);
        start->setConnection(((Connection*)newConnection));
        update(QRectF(-50,-50,1000,1000));
    }
}
开发者ID:sbvb,项目名称:ClusterPlayground,代码行数:11,代码来源:graphicsscene.cpp

示例6: randFloat

void ParticleEngineApp::update()
{
	if (int(app::getElapsedFrames()) % 120 == 0) {
		mDotLoc.x	= randFloat(0.0f, app::getWindowWidth());
		mDotLoc.y	= randFloat(0.0f, app::getWindowHeight());
		mDotCol		= ColorA(randFloat(), randFloat(), randFloat(), 1.0f);
	}
	if (mIsPressed) {
		mDot.addParticles(N_PARTICLES, mMouseLoc, mMouseVel);
	}
	mDot.update(mDotLoc, mDotCol);
}
开发者ID:kschmal,项目名称:Cinder,代码行数:12,代码来源:ParticleEngineApp.cpp

示例7: main

int main( int argc, char* args[] ) {
  //Start up SDL and create window
  if( !init() ) {
    printf( "Failed to initialize!\n" );
  } else {
    //Load media
    if( !loadMedia() ) {
      printf( "Failed to load media!\n" );
    } else {
      //Main loop flag
      bool quit = false;

      //Event handler
      SDL_Event e;

      //The dot that will be moving around on the screen
      Dot dot;

      //While application is running
      while( !quit ) {
        //Handle events on queue
        while( SDL_PollEvent( &e ) != 0 ) {
          //User requests quit
          if( e.type == SDL_QUIT ) {
            quit = true;
          }

          //Handle input for the dot
          dot.handleEvent( e );
        }

        //Move the dot
        dot.move();

        //Clear screen
        SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
        SDL_RenderClear( gRenderer );

        //Render objects
        dot.render();

        //Update screen
        SDL_RenderPresent( gRenderer );
      }
    }
  }

  //Free resources and close SDL
  close();

  return 0;
}
开发者ID:kaprikawn,项目名称:sdl-starter,代码行数:52,代码来源:38_particle_engines.cpp

示例8: pingu_pos

void
Worldmap::draw(DrawingContext& gc)
{
  Vector2i pingu_pos(static_cast<int>(pingus->get_pos().x),
                     static_cast<int>(pingus->get_pos().y));
  int min, max;
  int width  = worldmap.get_width();
  int height = worldmap.get_height();

  if (width >= gc.get_width())
  {
    min = gc.get_width()/2;
    max = width - gc.get_width()/2;
  }
  else
  {
    min = width - gc.get_width()/2;
    max = gc.get_width()/2;
  }
  pingu_pos.x = Math::clamp(min, pingu_pos.x, max);

  if (height >= gc.get_height())
  {
    min = gc.get_height()/2;
    max = height - gc.get_height()/2;
  }
  else
  {
    min = height - gc.get_height()/2;
    max = gc.get_height()/2;
  }
  pingu_pos.y = Math::clamp(min, pingu_pos.y, max);

  gc_state.set_size(gc.get_width(), gc.get_height());
  gc_state.set_pos(Vector2i(pingu_pos.x, pingu_pos.y));

  gc_state.push(gc);

  for (auto i = drawables.begin (); i != drawables.end (); ++i)
  {
    (*i)->draw(gc);
  }

  Vector2f mpos = gc_state.screen2world(Vector2i(mouse_x, mouse_y));
  Dot* dot = path_graph->get_dot(mpos.x, mpos.y);
  if (dot)
    dot->draw_hover(gc);

  gc_state.pop(gc);
}
开发者ID:fsantanna,项目名称:pingus,代码行数:50,代码来源:worldmap.cpp

示例9: QRectF

Dot* GraphicsScene::nearestCenter(Dot *dot){
    double nearestDistance = QRectF(-50,-50,1000,1000).width();
    Dot *nearestCenterPointer;
    for(int i = 0; i < centersPointers.size(); i++){
        Dot *center = centersPointers.at(i);
        double newDistance = distance(dot->getPos(),center->getPos());

        if(newDistance < nearestDistance){
            nearestDistance = newDistance;
            nearestCenterPointer = centersPointers.at(i);
        }
    }

    return nearestCenterPointer;
}
开发者ID:sbvb,项目名称:ClusterPlayground,代码行数:15,代码来源:graphicsscene.cpp

示例10: get_position

SDL_Rect sword :: get_position(Dot myDot, Setup foo)
{
    if(look_up)
    {
        box.x = myDot.box.x;
        box.y = (myDot.box.y - le) + properHeight;
        weaponsT.loadFromFile( "first_test12.bmp" );

    }

    else if(look_down && !myDot.is_onGround())                      ///very much so temp--- this should be its own move, once i get moves sorted :D
    {
        box.x = myDot.box.x;
        box.y = myDot.box.y + myDot.box.h;
        weaponsT.loadFromFile( "first_test11.bmp" );
    }

    else
    {

         if(!direction)
         {
             box.x = myDot.box.x +  trueWidth;
             weaponsT.loadFromFile( "first_test10.bmp" );
         }
         else
         {
             box.x = (myDot.box.x - 128) + (128 - trueWidth);
             weaponsT.loadFromFile( "first_test9.bmp" );
         }
         box.y = myDot.box.y + trueHeight/2;
         return box;
    }
}
开发者ID:KarlRoe,项目名称:PixelChamp,代码行数:34,代码来源:sword.cpp

示例11: get_position

SDL_Rect gun :: get_position(Dot myDot, Setup foo)
{
    if(look_up)
    {
        box.x = myDot.box.x;
        box.y = myDot.box.y;
        weapons2T.loadFromFile( "first_test16.bmp" );
    }

    else if(look_down && !myDot.is_onGround())                      ///very much so temp--- this should be its own move, once i get moves sorted :D
    {
        box.x = myDot.box.x;
        box.y = myDot.box.y + (myDot.box.h - speed);
        weapons2T.loadFromFile( "first_test15.bmp" );
    }

    else
    {

         if(!direction)
         {
             box.x = myDot.box.x +  (trueWidth - speed);
             weapons2T.loadFromFile( "first_test14.bmp" );
         }
         else
         {
             box.x = (myDot.box.x - 128) + (128 - trueWidth);
             weapons2T.loadFromFile( "first_test13.bmp" );
         }
         box.y = myDot.box.y + trueHeight/2;
    }
    return box;
}
开发者ID:KarlRoe,项目名称:PixelChamp,代码行数:33,代码来源:gun.cpp

示例12: draw

void Polygon::draw(){
    unsigned int i;
    Dot d;

    glLoadIdentity();
    glTranslatef(position.getX(), position.getY(), 0);
    glRotated(direction, 0, 0, 1);
    glColor3f(color[RED], color[GREEN], color[BLUE]);
    glBegin(GL_LINES);
        for(i=0; i<lines_vertex.size(); i++){
            d = lines_vertex.at(i);
            glVertex2f(d.getX(), d.getY());
        }
    glEnd();
    glBegin(GL_LINE_STRIP);
        for(i=0; i<strip_vertex.size(); i++){
            d = strip_vertex.at(i);
            glVertex2f(d.getX(), d.getY());
        }
    glEnd();
    glBegin(GL_LINE_LOOP);
        for(i=0; i<loop_vertex.size(); i++){
            d = loop_vertex.at(i);
            glVertex2f(d.getX(), d.getY());
        }
    glEnd();
}
开发者ID:lemuelroberto,项目名称:SpaceBattle,代码行数:27,代码来源:Polygon.cpp

示例13: get_pingus

void
Worldmap::enter_level()
{
  NodeId node = get_pingus()->get_node();

  if (node != NoNode)
  {
    Dot* dot = path_graph->get_dot(node);
    if (dot)
    {
      dot->on_click();
    }
  }
  else
  {
    if (globals::developer_mode)
      log_info("Worldmap: Pingus not on level");
  }
}
开发者ID:fsantanna,项目名称:pingus,代码行数:19,代码来源:worldmap.cpp

示例14: Dot

void Picture::mousePressEvent(QMouseEvent *e)
{
    if (e->button() == Qt::LeftButton) {
           if (selectedPoints.size() < 8)
           {
               Dot* dot = new Dot(this);
               dot->show();
               update();
               dot->move(e->x(), e->y());
               Vector3i *newPoint = new Vector3i(e->x(), e->y(), 1);
               selectedPoints.push_back(*newPoint);
           }
           else
           {
               double w = (double)boardDimensions->x();
               double h = (double)boardDimensions->y();

               double divisor = w;
               if(w>h)
                divisor = h;

               w = ((double)boardDimensions->x()/divisor);
               h = ((double)boardDimensions->y()/divisor);

               realWorldPoints.push_back(Vector3d(0, 0, 1));
               realWorldPoints.push_back(Vector3d(0, h, 1));
               realWorldPoints.push_back(Vector3d(w, h, 1));
               realWorldPoints.push_back(Vector3d(w, 0, 1));

               // Calculate H Matrix
               MatrixXd H = Utils::calculateHomographyMatrix(selectedPoints, realWorldPoints);

               QImage inputImage = QImage("/home/fschuindt/dev/qt-persperctive-distortion-remotion/work-1/MyActions/brahma01.jpg");
               QImage outputImage = Utils::applyHomography(H, inputImage, vector<Vector3i>(selectedPoints.begin()+4, selectedPoints.end()));
               Utils::saveImage(outputImage, "/home/fschuindt/teste.jpg");

           }
    }

}
开发者ID:flavioschuindt,项目名称:qt-persperctive-distortion-remotion,代码行数:40,代码来源:picture.cpp

示例15: while

void GraphicsScene::updateConnections(){
    int i = 0;
    while(i<items().size()){
        QGraphicsItem *activeItem = items().at(i);
        if(((CustomItem*)activeItem)->getName() == std::string("Connection")){
            removeItem(activeItem);
        }
        else{
            i++;
        }
    }
    i = 0;
    while(i<items().size()){
        QGraphicsItem *activeItem = items().at(i);
        if(((CustomItem*)activeItem)->getName() == std::string("Dot")){
            Dot *dot = ((Dot*)activeItem);
            if(!dot->isCenter()){
                connectToNearest(dot);
            }
        }
        i++;
    }
    update(QRectF(-50,-50,1000,1000));
}
开发者ID:sbvb,项目名称:ClusterPlayground,代码行数:24,代码来源:graphicsscene.cpp


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