Bonjour a tous,
voila je suis entrain de coder un morpion en c grâce a la SDL.
Cependant j'ai un petit problème.
Je devrais normalement être au point de l'affichage des rond et des croix en alterner.
mon probleme est qu'il n'y a que des croix qui s'affiche est il y a des endroits non cliquables:

X|X|-
X|X|-
-|-|-

ça me donne se schéma, les croix se mettent dans un carré en haut a droite et les "-" sont des zones non cliquables ( mais je peux aller dessus).

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>
#include "constantes.h"
#include <SDL_image.h>
 
void jeu (int joueur)
{
 
 
    /*
        Initialisation des variables du jeu
        */
    SDL_Surface *ecran = NULL, *imagefond = NULL, *selection= NULL, *croix=NULL, *rond=NULL;
    SDL_Rect positionimagefond, positionselection, position;
    SDL_Event event;
    int continuer = 1,i = 0, j = 0, x = 1, y = 1, tour = 1, nombredepion=0, gagnant=0;
    positionimagefond.x = 0;
    positionimagefond.y = 0;
    positionselection.x = x;
    positionselection.y = y;
    int grille[NB_BLOCS_LARGEUR][NB_BLOCS_HAUTEUR] = {0};
    /*
    Ouverture de SDL
    */
    if (SDL_Init(SDL_INIT_VIDEO) == -1) // Démarrage de la SDL. Si erreur alors...
    {
        fprintf(stderr, "Erreur d'initialisation de la SDL : %s\n", SDL_GetError()); // Ecriture de l'erreur
        exit(EXIT_FAILURE); // On quitte le programme
    }
 
    ecran = SDL_SetVideoMode(LARGEUR_FENETRE, HAUTEUR_FENETRE, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
 
    /*
    Chargement des images
    */
    SDL_WM_SetCaption("Morpion !", NULL);
    imagefond = IMG_Load("images/grille.bmp");
    selection= IMG_Load("images/selection.png");
    croix= IMG_Load("images/croix.png");
    rond = IMG_Load("images/rond.png");
    /*
    Affichage par defaut
    */
 
    SDL_BlitSurface(imagefond, NULL, ecran, &positionimagefond);
    SDL_BlitSurface(selection,NULL,ecran, &positionselection);
    SDL_Flip(ecran);
 
    /*
    Boucle du jeu
    */
    while (continuer || nombredepion !=9 || gagnant==0)
    {
 
        if (tour==0)
            tour++;
        if (tour==1)
            tour--;
 
        SDL_WaitEvent(&event);
        switch(event.type)
        {
        case SDL_QUIT:
            continuer = 0;
            break;
        case SDL_KEYDOWN:
            switch(event.key.keysym.sym)
            {
            case SDLK_ESCAPE:
                continuer = 0;
                break;
            case SDLK_UP:
                if(y - 1 <1 )
                    break;
                y--;
                break;
            case SDLK_DOWN:
 
                if(y + 1 >3 )
                    break;
                y++;
                break;
            case SDLK_RIGHT:
                if(x + 1 >3 )
                    break;
                x++;
                break;
            case SDLK_LEFT:
                if(x - 1 <1 )
                    break;
                x--;
                break;
            case SDLK_RETURN:
                if(grille[x][y] != 0)
                    break;
                grille[x][y]= tour+1;
                nombredepion++;
                break;
            }
            break;
        }
 
 
        /*
        Efface l'écran et réaffiche la grille
        */
        SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255));
        SDL_BlitSurface(imagefond, NULL, ecran, &positionimagefond);
 
        /*
        Recherche de croix et de ronds et affichage
        */
        for (i = 0 ; i < NB_BLOCS_LARGEUR ; i++)
        {
            for (j = 0 ; j < NB_BLOCS_HAUTEUR ; j++)
            {
                position.x = i * TAILLE_BLOC_COTE-TAILLE_BLOC_COTE;
                position.y = j * TAILLE_BLOC_COTE-TAILLE_BLOC_COTE;
 
                if(grille[i][j]==1)
                {
                    SDL_BlitSurface(croix, NULL, ecran, &position);
                }
                else if (grille[i][j]==2)
                {
 
 
                    SDL_BlitSurface(rond, NULL, ecran, &position);
                }
 
            }
        }
 
        /*
        Affichage de la selectionn
        */
        positionselection.x = x*TAILLE_BLOC_COTE-TAILLE_BLOC_COTE;
        positionselection.y = y*TAILLE_BLOC_COTE-TAILLE_BLOC_COTE;
 
        SDL_BlitSurface(selection, NULL, ecran, &positionselection);
        SDL_Flip(ecran);
 
 
    }
    /*
    Liberation des surfaces
    */
    SDL_FreeSurface(selection);
    SDL_FreeSurface(croix);
    SDL_FreeSurface(rond);
    SDL_FreeSurface(imagefond);
 
    SDL_Quit();
}
Je ne voit pas d’où vient l'erreur
Merci d'avance pour votre aide