Bonjour,
Je suis en train de créer un projet SDL et j'ai quelques problèmes. Voici mes fichiers sources :
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 /* const.h ========= Created by: Bogoris Last modification: 2007/08/28 */ #ifndef DEF_CONST #define DEF_CONST #define BLOCK_SIZE // Size of a square block (pixels) #define NB_BLOCKS_X 30 #define NB_BLOCKS_Y 25 #define WINDOW_WIDTH BLOCK_SIZE * NB_BLOCKS_X // Must not exceed 640px #define WINDOW_HEIGH BLOCK_SIZE * NB_BLOCKS_Y // Must not exceed 480px /* Enum used to make our prog more speaky and to define files formats */ enum { VIDE = ' ', MUR = '#', SNAKE_LEFT = 'L', SNAKE_FORWARD = 'F', SNAKE_RIGHT = 'R', SNAKE_BACKWARD = 'B', APPLE = '$', TAIL = 'T', SNAKE_START = 'S' }; enum { TO_THE_TOP, TO_THE_BOTTOM, TO_THE_LEFT, TO_THE_RIGHT }; #endif
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 /* main.c ========= Created by: Bogoris Last modification: 2007/09/16 */ #include <stdio.h> #include <stdlib.h> #include <SDL/SDL.h> #include <SDL/SDL_image.h> int main() { int mustContinue = 1; SDL_Surface *screen = NULL, *menu = NULL; SDL_Rect menuPosition; SDL_Event event; if (SDL_Init(SDL_INIT_VIDEO) == -1) { fprintf(stderr, "SDL initialisation error."); exit(EXIT_FAILURE); } screen = SDL_SetVideoMode(570, 475, 32, SDL_HWSURFACE | SDL_DOUBLEBUF); SDL_WM_SetCaption("Bogoris\' Snake", NULL); menu = IMG_Load("sprites/menu.png"); menuPosition.x = 0; menuPosition.y = 0; while (mustContinue) { SDL_WaitEvent(&event); switch (event.type) { case SDL_QUIT: mustContinue = 0; break; case SDL_KEYDOWN: switch(event.key.keysym.sym) { case SDLK_ESCAPE: mustContinue = 0; break; case SDLK_1: // mustContinue = play(screen); break; case SDLK_KP1: // mustContinue = play(screen); break; default: break; } } SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); SDL_BlitSurface(menu, NULL, screen, &menuPosition); SDL_Flip(screen); } SDL_FreeSurface(menu); SDL_Quit(); // Arrêt de la SDL return EXIT_SUCCESS; // Fermeture du programme }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 /* play.h ======== Created by: Bogoris Last modification: 2007/06/13 */ #ifndef DEF_PLAY #define DEF_PLAY int play (SDL_Surface *screen); #endifEt voilà les messages de construction :
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 /* Play.c ======== Created by: Bogoris Last modification: 2007/06/13 */ #include <stdio.h> #include <stdlib.h> #include <SDL/SDL.h> #include <SDL/SDL_image.h> #include "const.h" #include "play.h" int play (SDL_Surface *screen) { int mustContinue = 2; SDL_Event event; printf("Function play\n"); char lvlPath[] = "lvl/map_01.lvl.txt"; char map[NB_BLOCKS_X][NB_BLOCKS_Y] = {0}; // loadLevel(lvlPath, map); while (mustContinue == 2) { SDL_WaitEvent(&event); switch(event.type) { case SDL_QUIT: mustContinue = 0; break; case SDL_KEYDOWN: switch(event.key.keysym.sym) { case SDLK_ESCAPE: mustContinue = 1; break; default: break; } break; } SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 255, 255, 255)); SDL_Flip(screen); } return mustContinue; }
Merci d'avance.Construction du répertoire des sources du projet : Bogoris_Snake ...
make
gcc -DHAVE_CONFIG_H -I. -I.. -Wall -g -g -O2 -MT play.o -MD -MP -MF .deps/play.Tpo -c -o play.o play.c
In file included from play.c:14:
play.h:11: erreur: two or more data types in declaration specifiers
play.h:11: erreur: two or more data types in declaration specifiers
play.c:17: erreur: conflicting types for «play"
play.h:11: erreur: previous declaration of «play" was here
play.c: In function «play":
play.c:24: attention : accolades manquantes autour de l'initialisation
play.c:24: attention : (near initialization for «map[0]")
play.c:24: attention : unused variable «map"
play.c:23: attention : unused variable «lvlPath"
make: *** [play.o] Erreur 1
Terminé ... sur un échec
Temps total utilisé : 0 secondes
Partager