-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathloco.cc
More file actions
684 lines (608 loc) · 19.8 KB
/
loco.cc
File metadata and controls
684 lines (608 loc) · 19.8 KB
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
// (_||_/
// ( )
// ( o 0 )
//-OOO°--(_)---°OOO---------------------------------------
// Copyright (C) 2006 By Dominique Roux-Serret
// .OOOo oOOO. roux-serret@ifrance.com
//-( )------( )---------------------------------------
// ( ( ) / Copyright (C) 2023 By Johnny Jazeix
// (_) (_/ jazeix@gmail.com
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 or version 3 of the License.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#include <cmath>
#include <cstdlib>
#include "preference.h"
#include "loco.h"
#include "audio.h"
#include "screen.h"
#define PIQ (M_PI / 2.0)
#ifndef M_PI
#define M_PI 3.141592654
#endif
/*** Variables globales ***/
/**************************/
extern sNewPreference Pref;
extern int currentTime;
extern int MasqueK;
int AddDir[] = { -1, 1, -LT, LT };
/*** Construteur et Destructeur ***/
/**********************************/
Loco::Loco(Audio &audio) :
m_audio(audio)
{
Init(LT / 2 + HT / 2 * LT, D_Right);
}
/*** Initialise la locomotive ***/
/********************************/
void Loco::Init(int Pos, int Direction)
{
int i;
unsigned char Ar = 0;
PLoco = 0; // Pointe sur la première case
PInter = -1;
Speed = Reduce = Extend = 0; // Pas d'alongement
Mort = -1;
Gagne = false;
Pref.WagonGap = WAGON_GAP_AVERAGE;
// Initialise les variables
for (i = 0; i < 256; i++) {
PosWagon[i].SprStart = 0;
}
// Cherche le case Avant
switch (Direction) {
case D_Top:
Pos += LT;
Ar = D_Bottom;
break;
case D_Bottom:
Pos -= LT;
Ar = D_Top;
break;
case D_Left:
Pos++;
Ar = D_Right;
break;
case D_Right:
Pos--;
Ar = D_Left;
break;
}
// Initialise le Tableau et la loco
D = D_Case * 1.99; // Positionne la tete presque à la fin
T[PLoco].P = Pos;
T[PLoco].Arrive = Ar;
T[PLoco].Sortie = Direction;
T[PLoco].D = D_Case;
// Fait avancer d'une case
Go(Direction);
Go(Direction);
// Initialise la loco et son wagon à charbon
NWagon = 2;
Wagon[0] = locomotive;
Wagon[1] = coal_wagon;
PosWagon[0].SprStart = PosWagon[1].SprStart = N_SPR_START;
PosWagon[0].dx = PosWagon[0].dy = -10;
PosWagon[0].fx = PosWagon[0].fy = -10;
PosWagon[1].dx = PosWagon[1].dy = -10;
PosWagon[1].fx = PosWagon[1].fy = -10;
MemoDuree = 0;
}
/*** Affiche la locomotive ***/
/*****************************/
void Loco::Display(Screen *Ec)
{
float ltrain = 0;
float p1, p2, a, ar, vx, vy;
int x1, x2, y1, y2;
int i, ns = 0;
int cdx, cdy, cfx = 0, cfy = 0; // Points d'accroche des cables
float lv;
// Affiche tous les wagons
for (i = 0; i < NWagon; i++) {
// Cherche les points du wagons
switch (Wagon[i]) {
case coal_wagon:
p1 = ltrain + 11;
p2 = ltrain + 36 - 11;
ltrain += 36.0;
lv = 18;
break;
default:
p1 = ltrain + 11;
p2 = ltrain + 40 - 11;
ltrain += 40.0;
lv = 20;
}
// Calcule la position des points
FindPoint(D - p1, x1, y1);
FindPoint(D - p2, x2, y2);
PosWagon[i].dx = x1; // Sauve la position des points pour test de colision futur
PosWagon[i].dy = y1;
PosWagon[i].fx = x2;
PosWagon[i].fy = y2;
// Calcule l'angle de rotation de la loco et le N° du Sprite
if (x1 <= x2) { // Angle 0 à 180 compris
vy = (float)(x2 - x1);
vx = (float)(y2 - y1);
if (vx != 0) {
a = atan(vy / vx) * 180.0 / M_PI;
}
else {
a = 90.0;
}
if (vx < 0) {
a = 180.0 + a;
}
}
else { // Angle 180.001 à 359.999
vy = (float)(x1 - x2);
vx = (float)(y1 - y2);
if (vx != 0) {
a = atan(vy / vx) * 180.0 / M_PI + 180.0;
}
else {
a = 270.0;
}
if (vx < 0) {
a = 180.0 + a;
}
}
ar = a * M_PI / 180.0;
// Prend le centre du sprite
x1 = (x1 + x2) / 2;
y1 = (y1 + y2) / 2;
// Affiche les cables de liaison
if (i > 0) { // Si doit afficher les cables
// Calcule le point d'accroche en sortie
cdx = x1 - (int)(sin(ar) * lv);
cdy = y1 - (int)(cos(ar) * lv);
// Affiche le cable
Ec->PrintCable(cdx, cdy, cfx, cfy);
}
// Calcule le crocher de fin pour le prochaine wagon
cfx = x1 - (int)(sin(ar + M_PI) * lv);
cfy = y1 - (int)(cos(ar + M_PI) * lv);
// Cherche le N° du Sprite
switch ((int)a) {
case 0: // En haut
ns = (int)(y1 + D_Case / 2) % (int)D_Case;
break;
case 180: // En bas
ns = (int)(y1 + D_Case / 2) % (int)D_Case + 40;
break;
case 90: // Gauche
ns = (int)(x1 + D_Case / 2) % (int)D_Case + 80;
break;
case 270: // Droite
ns = (int)(x1 + D_Case / 2) % (int)D_Case + 120;
break;
default:
ns = (int)(a * 160.0 / 360.0);
if (ns >= 160) {
ns = 0;
}
ns += 160;
}
Ec->PrintSprite(Wagon[i], ns, x1, y1);
// Si pas fini la sequence d'affiche de départ du wagon
if (PosWagon[i].SprStart < N_SPR_START) {
PosWagon[i].SprStart += MemoDuree * N_SPR_START / 750.0;
if (PosWagon[i].SprStart < N_SPR_START) {
Ec->PrintSprite(new_wagon, (int)(PosWagon[i].SprStart), x1, y1);
}
}
// Met l'ecart entre les wagons
ltrain += Pref.WagonGap;
}
}
/*** Test les options sur une case ***/
/*************************************/
void Loco::TestCase(float Dist, long DureeJeu, int *Tableau)
{
int i;
float DMoy;
float Ec1, vx, vy, Ec2;
// test si depasse milieu d'une case pour teste de colision
DMoy = (T[PLoco].D + T[PLoco - 1].D) / 2.0;
if (D <= DMoy && D + Dist >= DMoy) {
// Test si sur une option
switch (Tableau[T[PLoco].P]) {
case C_Wagon: // Une nouvelle loco
m_audio.Play(sWagon);
Tableau[T[PLoco].P] = 1; // efface l'option
Pref.Score += 5;
AddLoco(); // Ajoute une loco au azard
Gagne = true; // Test si la dernière loco
for (i = 0; i < LT * HT; i++) {
if (Tableau[i] == C_Wagon) {
Gagne = false;
}
}
if (Gagne) {
Mort = currentTime + PAUSE_DURATION;
m_audio.Play(sEnd);
}
break;
case C_Allonge: // Alonge la loco
m_audio.Play(sEtire);
Tableau[T[PLoco].P] = 1; // efface l'option
Pref.Score += 20;
if (Reduce > DureeJeu) {
Reduce = DureeJeu - 1;
}
else {
Extend = DureeJeu + EXTENSION_DURATION;
}
break;
case C_Reduit: // Si réduit la loco
m_audio.Play(sReduit);
Tableau[T[PLoco].P] = 1; // efface l'option
if (Extend > DureeJeu) {
Extend = DureeJeu - 1;
}
else {
Reduce = DureeJeu + REDUCTION_DURATION;
}
break;
case C_Speed: // Si Vitesse
m_audio.Play(sSpeed);
Tableau[T[PLoco].P] = 1; // efface l'option
Pref.Score += 30;
Speed = DureeJeu + SPEED_DURATION;
break;
case C_Live: // Si Vie
m_audio.Play(sLive);
Tableau[T[PLoco].P] = 1; // efface l'option
Pref.Lives++;
break;
}
// Test de colision avec un autre Wagon
for (i = 1; i < NWagon; i++) {
vx = (float)(PosWagon[i].dx - PosWagon[0].dx);
vy = (float)(PosWagon[i].dy - PosWagon[0].dy);
Ec1 = vx * vx + vy * vy;
vx = (float)(PosWagon[i].fx - PosWagon[0].dx);
vy = (float)(PosWagon[i].fy - PosWagon[0].dy);
Ec2 = vx * vx + vy * vy;
// Si colition le signale
if (Mort < currentTime && (Ec1 < RAYON_TOUCHE || Ec2 <= RAYON_TOUCHE)) {
m_audio.Play(sCrash);
Pref.Lives--;
Mort = currentTime + PAUSE_DURATION;
}
}
}
}
/*** Fait Avancer la locomotive ***/
/**********************************/
void Loco::Avance(int Duree, long DureeJeu, int *Touche, int *Tableau)
{
int i;
float Dist = Pref.SpeedAverage * (float)(Duree) / 1000.0;
MemoDuree = (float)(Duree);
TestCase(Dist, DureeJeu, Tableau);
// Test si doit Réduire le wagon
if (Reduce > DureeJeu) {
if (Pref.WagonGap > WAGON_GAP_MIN) { // Si doit réduire
Pref.WagonGap -= (float)(Duree) * (Pref.SpeedAverage * 0.8 / (float)(NWagon - 1)) / 1000.0;
if (Pref.WagonGap < WAGON_GAP_MIN) {
Pref.WagonGap = WAGON_GAP_MIN;
}
}
}
else { // Si temps est passé
if (Pref.WagonGap < WAGON_GAP_AVERAGE) { // Si doit ralonger le wagon
Pref.WagonGap += (float)(Duree) * (Pref.SpeedAverage * 0.8 / (float)(NWagon)) / 1000.0;
if (Pref.WagonGap > WAGON_GAP_AVERAGE) {
Pref.WagonGap = WAGON_GAP_AVERAGE;
}
}
}
// Test si doit Ralonger le wagon
if (Extend > DureeJeu) {
if (Pref.WagonGap < WAGON_GAP_MAX) { // Si doit Ralonger
Pref.WagonGap += (float)(Duree) * (Pref.SpeedAverage * 0.8 / (float)(NWagon)) / 1000.0;
if (Pref.WagonGap > WAGON_GAP_MAX) {
Pref.WagonGap = WAGON_GAP_MAX;
}
}
}
else { // Si temps est passé
if (Pref.WagonGap > WAGON_GAP_AVERAGE) { // Si doit ralonger le wagon
Pref.WagonGap -= (float)(Duree) * (Pref.SpeedAverage * 0.8 / (float)(NWagon - 1)) / 1000.0;
if (Pref.WagonGap < WAGON_GAP_AVERAGE) {
Pref.WagonGap = WAGON_GAP_AVERAGE;
}
}
}
// Test si doit modifier la vitesse de la loco
if (Speed > DureeJeu) {
if (Pref.SpeedAverage < Pref.Speed * 2) { // Si doit accelerer
Pref.SpeedAverage += (float)(Duree) / 40.0;
if (Pref.SpeedAverage > Pref.Speed * 2) {
Pref.SpeedAverage = Pref.Speed * 2;
}
}
}
else {
if (Pref.SpeedAverage > Pref.Speed) { // Si doit ralentir
Pref.SpeedAverage -= (float)(Duree) / 40.0;
if (Pref.SpeedAverage < Pref.Speed) {
Pref.SpeedAverage = Pref.Speed;
}
}
}
// Tand que dépasse la case en distante
while (D + Dist > T[PLoco].D) {
Dist -= T[PLoco].D - D; // Enleve la distance restant à parcourir
D = T[PLoco].D;
i = 0; // Cherche la direction possible
while (TestDir(Touche[i], Tableau) == false) {
i++;
}
Go(Touche[i]); // Fait avancer le loco suivant le désir du joueur
DoFleche(Tableau, Touche); // Recherche la position de la futur intersection
TestCase(Dist, DureeJeu, Tableau); // Test la case au cas ou le jeu est vraiment lent
}
D += Dist; // Met à la bonne position finale
if (PInter == -1) {
DoFleche(Tableau, Touche);
}
}
/*** Recherche la position de la futur intersection ***/
/******************************************************/
void Loco::DoFleche(int *Tableau, int *Touche)
{
int Sortie = T[PLoco].Sortie;
int MemoS;
int NVoie;
int x, y, Tou;
int i = 0;
if (T[PLoco].P != PInter && PInter != -1) {
return; // Si pas encore arrivé sur la case de croisement
}
PInter = T[PLoco].P; // Prend la position de la loco
do {
// Vas à la nouvelle case
switch (Sortie) {
case D_Top:
PInter -= LT;
PEntree = D_Bottom;
break;
case D_Left:
PInter--;
PEntree = D_Right;
break;
case D_Bottom:
PInter += LT;
PEntree = D_Top;
break;
case D_Right:
PInter++;
PEntree = D_Left;
break;
}
// Compte les voies disponibles.
MemoS = Sortie;
x = PInter % LT;
y = PInter / LT;
NVoie = 0;
if (y > 0 && PEntree != D_Top && Tableau[PInter - LT] != 0) {
Sortie = D_Top;
NVoie++;
}
if (y + 1 < HT && PEntree != D_Bottom && Tableau[PInter + LT] != 0) {
Sortie = D_Bottom;
NVoie++;
}
if (x > 0 && PEntree != D_Left && Tableau[PInter - 1] != 0) {
Sortie = D_Left;
NVoie++;
}
if (x + 1 < LT && PEntree != D_Right && Tableau[PInter + 1] != 0) {
Sortie = D_Right;
NVoie++;
}
} while (NVoie == 1);
// Prend la direction de sortie comme direction par defaut
while (Touche[i] != MemoS) {
i++;
}
if (i > 0 && !MasqueK) { // Prend la direction de la loco comme direction par defaut
Tou = Touche[i];
while (i) {
Touche[i] = Touche[i - 1];
i--;
}
Touche[0] = Tou; // Mémorise la touche
}
}
/*** Test si une direction est possible ***/
/******************************************/
bool Loco::TestDir(int FDir, int *Tableau)
{
int PAvant = T[PLoco].P;
int x, y;
// Test si les directions ne sont pas opposées
if (T[PLoco].Sortie == D_Top && FDir == D_Bottom) {
return false;
}
if (T[PLoco].Sortie == D_Bottom && FDir == D_Top) {
return false;
}
if (T[PLoco].Sortie == D_Left && FDir == D_Right) {
return false;
}
if (T[PLoco].Sortie == D_Right && FDir == D_Left) {
return false;
}
PAvant += AddDir[(T[PLoco].Sortie)]; // Position dans virage
// Test si un bord
x = PAvant % LT;
y = PAvant / LT;
if (FDir == D_Top && y == 0) {
return false;
}
if (FDir == D_Bottom && y + 1 == HT) {
return false;
}
if (FDir == D_Left && x == 0) {
return false;
}
if (FDir == D_Right && x + 1 == LT) {
return false;
}
PAvant += AddDir[FDir]; // Position futur
if (Tableau[PAvant] == 0) {
return false; // Test si il y a un rail
}
return true;
}
/*** Deplace la locomotive ***/
/*****************************/
bool Loco::Go(int FuturDir)
{
int PTab = T[PLoco].P;
int const Dir = T[PLoco].Sortie;
int Mask;
int i;
// Test si risque de dépassement et enleve une bonne partie
if (PLoco == 255) {
for (i = 0; i < 256 - 50; i++) {
T[i].P = T[i + 50].P;
T[i].D = T[i + 50].D;
T[i].Arrive = T[i + 50].Arrive;
T[i].Sortie = T[i + 50].Sortie;
}
PLoco -= 50;
}
// Mémorise la prochaine case
PLoco++; // Passe à la case suivante
switch (Dir) {
case D_Top:
PTab -= LT;
T[PLoco].Arrive = D_Bottom;
break;
case D_Bottom:
PTab += LT;
T[PLoco].Arrive = D_Top;
break;
case D_Left:
PTab--;
T[PLoco].Arrive = D_Right;
break;
default:
PTab++;
T[PLoco].Arrive = D_Left;
}
// Donne futur direction et N° case avant
T[PLoco].P = PTab;
T[PLoco].Sortie = FuturDir;
// Calcule la distance
Mask = T[PLoco].Arrive * 4 + T[PLoco].Sortie;
switch (Mask) {
case (D_Left * 4 + D_Right): // Si vas tous droit
case (D_Right * 4 + D_Left):
case (D_Top * 4 + D_Bottom):
case (D_Bottom * 4 + D_Top):
T[PLoco].D = T[PLoco - 1].D + D_Case;
break;
default:
T[PLoco].D = T[PLoco - 1].D + D_CaseR;
return true;
}
return false;
}
/*** Recherche un point sur le parcour ***/
/*****************************************/
void Loco::FindPoint(float Dist, int &x, int &y)
{
int NP = PLoco;
int P;
float D_Rest;
// Recherche la case d'avant
while (T[NP - 1].D > Dist) {
NP--;
}
P = T[NP].P;
// Calcule les coordonnée suivant la direction
D_Rest = T[NP].D - Dist;
if (D_Rest == 0) {
D_Rest = D_Case / 1000.0; // Evite les erreurs de division
}
switch (T[NP].Arrive * 4 + T[NP].Sortie) {
case (D_Left * 4 + D_Right):
y = int(P / LT * D_Case + D_Case / 2);
x = int(P % LT * D_Case + D_Case - D_Rest);
break;
case (D_Left * 4 + D_Top):
x = int(P % LT * D_Case + cos(D_Rest * PIQ / D_CaseR) * (D_Case / 2.0));
y = int(P / LT * D_Case + sin(D_Rest * PIQ / D_CaseR) * (D_Case / 2.0));
break;
case (D_Left * 4 + D_Bottom):
x = int(P % LT * D_Case + cos(D_Rest * PIQ / D_CaseR) * (D_Case / 2.0));
y = int(P / LT * D_Case + D_Case - sin(D_Rest * PIQ / D_CaseR) * (D_Case / 2.0));
break;
case (D_Right * 4 + D_Left):
y = int(P / LT * D_Case + D_Case / 2);
x = int(P % LT * D_Case + D_Rest);
break;
case (D_Right * 4 + D_Top):
x = int(P % LT * D_Case + D_Case - cos(D_Rest * PIQ / D_CaseR) * (D_Case / 2.0));
y = int(P / LT * D_Case + sin(D_Rest * PIQ / D_CaseR) * (D_Case / 2.0));
break;
case (D_Right * 4 + D_Bottom):
x = int(P % LT * D_Case + D_Case - cos(D_Rest * PIQ / D_CaseR) * (D_Case / 2.0));
y = int(P / LT * D_Case + D_Case - sin(D_Rest * PIQ / D_CaseR) * (D_Case / 2.0));
break;
case (D_Bottom * 4 + D_Top):
x = int(P % LT * D_Case + D_Case / 2);
y = int(P / LT * D_Case + D_Rest);
break;
case (D_Bottom * 4 + D_Left):
x = int(P % LT * D_Case + sin(D_Rest * PIQ / D_CaseR) * (D_Case / 2.0));
y = int(P / LT * D_Case + D_Case - cos(D_Rest * PIQ / D_CaseR) * (D_Case / 2.0));
break;
case (D_Bottom * 4 + D_Right):
x = int(P % LT * D_Case + D_Case - sin(D_Rest * PIQ / D_CaseR) * (D_Case / 2.0));
y = int(P / LT * D_Case + D_Case - cos(D_Rest * PIQ / D_CaseR) * (D_Case / 2.0));
break;
case (D_Top * 4 + D_Bottom):
x = int(P % LT * D_Case + D_Case / 2);
y = int(P / LT * D_Case + D_Case - D_Rest);
break;
case (D_Top * 4 + D_Left):
x = int(P % LT * D_Case + sin(D_Rest * PIQ / D_CaseR) * (D_Case / 2.0));
y = int(P / LT * D_Case + cos(D_Rest * PIQ / D_CaseR) * (D_Case / 2.0));
break;
case (D_Top * 4 + D_Right):
x = int(P % LT * D_Case + D_Case - sin(D_Rest * PIQ / D_CaseR) * (D_Case / 2.0));
y = int(P / LT * D_Case + cos(D_Rest * PIQ / D_CaseR) * (D_Case / 2.0));
break;
}
}
/*** Ajoute une loco au azrard ***/
/*********************************/
void Loco::AddLoco()
{
Wagon[NWagon] = (e_Sprite)(rand() % (wagon - logs_wagon) + logs_wagon);
if (Wagon[NWagon] == Wagon[NWagon - 1]) { // Evite 2 fois le meme wagon
if (Wagon[NWagon] + 1 == wagon) {
Wagon[NWagon] = logs_wagon;
}
else {
Wagon[NWagon] = (e_Sprite)(Wagon[NWagon] + 1);
}
}
PosWagon[NWagon].dx = PosWagon[NWagon].dy = -10;
PosWagon[NWagon].fx = PosWagon[NWagon].fy = -10;
NWagon++;
}