int main(){

        Brain* brain = new Brain();
        Moteur* moteur = new Moteur();
        Sonar* sonarAvant = new Sonar();
        Sonar* sonarArriere = new Sonar();
        Gyroscope* gyroscope = new Gyroscope();
        FeedbackCurrent* feedbackCurrentReader = new FeedbackCurrent();
        Stage1* stage1 = new Stage1(brain);

        /* Initialisations */
        brain->init();
        moteur->init();
        feedbackCurrentReader->init();
        sonarAvant->init(AVANT);
        sonarArriere->init(ARRIERE);
        gyroscope->init();
		//bras->int();

        /* Bindings */
        brain->bindService(moteur);
        brain->bindService(feedbackCurrentReader);
        brain->bindService(sonarAvant);
        brain->bindService(sonarArriere);
        brain->bindService(gyroscope);
        brain->bindService(stage1);
        /* Lancement du brain */

        stage1->init();


        brain->start();

        /* Rajouter delete pour les composants  ??? */

        return EXIT_SUCCESS;
}
Esempio n. 2
0
int main(int argc, char **argv)
{
    SDL_Event event;
    SDL_Surface *screen;
    int fps, last, now;
    FPSmanager manager;

    #ifdef __linux
    glutInit(&argc, argv);
    #endif
    //Initialisation
    if(SDL_Init(SDL_INIT_VIDEO)!=0) {
        cerr << "Probleme pour initialiser SDL: " << SDL_GetError() << endl;
        return EXIT_FAILURE;
    }

    //Mettre un titre à la fenêtre
    SDL_WM_SetCaption("Pong Version 1.3", NULL);

    //Ouvrir une fenetre
    screen = SDL_SetVideoMode(WIDTH, HEIGHT, 32, SDL_OPENGL);
    if(screen==NULL)
        return EXIT_FAILURE;

    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);

    // Mettre le systeme de coordonnees a zero avant de modifier
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    //Mettre la bonne perspective
    glOrtho(0,WIDTH,HEIGHT,0,-1,1);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();                                            

    //Initialisation du moteur
    if(moteur.init()==false)
        return EXIT_FAILURE;

    //Initialisation 
    SDL_initFramerate(&manager);

    //Mettre le nombre d'images par secondes souhaite
    SDL_setFramerate(&manager,60);

    //Pour le calcul des FPS
    last = SDL_GetTicks()/1000;
    fps = 0;

    //Boucle generale
    while(moteur.estFini()==false)
    {
        //Traiter les evenements
        while(SDL_PollEvent(&event))
        {
            switch(event.type)
            {
                case SDL_QUIT:
                    moteur.fin();
                    break;
                case SDL_KEYDOWN:
            		moteur.clavier(event.key.keysym.sym);
                    break;
		  break;
                default:
                    break;
            }
        }

        // Demander au moteur de dessiner la scene
        moteur.gereScene();
        SDL_framerateDelay(&manager);

        //Pour le calcul de fps
        fps++;
        now = SDL_GetTicks()/1000;
    }

    SDL_Quit();

    (void) argc;
    (void) argv;
    return EXIT_SUCCESS;
}