Пример #1
0
void ParticleSystem::setup(string name, int cx, int cy, int w, int h){
    
    png.loadImage(name);
    
    centerX = cx;
    centerY = cy;
    width = w;
    height = h;
    hit = false;
    prevHit = false;
    
    png.resize(width, height);
    
    for(unsigned int y = 0; y < height; y+=1){
        for(unsigned int x = 0; x < width; x+=1){
            
            ofVec2f pixelPosition;
            pixelPosition.set(cx+x,cy+y);
            ofColor c = png.getPixelsRef().getColor(x, y);
            //int b = c.getBrightness();
            //if(b < 255){
                Mover m =  Mover(pixelPosition, c);
                movers.push_back(m);
            //}
            
        }
    }
}
Пример #2
0
//--------------------------------------------------------------
void ofApp::setup(){
    // test
    mapPhoto.load("images/vv_background.jpg");
    mapWidth = mapPhoto.getWidth();
    mapHeight = mapPhoto.getHeight();
    // ofHideCursor();
    ofNoFill();
    
    // Locations:
    Location rioBravo;
    rioBravo.setup(665,320);
    rioBravo.facebookPagename = "Rio-Bravo";
    rioBravo.likes = 1094;
    rioBravo.checkins = 21116;
    locations.push_back(rioBravo);
    Location raadhus;
    raadhus.setup(100,320);
    raadhus.facebookPagename = "Raadhuset";
    raadhus.likes = 435;
    raadhus.checkins = 32195;
    locations.push_back(raadhus);
    
    // Users:
    users.push_back(userCircle());
    users.back().update(400,40);
    users.push_back(userCircle());
    
    flowField.init();
    
    for(int i = 0; i < 5;i++){
        movers.push_back(Mover(ofVec2f(ofRandom(300),ofRandom(300)),1,1));
    }
    
}
//--------------------------------------------------------------
void ofApp::setup(){
     ofBackground(255);
     ofSetBackgroundAuto(true);
     for (int i=0; i<moverArray.size(); ++i)
        moverArray[i] = Mover();

}
void testApp::reset() {
    for (int i=movers.size();i>0;i--) {
        movers.erase(movers.begin() + i);
    }
    for (int i = 0; i < 11; i++) {
        movers.push_back(Mover(ofRandom(0.5, 3),40+i*70, 0));
    }
}
//--------------------------------------------------------------
void ofApp::setup(){
     ofBackground(255);
     ofSetBackgroundAuto(true);
     wind.set(0.02,0.0);
     for (int i=0; i<moverArray.size(); ++i)
        moverArray[i] = Mover(ofRandom(0.3,3.5), 100.0f,100.0f);

     liquid = Liquid(0.0,ofGetWindowHeight()/2.0,(float)ofGetWindowWidth(),ofGetWindowHeight()/2.0,0.02);
}
Пример #6
0
//--------------------------------------------------------------
void ofApp::setup(){

    ofBackground(255);
    ofSetBackgroundAuto(false);
    ofEnableSmoothing();
    ofSetFrameRate(60);
    
    for(int i=0;i<20;i++){
        movers.push_back(Mover(ofRandom(0.1,2),ofRandom(ofGetWidth()),ofGetHeight()));
    }
   
}
Пример #7
0
void Objeto::Actualizar()
{
	if(autoMovimiento)
	{
Mover(1);
Mover2(1);
	}
if(pasoLimite>0)
{
	//pasoActual++;
if(pasoActual>=pasoLimite)
	pasoActual = 0;
	}
}
//--------------------------------------------------------------
void testApp::setup(){

    ofSetFrameRate(60);
    ofBackground(255);     //Sets white background
    ofSetVerticalSync(true);
    ofEnableSmoothing();
    ofEnableAlphaBlending();

    wind.set(0.01,0);
    gravity.set(0,0.1);
    movers.clear();
    for (int i=0;i<20;i++) {
        movers.push_back(Mover(ofRandom(0.1,4),0,0));
    }
}
//--------------------------------------------------------------
void testApp::setup(){

    ofSetFrameRate(60);
    ofBackground(255);     
    ofSetVerticalSync(true);
    ofEnableSmoothing();
    ofEnableAlphaBlending();
    glEnable(GL_DEPTH_TEST);
    
    a = new Attractor();
    angle = 0;
    float g = 0.4;
    for (int i=0;i<10;i++) {
        movers.push_back(Mover(ofRandom(0.1,2),ofRandom(ofGetWidth()/2),ofRandom(ofGetHeight()/2),ofRandom(-100,100),g));
    }
}
Пример #10
0
//--------------------------------------------------------------
void ofApp::setup(){
    ofSetWindowShape(800, 200);
    ofBackground(255);
    ofSetBackgroundAuto(false);
    ofEnableSmoothing();
    ofSetFrameRate(60);
    
    // make loop to add 20 seperate movers so that their constructor is also called
    for(int i=0;i<20;i++){
        movers.push_back(Mover(ofRandom(0.1,4),ofRandom(ofGetWidth()),0));
    }
    
    // use pointer so we can use new ...
    liquid = new Liquid(0,ofGetHeight()/2,ofGetWidth(),ofGetHeight()/2,0.1);

}
Пример #11
0
/**
 * Metodo que realiza todas las acciones de la persona
 * @Return false si mover devuelve false
 */
