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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
| #include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>
/* Cette fonction charge l'ensemble des chiffres */
void chargement_chiffres(SDL_Surface *b[9])
{
/* Chargement des chiffres de couleur bleu*/
b[0] = SDL_LoadBMP("chiffres/b1.bmp");
b[1] =SDL_LoadBMP("chiffres/b2.bmp");
b[2] = SDL_LoadBMP("chiffres/b3.bmp");
b[3] =SDL_LoadBMP("chiffres/b4.bmp");
b[4] = SDL_LoadBMP("chiffres/b5.bmp");
b[5] = SDL_LoadBMP("chiffres/b6.bmp");
b[6] = SDL_LoadBMP("chiffres/b7.bmp");
b[7] =SDL_LoadBMP("chiffres/b8.bmp");
b[8] = SDL_LoadBMP("chiffres/b9.bmp");
}
void pause()
{
int continuer = 1;
SDL_Event event;
while (continuer)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
continuer = 0;
}
}
}
int main(int argc, char *argv[])
{
SDL_Surface *ecran = NULL,*imageDeFond = NULL;
SDL_Rect positionFond;
int continuer=1;
positionFond.x = 0;
positionFond.y = 0;
SDL_Init(SDL_INIT_VIDEO);
ecran = SDL_SetVideoMode(1024, 768, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
SDL_WM_SetCaption("SUDOKU par tizi", NULL);
SDL_Event event;
/* Chargement d'une image Bitmap dans une surface */
imageDeFond = SDL_LoadBMP("sudoku.bmp");
// Effacement de l'écran
SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 0, 0, 0));
/* On blitte par-dessus l'écran */
SDL_BlitSurface(imageDeFond, NULL, ecran, &positionFond);
SDL_Flip(ecran);
while (continuer)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
continuer = 0;
break;
case SDL_KEYDOWN:
switch(event.key.keysym.sym)
{
case SDLK_ESCAPE: // Veut arrêter le jeu
continuer = 0;
break;
case SDLK_1: // Demande à jouer
ecran = SDL_SetVideoMode(1021, 769, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
SDL_WM_SetCaption("SUDOKU par tizi", NULL);
SDL_Event event;
/* Chargement d'une image Bitmap dans une surface */
imageDeFond = SDL_LoadBMP("grille.bmp");
/* On blitte par-dessus l'écran */
SDL_BlitSurface(imageDeFond, NULL, ecran, &positionFond);
SDL_Flip(ecran);
pause();
SDL_FreeSurface(imageDeFond); /* On libère la surface */
SDL_Quit();
return EXIT_SUCCESS;
break;
case SDLK_2:
continuer=0;
break;
}
break;
}
SDL_BlitSurface(imageDeFond, NULL, ecran, &positionFond);
SDL_Flip(ecran);
}
SDL_FreeSurface(imageDeFond);
SDL_Quit();
return EXIT_SUCCESS;
} |
Partager