Debian Codegraph @

src/sprite.h

raw symbols SCIP
1 // (_||_/
2 // ( ) Sprite class
3 // ( o 0 )
4 //-OOO°--(_)---°OOO---------------------------------------
5 // Copyright (C) 2006 By Dominique Roux-Serret
6 // .OOOo oOOO. [email protected]
7 //-( )------( )---------------------------------------
8 // ( ( ) / Copyright (C) 2023 By Johnny Jazeix
9 // (_) (_/ [email protected]
10
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 or version 3 of the License.
14
15 // This program is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19
20 // You should have received a copy of the GNU General Public License along
21 // with this program; if not, write to the Free Software Foundation, Inc.,
22 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23
24 #ifndef SPRITE_DOM_
25 #define SPRITE_DOM_
26
27 #include <SDL2/SDL_render.h>
28
29 #define FCOLOR 128
30 #define ALPHA_OMBRE 125
31 #define ECART_ENTRE_CHIFFRE 1
32 #define ECART_ENTRE_LETTRE 2
33 #define LONGUEUR_ESPACE 30
34
35 /*** Definition de la structure Dim ***/
36 /**************************************/
37 struct s_Dim
38 {
39 int L, H;
40 int cx, cy; // Centre de l'image après recadrage
41 int bpp; // Nombre de bytes par pixels 3 ou 4 avec l'alpha
42 };
43
44 /*** Nom des sprites ***/
45 /***********************/
46 enum e_Sprite {
47 locomotive = 0,
48 charbon,
49 buches,
50 balles,
51 moteur,
52 citerne,
53 wagon,
54 pluslong,
55 pluscourt,
56 vitesse,
57 vie,
58 nouveau_wagon,
59 logo_vie,
60 rail,
61 dir,
62 lettres,
63 chiffres,
64 titre,
65 copyright,
66 deco,
67 curseur,
68 fleche_gauche,
69 fleche_droite,
70 fleches,
71 monde,
72 music,
73 bruitage,
74 fscreen,
75 window,
76 keys,
77 gmenu,
78 menu,
79 fond_hr,
80 fond_hrr,
81 fond_menu,
82 fond,
83
84 fjeu,
85 fmenu,
86 rope,
87 chargeur,
88
89 T_level,
90 T_lives,
91 T_options,
92 T_score,
93 T_press_any_key,
94 T_continue,
95 T_moptions,
96 T_exit_game,
97 T_play,
98 T_scores,
99 T_better_scores,
100 T_quit,
101 T_new_game,
102 T_old_level,
103 T_menu,
104 T_easy,
105 T_normal,
106 T_hard,
107 #ifndef DCHILDREN
108 T_question,
109 T_tart1,
110 T_tart2,
111 T_tart3,
112 T_tart4,
113 T_tart5,
114 T_tart6,
115 T_tart7,
116 T_tart8,
117 T_tart9,
118 T_tart10,
119 T_tart11,
120 T_tart12,
121 T_tart13,
122 T_tart14,
123 T_tart15,
124 T_tart16,
125 T_tart17,
126 T_tart18,
127 T_tart19,
128 T_tart20,
129 T_tart21,
130 T_tart22,
131 T_tart23,
132 T_tart24,
133 T_tart25,
134 T_tart26,
135 T_tart27,
136 T_tart28,
137 T_tart29,
138 T_tart30,
139 T_art1,
140 T_art2,
141 T_art3,
142 T_art4,
143 T_art5,
144 T_art6,
145 T_art7,
146 T_art8,
147 T_art9,
148 T_art10,
149 T_art11,
150 T_art12,
151 T_art13,
152 T_art14,
153 T_art15,
154 T_art16,
155 T_art17,
156 T_art18,
157 T_art19,
158 T_art20,
159 T_art21,
160 T_art22,
161 T_art23,
162 T_art24,
163 T_art25,
164 T_art26,
165 T_art27,
166 T_art28,
167 T_art29,
168 T_art30,
169 #endif
170 T_Langue,
171
172 T_ENDTEXT
173 };
174
175 /*** Fonctions ***/
176 /*****************/
177 void AfficheChargeur(); // Affiche le chargeur sur la page de départ
178 bool LoadLangue(); // Charge les sprites d'une langue
179 bool LoadSprites(); // Charge tous les sprites
180
181 int LongueurChiffre(int C); // Retourne la longueur en pixels d'un nombre
182 int LongueurString(char *Texte); // Retourne la longueur en pixels d'un texte
183 bool CharExiste(char C); // Si un caracataire existe
184
185 void AfficheChiffre(int x, int y, int Nombre, SDL_Texture *Fond = nullptr); // Affiche un chiffre
186 void AfficheString(int x, int y, char *Texte, SDL_Texture *Fond = nullptr); // Affiche une chaine de caractaire
187
188 void AfficheText(int x, int y, e_Sprite Text, SDL_Texture *Fond = nullptr); // Affiche un text dans la langue
189
190 /*** Definition de la classe Sprite ***/
191 /**************************************/
192 class Sprite
193 {
194 public:
195 Sprite() = default;
196 ~Sprite();
197
198 /*** Fonctions ***/
199 bool Load(unsigned char *Buf, long &P); // Charge les images
200 void Affiche(int X, int Y, int NumSpr, SDL_Texture *Fond = nullptr) const; // Affiche un sprite
201 void PrintRope(int dx, int dy, int fx, int fy);
202 bool Nouveau(int Lx, int Ly); // Alloue un nouveau sprite vide sans transparence
203 void Delete(); // Efface la mémoire du sprite
204
205 /*** Variables ***/
206 int N { 0 }; // Nombre de sprite
207 SDL_Texture **Image { nullptr }; // Pointe sur les sprites
208 s_Dim *Dim { nullptr }; // Dimensions des sprites
209 };
210
211 #endif