bool Persona::Actuar()
{
  bool aux = true;
  if(turno_ <= Prision::get_instancia()->get_turno()) {
    if(turno_!=Prision::get_instancia()->get_turno()){
      turno_ = Prision::get_instancia()->get_turno();
      UsarPuerta();
      aux = Mover();
      if(aux) {
        Interactuar();
        TratarLlave();
      }
    }
  }
  return aux;
}
//--------------------------------------------------------------
void testApp::setup(){

    ofSetFrameRate(60);
    ofBackground(255);     
    ofSetVerticalSync(true);
    ofEnableSmoothing();
    ofEnableAlphaBlending();

    
    liquid = new Liquid(0, ofGetHeight()/2, ofGetWidth(), ofGetHeight()/2, 0.1);
    movers.clear();
    for (int i=0;i<11;i++) {
        movers.push_back(Mover(ofRandom(1, 4),ofRandom(0,ofGetWidth()),0));
    }
    snapCounter = 0;
	memset(snapString, 0, 255);		// clear the string by setting all chars to 0    
}
Пример #13
0
TEST(ApplyTuple, Test) {
  auto argsTuple = std::make_tuple(1, 2, 3.0);
  auto func2 = func;
  folly::applyTuple(func2, argsTuple);
  folly::applyTuple(func, argsTuple);
  folly::applyTuple(func, std::make_tuple(1, 2, 3.0));
  folly::applyTuple(makeFunc(), std::make_tuple(1, 2, 3.0));
  folly::applyTuple(makeFunc(), argsTuple);

  std::unique_ptr<Wat> wat(new Wat);
  folly::applyTuple(&Wat::func, std::make_tuple(wat.get(), 1, 2, 3.0));
  auto argsTuple2 = std::make_tuple(wat.get(), 1, 2, 3.0);
  folly::applyTuple(&Wat::func, argsTuple2);

  EXPECT_EQ(10.0,
            folly::applyTuple(&Wat::retVal,
                              std::make_tuple(wat.get(), 1, 9.0)));

  auto test = guard(func, 1, 2, 3.0);
  CopyCount cpy;
  auto test2 = guard(anotherFunc, cpy);
  auto test3 = guard(anotherFunc, std::cref(cpy));

  Overloaded ovl;
  EXPECT_EQ(0,
            folly::applyTuple(
              static_cast<int (Overloaded::*)(int)>(&Overloaded::func),
              std::make_tuple(&ovl, 12)));
  EXPECT_EQ(
      /* do not code-mode to EXPECT_TRUE */ true,
      folly::applyTuple(
          static_cast<bool (Overloaded::*)(bool)>(&Overloaded::func),
          std::make_tuple(&ovl, false)));

  int x = folly::applyTuple(std::plus<int>(), std::make_tuple(12, 12));
  EXPECT_EQ(24, x);

  Mover m;
  folly::applyTuple(move_only_func,
                    std::forward_as_tuple(std::forward<Mover>(Mover())));
  const auto tuple3 = std::make_tuple(1, 2, 3.0);
  folly::applyTuple(func, tuple3);
}
Пример #14
0
Arreglo<T>& Arreglo<T>::Mover(Nat destino, Nat origen) {
    return Mover(destino, *this, origen);
}
Пример #15
0
void *Options(void *opt)
{
    int sock = *(int *) opt;
    usuario_t *user = NULL;
    char *path;

    char comando[50];
    printf("SERVER: CHEGOU NA THREAD VERIFICACAO \n");

    /*
        Cria a thread de autenticacao
    */
    /*  pthread_t autenticacao_tid;
      pthread_create(&autenticacao_tid, NULL, Autenticacao, array);
      pthread_join(autenticacao_tid, NULL);
  */

    Autenticacao(sock, &user);

    if (user == NULL)
    {
        printf("Nous avons un problème");
        pthread_exit(NULL);
    }

    sem_t *ptr_mem;
    printf("Cliente conectou!\n");

    /*
        Acesso a sessao critica
    */

    bzero(&sock, 0);

    char buf[MAX_SIZE_BUFFER];

    bzero(buf, MAX_SIZE_BUFFER);

    strcpy(buf, "Conexao realizada com sucesso\n\n");
    strcat(buf, printCaminho(user));

    write(sock, buf, MAX_SIZE_BUFFER);

    do
    {
        printf("A espera de comandos...\n");
        read(sock, comando, sizeof(comando));
        printf("Comando recebido:|%s|\n", comando);

        char *comando_original = malloc(sizeof(char) * MAX_SIZE_BUFFER);
        strcpy(comando_original, comando);

        //comando;
        token = strtok(comando, " ");
        operation = token;

        if (strcmp(operation, "ls") == 0)
        {
            ListarConteudo(comando_original, sock, user);
        }
        else if (strcmp(operation, "mkdir") == 0)
        {
            CriarDiretorio(comando_original, sock, user);
        }
        else if (strcmp(operation, "touch") == 0)
        {
            CriarArquivo(comando_original, sock, user);
        }
        else if (strcmp(operation, "cat") == 0)
        {
            mostraConteudoArquivo(comando_original, sock, user);
        }
        else if (strcmp(operation, "rm") == 0)
        {
            Remover(comando_original, sock, user);
        }
        else if (strcmp(operation, "mv") == 0)
        {
            Mover(comando_original, user, sock);
        }
        else if (strcmp(operation, "cp") == 0)
        {
            Copiar(comando_original, user, sock);
        }
        else if (strcmp(operation, "cd") == 0)
        {
            Entrar(comando_original, user, sock);
        }
        else if (strcmp(operation, "clear") == 0)
        {
            system("clear");
            char *ret = printCaminho(user);
            write(sock, ret, strlen(ret) + 1);
        }
        else if (strcmp(operation, "exit") == 0)
        {

        }
        else
        {
            ComandoErrado(sock, user);
        }

        free(comando_original);
        bzero(&sock, 0);
    }
    while (strcmp(comando, "exit") != 0);

    printf("fim da execucao do cliente\n");
}