1 //      (_||_/
2 //      (    )       Classe Sprite
3 //     ( o  0 )
4 //-OOO�--(_)---�OOO---------------------------------------
5 //                   Copyright (C) 2006 By Dominique Roux-Serret
6 // .OOOo      oOOO.  roux-serret@ifrance.com
7 //-(   )------(   )---------------------------------------
8 //  ( (        ) /   Le 11/01/2006
9 //   (_)      (_/
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 <SDL/SDL.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   int L,H;
39   int cx,cy; // Centre de l'image apr�s recadrage
40   int bpp;   // Nombre de bytes par pixels 3 ou 4 avec l'alpha
41 };
42 
43 /*** Nom des sprites ***/
44 /***********************/
45 enum e_Sprite {
46   locomotive=0,
47   charbon,
48   buches,
49   balles,
50   moteur,
51   citerne,
52   wagon,
53   pluslong,
54   pluscourt,
55   vitesse,
56   vie,
57   nouveau_wagon,
58   logo_vie,
59   rail,
60   dir,
61   lettres,
62   chiffres,
63   titre,
64   copyright,
65   deco,
66   curseur,
67   fleche_gauche,
68   fleche_droite,
69   fleches,
70   monde,
71   music,
72   bruitage,
73   fscreen,
74   window,
75   keys,
76   gmenu,
77   menu,
78   fond_hr,
79   fond_hrr,
80   fond_menu,
81   fond,
82 
83   fjeu,
84   fmenu,
85   corde,
86   chargeur,
87 
88   T_level,
89   T_lives,
90   T_options,
91   T_score,
92   T_press_any_key,
93   T_continue,
94   T_moptions,
95   T_exit_game,
96   T_play,
97   T_scores,
98   T_better_scores,
99   T_quit,
100   T_new_game,
101   T_old_level,
102   T_menu,
103   T_easy,
104   T_normal,
105   T_hard,
106 #ifndef DCHILDREN
107   T_question,
108   T_tart1,
109   T_tart2,
110   T_tart3,
111   T_tart4,
112   T_tart5,
113   T_tart6,
114   T_tart7,
115   T_tart8,
116   T_tart9,
117   T_tart10,
118   T_tart11,
119   T_tart12,
120   T_tart13,
121   T_tart14,
122   T_tart15,
123   T_tart16,
124   T_tart17,
125   T_tart18,
126   T_tart19,
127   T_tart20,
128   T_tart21,
129   T_tart22,
130   T_tart23,
131   T_tart24,
132   T_tart25,
133   T_tart26,
134   T_tart27,
135   T_tart28,
136   T_tart29,
137   T_tart30,
138   T_art1,
139   T_art2,
140   T_art3,
141   T_art4,
142   T_art5,
143   T_art6,
144   T_art7,
145   T_art8,
146   T_art9,
147   T_art10,
148   T_art11,
149   T_art12,
150   T_art13,
151   T_art14,
152   T_art15,
153   T_art16,
154   T_art17,
155   T_art18,
156   T_art19,
157   T_art20,
158   T_art21,
159   T_art22,
160   T_art23,
161   T_art24,
162   T_art25,
163   T_art26,
164   T_art27,
165   T_art28,
166   T_art29,
167   T_art30,
168 #endif
169   T_Langue,
170 
171   T_ENDTEXT
172 };
173 
174 /*** Fonctions ***/
175 /*****************/
176 void AfficheChargeur(void);   // Affiche le chargeur sur la page de d�part
177 bool LoadLangue(void);  // Charge les sprites d'une langue
178 bool LoadSprites(void); // Charge tous les sprites
179 
180 int LongueurChiffre(int Nombre); // Retourne la longueur en pixels d'un nombre
181 int LongueurString(char *Texte);  // Retourne la longueur en pixels d'un texte
182 bool CharExiste(char C); // Si un caracataire existe
183 
184 void AfficheChiffre(int x,int y,int Nombre,SDL_Surface *Fond=NULL); // Affiche un chiffre
185 void AfficheString(int x,int y,char *Texte,SDL_Surface *Fond=NULL); // Affiche une chaine de caractaire
186 
187 void EffaceChiffre(int x,int y,int Nombre,SDL_Surface *Fond=NULL);  // Efface un chiffre
188 void AfficheText(int x,int y,e_Sprite Text,SDL_Surface *Fond=NULL); // Affiche un text dans la langue
189 
190 
191 /*** Definition de la classe Sprite ***/
192 /**************************************/
193 class Sprite
194 {
195  public:
196   Sprite(void);
197   ~Sprite(void);
198 
199   /*** Fonctions ***/
200   bool Load(unsigned char *Buf,long &P); // Charge les images
201   void Affiche(int X,int Y,int NumSpr,SDL_Surface *Fond=NULL);  // Affiche un sprite
202   void AfficheCorde(int dx,int dy,int fx,int fy); // Affiche une corde
203   void Efface(int X,int Y,int NumSpr,SDL_Surface *Fond);   // Efface le sprite
204   void EffaceCarre(int dx,int dy,int fx,int fy,SDL_Surface *Fond); // Efface un carr� � l'ecran
205   bool Nouveau(int Lx,int Ly); // Alloue un nouveau sprite vide sans transparence
206   void Delete(void); // Efface la m�moire du sprite
207 
208   /*** Variables ***/
209   int N;            // Nombre de sprite
210   SDL_Surface **Image; // Pointe sur les sprites
211   s_Dim *Dim; // Dimensions des sprites
212 };
213 
214 #endif
215