1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
   | int main(int argc, char *argv[])
{
 
SDL_Event event;
 
    SDL_Init(SDL_INIT_VIDEO);
 
//créer un terrain
    Terrain terrain(0,100,0, 500, 500);
	terrain.refresh();
 
//une image en fond d'écran
	terrain.chargerImage();
	terrain.afficherImage(0, 0);
	terrain.refresh();
 
//créer un Perso
    Personnage perso(50);
		terrain.refresh();
 
 
SDL_EnableKeyRepeat(10, 10); /* Activation de la répétition des touches */
 
int continuer = 1;
   while (continuer)
    {
 
        SDL_WaitEvent(&event);
        switch(event.type)
        {
 
case SDL_MOUSEBUTTONUP:
       if((event.button.x >= terrain.PositionFondX() && event.button.x <= terrain.PositionFondX() + terrain.getSurfaceFond()->w) && (event.button.y >= terrain.PositionFondY() && event.button.y <= terrain.PositionFondY() + terrain.getSurfaceFond()->h))
		{
 
	perso.afficherPerso(50, 50);
 
		}
                break;
		}
 
terrain.refresh();
 
	}
 
    pause();
 
    SDL_Quit();
 
    return EXIT_SUCCESS;
} | 
Partager