Example #1
0
void Chomp::handle(const char& c){
  /**
   * Cette fonction vérifie les touches tapées au clavier
   * par les joueurs.
   * @param c représente le caractère taper au clavier
   */
  if(checkMove(c) ){
    return;
  }
  
  // si le joueur veut quitter le jeux
  if (c == 'x') {
    Game::getInstance()->mainMenu();
    return;
  }

  // si le joueur veux executer une action, ici joueur une piece
  if (c == 'p' || c == MARK) {
    /* vérifie si b est en position gagnante 
     * avec le coup jouer */
    if( isNext(mPointer, mSuccessors) ){
      mBoard.at(mPointer.fst(), mPointer.snd()) = mCurrentPlayer->getColor(); 
      fillcolor(mPointer.fst(), mPointer.snd());
      mCurrentPlayer = opponent();
    }
  }
}
Example #2
0
/* virtual */ void DotGenerator::visit(node::TransformNode* cam) {
  pre_node_info(cam);

  std::string fillcolor("[fillcolor =");
  fillcolor += " \"#888888\"";
  fillcolor += "]";

  post_node_info(cam, fillcolor);

  for (auto child : cam->children_)
    child->accept(*this);
}
Example #3
0
/* virtual */ void DotGenerator::visit(node::Node* node) {
  pre_node_info(node);

  std::string fillcolor("[fillcolor =");
  fillcolor += " \"#FFDD55\"";
  fillcolor += "]";

  post_node_info(node, fillcolor);

  for (auto child : node->children_)
    child->accept(*this);
}
Example #4
0
/* virtual */ void DotGenerator::visit(node::RayNode* ray) {
  pre_node_info(ray);

  std::string fillcolor("[fillcolor =");
  fillcolor += " \"#DDFF22\"";
  fillcolor += "]";

  post_node_info(ray, fillcolor);

  for (auto child : ray->children_)
    child->accept(*this);
}
Example #5
0
/* virtual */ void DotGenerator::visit(node::SpotLightNode* spot) {
  pre_node_info(spot);

  std::string fillcolor("[fillcolor =");
  fillcolor += " \"#FFDD55\"";
  fillcolor += "]";

  post_node_info(spot, fillcolor);

  for (auto child : spot->children_)
    child->accept(*this);
}
Example #6
0
/* virtual */ void DotGenerator::visit(node::ScreenNode* screen) {
  pre_node_info(screen);

  std::string fillcolor("[fillcolor =");
  fillcolor += " \"#55DDFF\"";
  fillcolor += "]";

  post_node_info(screen, fillcolor);

  for (auto child : screen->children_)
    child->accept(*this);
}
Example #7
0
/* virtual */ void DotGenerator::visit(physics::CollisionShapeNode* shape) {
  pre_node_info(shape);

  std::string fillcolor("[fillcolor =");
  fillcolor += " \"#AAFFAA\"";
  if (shape->data.get_shape() != "")
    parse_data_ += "| shape: " + shape->data.get_shape();
  fillcolor += "]";

  post_node_info(shape, fillcolor);

  for (auto child : shape->children_)
    child->accept(*this);
}
Example #8
0
/* virtual */ void DotGenerator::visit(node::VolumeNode* volume) {
	pre_node_info(volume);

	std::string fillcolor("[fillcolor =");
	fillcolor += " \"#CCEECC\"";
	if (volume->data.get_volume() != "")
		parse_data_ += "| volume: " + volume->data.get_volume();

	fillcolor += "]";

	post_node_info(volume, fillcolor);

	for (auto child : volume->children_)
		child->accept(*this);
}
Example #9
0
/* virtual */ void DotGenerator::visit(physics::RigidBodyNode* rb) {
  pre_node_info(rb);

  std::string fillcolor("[fillcolor =");
  fillcolor += " \"#FF2222\"";
  parse_data_ += "| mass: " + string_utils::to_string<float>(rb->mass());
  parse_data_ +=
      "| friction: " + string_utils::to_string<float>(rb->friction());
  parse_data_ +=
      "| restitution: " + string_utils::to_string<float>(rb->restitution());
  fillcolor += "]";

  post_node_info(rb, fillcolor);

  for (auto child : rb->children_)
    child->accept(*this);
}
Example #10
0
/* virtual */ void DotGenerator::visit(node::GeometryNode* geometry) {
  pre_node_info(geometry);

  std::string fillcolor("[fillcolor =");
  fillcolor += " \"#CCCCCC\"";
  if (geometry->get_filename() != "")
    parse_data_ += "| geometry: " + geometry->get_filename();
  if (geometry->get_material() != "")
    parse_data_ += "| material: " + geometry->get_material();

  fillcolor += "]";

  post_node_info(geometry, fillcolor);

  for (auto child : geometry->children_)
    child->accept(*this);
}
Example #11
0
/*!
    Sets this texture to have the contents of the image stored at \a url.

    If the environment variable QT3D_MULTITHREAD is defined, network urls
    (http, etc) are downloaded in a separate download thread, otherwise they are
    downloaded asynchronously in the current thread.
*/
void QGLTexture2D::setUrl(const QUrl &url)
{
    Q_D(QGLTexture2D);
    if (d->url == url)
        return;
    d->url = url;

    if (url.isEmpty())
    {
        d->image = QImage();
    }
    else
    {
        if (url.scheme() == QLatin1String("file") || url.scheme().toLower() == QLatin1String("qrc"))
        {
            QString fileName = url.toLocalFile();

            // slight hack since there doesn't appear to be a QUrl::toResourcePath() function
            // to convert qrc:///foo into :/foo
            if (url.scheme().toLower() == QLatin1String("qrc")) {
                // strips off any qrc: prefix and any excess slashes and replaces it with :/
                QUrl tempUrl(url);
                tempUrl.setScheme("");
                fileName = QLatin1String(":")+tempUrl.toString();
            }

            if (fileName.endsWith(QLatin1String(".dds"), Qt::CaseInsensitive))
            {
                setCompressedFile(fileName);
            }
            else
            {
                QImage im(fileName);
                if (im.isNull())
                    qWarning("Could not load texture: %s", qPrintable(fileName));
                setImage(im);
            }
        }
        else
        {
             if (!d->downloadManager) {
                if (getenv(QT3D_MULTITHREAD)) {
                    //Download in a multithreaded environment
                    d->downloadManager = new QThreadedDownloadManager();
                } else {
                    //Download in a single threaded environment
                    d->downloadManager = new QDownloadManager();
                }
                connect (d->downloadManager,SIGNAL(downloadComplete(QByteArray)),this, SLOT(textureRequestFinished(QByteArray)));
            }

            //Create a temporary image that will be used until the Url is loaded.
            static QImage tempImg(128,128, QImage::Format_RGB32);
            QColor fillcolor(Qt::gray);
            tempImg.fill(fillcolor.rgba());
            setImage(tempImg);

            if (!d->downloadManager->beginDownload(QUrl(url.toString()))) {
                qWarning("Unable to issue texture download request.");
            }
        }
    }
}