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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
#ifndef CONSTANTES_H
#define CONSTANTES_H
#define JOUER 0
#define OPTIONS 1
#define QUITTER 2
#define XWIN 1024
#define YWIN 768
enum character_class_t {
CLASS_INVAL = -1,
CLASS_PALADIN,
#define PALADIN CLASS_PALADIN
CLASS_PRIEST,
#define PRETRE CLASS_PRIEST
CLASS_THIEF,
#define VOLEUR CLASS_THIEF
/* XXX add new ally classes here
* ->
*/
CLASS_ALLY_CNT,
CLASS_WARRIOR_GOBELIN = CLASS_ALLY_CNT,
#define GUERRIER_GOBELIN CLASS_WARRIOR_GOBELIN
/* XXX add new enemy classes here
* ->
*/
CLASS_CNT,
CLASS_ENEMY_CNT = CLASS_CNT - CLASS_ALLY_CNT,
};
#define VIE 1
#define MORT 0
//type de sort
#define FEU 0
#define GLACE 1
#define EAU 2
#define TONNERRE 3
#define CHOC 4
#define NON_ELEMENTAIRE 4
#define SOIN 0
//caractéristiques
#define SENSIBILITE 1
#define RESISTANCE 2
#define INVULNERABILITE 3
#define ABSORBTION 4
//active / desactivé
#define ACTIVE 1
#define DESACTIVE 0
#define ATTAQUE 0
#define MAGIE_BLANCHE 1
#define MAGIE_NOIRE 2
#define TECHNIQUES 3
#define OBJETS 4
#define POTION 0
#define ETHER 1
#define POTIONPLUS 2
#define ETHERPLUS 3
#define ACTIONS 5
#define DEGATS 0
#define SOINS 1
#define ALLIE 1
#define ENNEMI 0
enum damages_type_t {
DAMAGES_PHYSICAL,
#define TYPE_ATTAQUE DAMAGES_PHYSICAL
DAMAGES_MAGICAL,
#define TYPE_MAGIE DAMAGES_MAGICAL
};
enum action_state_t {
ACTION_PERFORMED,
ACTION_CANCELED,
ACTION_ERROR,
ACTION_COUNT,
};
#define SELECTION(nb,nb2) if (selection == nb)\
{\
if(nb2==ALLIE)\
{\
positions->Vpositioncurseurallies.x = positions->Vpositionpersos[nb].x + 20 + surfaces->Tperso[nb]->w;\
positions->Vpositioncurseurallies.y = positions->Vpositionpersos[nb].y + surfaces->Tperso[nb]->h/2 - surfaces->Pcurseurallies->h/2;\
SDL_BlitSurface (surfaces->Pcurseurallies,NULL,surfaces->Pecran,&positions->Vpositioncurseurallies);\
}\
else\
{\
SDL_BlitSurface (surfaces->Pcadrecible,NULL,surfaces->Pecran,&positions->Vpositioncadrecible);\
positions->Vpositioncurseurennemis.x=positions->Vpositionennemis[nb].x-20-surfaces->Pcurseurennemis->w;\
positions->Vpositioncurseurennemis.y=positions->Vpositionennemis[nb].y+surfaces->Tennemi[nb]->h/2 - surfaces->Pcurseurennemis->h/2;\
SDL_BlitSurface (surfaces->Pcurseurennemis,NULL,surfaces->Pecran,&positions->Vpositioncurseurennemis);\
}\
}
#define ECRIRE(texte,id)sprintf(chaine[id],texte);\
surfaces->Pnomactions[id]=TTF_RenderText_Blended(police,chaine[id],couleur);\
SDL_BlitSurface (surfaces->Pnomactions[id],NULL,surfaces->Pecran,&positions->Vpositionnomactions[id]);
//map
#define SOL 0
#define MUR 1
#define COFFRE 2
#define GUS 3
#define SELECTION_CIBLE() \
case SDLK_RIGHT:\
case SDLK_l: \
if(clan==ALLIE)\
{\
selection=0;\
while(ennemis[selection].etat==MORT)\
selection++;\
inverse_boolean(clan);\
SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncurseurallies,surfaces->Pecran,&positions->Vpositioncurseurallies);\
Fchangercurseurennemis (surfaces,positions,selection,ennemis);\
}\
break;\
case SDLK_LEFT:\
case SDLK_h: \
if(clan==ENNEMI)\
{\
SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncadrecible,surfaces->Pecran,&positions->Vpositioncadrecible);\
selection=0;\
while (!ally->chrs[selection].alive)\
selection++;\
inverse_boolean(clan);\
SDL_BlitSurface(surfaces->Pfondjeu,&positions->Vpositioncurseurennemis,surfaces->Pecran,&positions->Vpositioncurseurennemis);\
Fchangercurseurpersos(surfaces,positions,selection);\
}\
break;\
case SDLK_UP:\
case SDLK_k: \
if(clan==ENNEMI)\
{\
if (selection!=0)\
selection--;\
else\
selection=Vnbennemis;\
while(ennemis[selection].etat==MORT)\
{\
if(selection!=0)\
selection--;\
else\
selection=Vnbennemis;\
}\
Fchangercurseurennemis (surfaces,positions,selection,ennemis);\
}\
else\
{\
if (selection!=0)\
selection--;\
else\
selection=2;\
while (!ally->chrs[selection].alive)\
{\
if(selection!=0)\
selection--;\
else\
selection=2;\
}\
Fchangercurseurpersos(surfaces,positions,selection); \
}\
break;\
case SDLK_DOWN:\
case SDLK_j:\
if(clan==ENNEMI)\
{\
if(selection!=Vnbennemis)\
selection++;\
else\
selection=0;\
while(ennemis[selection].etat==MORT)\
{\
if(selection!=Vnbennemis)\
selection++;\
else\
selection=0;\
}\
Fchangercurseurennemis(surfaces,positions,selection,ennemis);\
}\
else\
{\
if(selection!=2)\
selection++;\
else\
selection=0;\
while (!ally->chrs[selection].alive) \
{\
if(selection!=2)\
selection++;\
else\
selection=0;\
}\
Fchangercurseurpersos(surfaces,positions,selection); \
}\
break;
#include <stdbool.h>
#define inverse_boolean(_b) ((_b) = (((_b)) ? false : true))
#endif
|