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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
int main (int argc, char *argv[])
{
SDL_Surface *ecran = NULL;
SDL_Event event;
bool continuer = 1;
SDL_Init(SDL_INIT_VIDEO);
ecran = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE| SDL_DOUBLEBUF);
//SDL_SetColorKey(zozor, SDL_SRCCOLORKEY, SDL_MapRGB(zozor->format, 0, 0, 255));
SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 0, 0, 112));
Carte carte(ecran);
//carte.AfficherGrille();
carte.ShowObstacle();
SDL_Flip(ecran);
if (SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL) == 0)
cout << "ok" << endl;
else
{
cout << "echec" << endl;
}
SDL_Rect s;
s.x = 100;
s.y = 100;
//######PARTIE QUI NOUS(?) INTERESSE#########
Tile t("Fond/Objets/Tile/tileTest/tileTest", s);
//######PARTIE QUI NOUS(?) INTERESSE#########"
while (continuer)
{
SDL_WaitEvent(&event); /* On utilise PollEvent et non WaitEvent pour ne pas bloquer le programme */
switch (event.type)
{
case SDL_QUIT:
continuer = 0;
break;
case SDL_KEYDOWN:
switch (event.key.keysym.sym)
{
case SDLK_a:
cout << "appel" << endl;
carte.Rafraichir(SDL_GetTicks());
cout << "rafraicih ok" << endl;
SDL_Flip(ecran);
break;
case SDLK_b:
SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 0, 0, 112));
SDL_Flip(ecran);
break;
case SDLK_c:
carte.AfficherGrille();
SDL_Flip(ecran);
break;
case SDLK_d:
{
cout << "appel ajouterTile" << endl;
carte.ShowObstacle();
if (carte.AjouterTile(t)) cout << "Tile Ajoute" << endl;
SDL_Flip(ecran);
}
break;
default:
break;
}
break;
default:
break;
}
//SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255));
//SDL_Flip(ecran);
}
//SDL_FreeSurface(t.vImageAnim[0]);
//SDL_FreeSurface(t.vImageAnim[1]);
//SDL_FreeSurface(t.vImageAnim[2]);
//########### ICI AUSSI ##########
cout << "sortie du bloc" << endl;
SDL_FreeSurface(ecran);
cout << "sortie du bloc" << endl;
SDL_Quit();
cout << "sortie du bloc" << endl;
//###############################
return EXIT_SUCCESS;
} |