-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathload.c
806 lines (651 loc) · 25.3 KB
/
load.c
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
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
#include "load.h"
/*
Ce fichier contient les sous programmes appellées uniquement au début du jeu
merci à Mr. Segado pour la fonction init alleg
*/
/** trucs qui ne sont pas enregistrés dans save_game:
la quantité de ressources sur une case (soit y'en a pas soit reprend tout)
les temps (de formation des unités, les animation, attaques, tout est remis à zero)
La vision sur les cases
*/
//ce sous programme sert à définir les différents parametres d'une tuile
void set_tile(Tile *tile, char type)
{
int a;
tile->position = type - 'A'; //pour passer du caractère à un entier
tile->erige = NULL; //par defaud pas de batiment dessus
tile->fleur = 0;
switch (tile->type)
{
case ROCK:
case TREE:
tile->block = SOLID;
switch (tile->position)
{
case 0: //si c'est la partie basse d'un arbre feuillu ou conifere
case 2:
tile->res = GRAND; //set les ressources
break;
case 4: //si c'est un petit arbre
tile->res = PETIT;
break;
default:
break;
}
break;
case BUILDING:
tile->block = SOLID;
tile->res = 0;
break;
case CAMP:
tile->block = SOLID;
tile->res = 0;
break;
case WATER:
tile->block = NAGE; //peut pas passer
tile->res = 0;
if (tile->position==0)
{
//rien pour l'instant, on ajoutera les nenuphars après
}
break;
case MOUNTAIN:
tile->block = SOLID;
tile->res = 0;
break;
default:
case GRASS:
tile->block = VIDE; //il n'y a rien
tile->res = 0;
if (tile->position==P_HERBE)
{
a = rand()%20;
if (a<7)
tile->fleur = a;
else if (a==8)
tile->fleur = 3;
}
else if (tile->position==P_SABLE) //on met les caillous
{
a = rand()%44;
if (a<3)
tile->fleur = a+7;
else if (a==4)
tile->fleur = 7;
}
break;
}
tile->visible = 0; //au debut tous les blocks sont invisibles
}
//chargement de toute la map et des bitmaps
void load_game(Tile carte[MAPSIZEX][MAPSIZEY], Ancre *ancre, Ancre_b *ancre_b, Joueur *joueur, int num)
{
int i, j, k;
FILE *fic;
char a, fichier[50];
int siz, x, y;
Unit *unite;
Build *bat;
//on fait le nom du fichier
sprintf(fichier, NAME, SAUV, num, MAP);
DEB("0-10")
//chargement de la map depuis un fichier
fic = fopen(fichier, "r"); ERR_CHARG(fic)
for (j=0;j<MAPSIZEY;j++)
{
for (i=0;i<MAPSIZEX;i++)
{
fscanf(fic, "%c%c", &carte[i][j].type, &a); //chaque tuile
set_tile(&carte[i][j], a);
}
fscanf(fic, "\n");
}
fclose(fic);
//fin du chargement de la map
DEB("0-11")
sprintf(fichier, NAME, SAUV, num, FOG);
fic = fopen(fichier, "r");
//chargement du brouillard de guerre s'il y en a un
if (fic!=NULL)
{
for (j=0;j<MAPSIZEY;j++)
{
i = 0;
while (i<MAPSIZEX)
{
fscanf(fic, "%d %d ", &x, &y);
for (k=0;k<y;k++)
{
carte[i][j].visible = x;
i++;
}
}
fscanf(fic, "\n");
}
fclose(fic);
}
DEB("0-12")
//assemblage de l'autre nom
sprintf(fichier, NAME, SAUV, num, VALS);
fic = fopen(fichier, "r");ERR_CHARG(fic)
//chargement des autres valeurs
fscanf(fic, "%d\n", &siz);
DEB("0-13")
for (i=0;i<siz;i++) //chaquee batiment
{
bat = malloc(sizeof(Build));
fscanf(fic, "%d %d %d %d\n", &bat->x, &bat->y, &bat->w, &bat->h);
fscanf(fic, "%d %d %d %d %d %d\n", &bat->state, &bat->side, &bat->hp, &bat->hp_max, &bat->range, &bat->damage);
fscanf(fic, "%d %d\n", &bat->cap, &bat->statione);
fscanf(fic, "\n");
for (k=0;k<bat->w;k++)
{
for (j=0;j<bat->h;j++) //toutes les cases (tuiles)
{
carte[bat->x+k][bat->y+j].erige = bat; //on y met le pointeur sur batiment
}
}
fscanf(fic, "%d\n\n", &bat->curr_queue); //on met les unités en formation
for (j=0;i<bat->curr_queue;i++)
{
fscanf(fic, "%d\n", &bat->unit_queue[i]);
}
getTime(&bat->start);
//on éclaire la zone
if (bat->side==ALLY)
{
eclaire(carte, (bat->x+bat->w/2)*COTE, (bat->y+bat->h/2)*COTE, 4);
}
ajout_debut_b(ancre_b, bat); //on l'ajoute à la liste chainée
}
DEB("0-14")
fscanf(fic, "\n\n%d\n\n", &siz);
for (i=0;i<siz;i++) //pour chaque unite
{
unite = malloc(sizeof(Unit));
fscanf(fic, "%d %d %d %d\n", &unite->x, &unite->y, &unite->xdest, &unite->ydest);
fscanf(fic, "%d %d %d %d %d %d\n", &unite->hp, &unite->hp_max, &unite->damage, &unite->side, &unite->type, &unite->unitsize);
fscanf(fic, "%d %d %d %d %d\n", &unite->frame, &unite->state, &unite->priority, &unite->prec, &unite->direction);
fscanf(fic, "%d %d %d %d %f %d\n", &unite->cote, &unite->prod, &unite->speed, &unite->range, &unite->delay, &unite->vision);
fscanf(fic, "%d %d\n", &x, &y);
if (x==-1 || y==-1)
unite->bat = NULL;
else if (carte[x][y].erige)
unite->bat = carte[x][y].erige;
else
unite->bat = NULL;
getTime(&unite->since_a); //les temps ne sont pas enregistrés
getTime(&unite->since_w);
unite->speed*=SCALE;
unite->changepath = 1;
unite->step = NULL;
unite->xpath = DIV(unite->xdest);
unite->ypath = DIV(unite->ydest);
ajout_debut(ancre, unite);
fscanf(fic, "\n");
}
DEB("0-15")
//les valeurs "globales" - -on remplit la structure joueur
fscanf(fic, "\n\n\n");
fscanf(fic, "%d %d %d %d\n", &joueur->xcamera, &joueur->ycamera, &joueur->xecran, &joueur->yecran);
fscanf(fic, "%d %d %d %d\n", &joueur->bois, &joueur->marbre, &joueur->viande, &joueur->nend_b);
fscanf(fic, "%d %d\n", &joueur->level, &joueur->map_num);
DEB("0-16")
joueur->quit = 0;
joueur->change = 1;
joueur->chang_taill = 1;
DEB("0-17")
joueur->prevwheel = mouse_z;
joueur->act = RIEN;
joueur->clic_prec = 0;
getTime(&joueur->last_spawn);
getTime(&joueur->last_clic);
DEB("0-18")
fscanf(fic, "%d\n", &siz);
getTime(&joueur->debut);
addSec(&joueur->debut, (-1 * siz));
joueur->pause = 0;
fscanf(fic, "\n");
DEB("0-19")
fclose(fic);
}
//sauvegarde toute la partie dans un fichier de sauvegarde
void save_game(Tile carte[MAPSIZEX][MAPSIZEY], Ancre ancre, Ancre_b ancre_b, Joueur joueur, int num)
{
int i, j;
TIMESTRUCT now;
Maillon *inter1;
Maillon_b *inter2;
Unit *unite;
Build *bat;
FILE *fic;
char fichier[50];
int val, counter;
getTime(&now);
sprintf(fichier, NAME, SAUV, num, MAP); //on assemble le nom du fichier
fic = fopen(fichier, "w");
//sauvegarde de la map (ne sauvegarde pas la quantité de ressources. ni la visibilité :'(..)
for (j=0;j<MAPSIZEY;j++)
{
for (i=0;i<MAPSIZEX;i++)
{
fprintf(fic, "%c%c", carte[i][j].type, carte[i][j].position+'A');
}
fprintf(fic, "\n");
}
fprintf(fic, "\n");
fclose(fic);
sprintf(fichier, NAME, SAUV, num, FOG);
fic = fopen(fichier, "w");
//sauvegarde du brouillard de guerre
for (j=0;j<MAPSIZEY;j++)
{
counter = 0;
val = 0;
for (i=0;i<MAPSIZEX;i++)
{
if (val==carte[i][j].visible)
{
counter++;
}
else
{
fprintf(fic, "%d %d ", val, counter);
val = carte[i][j].visible;
counter = 1;
}
}
fprintf(fic, "%d %d \n", val, counter);
}
fprintf(fic, "\n");
fclose(fic);
sprintf(fichier, NAME, SAUV, num, VALS); //on assemble le nom du deuxième fichier
fic = fopen(fichier, "w");
//sauvegarde des autres valeurs
fprintf(fic, "%d\n", taille_b(ancre_b));
inter2 = ancre_b.debut;
while (inter2!=NULL)
{
bat = inter2->batiment; //on sauvegarde les batiments
fprintf(fic, "%d %d %d %d\n", bat->x, bat->y, bat->w, bat->h);
fprintf(fic, "%d %d %d %d %d %d\n", bat->state, bat->side, bat->hp, bat->hp_max, bat->range, bat->damage);
fprintf(fic, "%d %d\n", bat->cap, bat->statione);
fprintf(fic, "\n");
fprintf(fic, "%d\n\n", bat->curr_queue);
for (i=0;i<bat->curr_queue;i++) //la queue de formation d'unités
{
fprintf(fic, "%d\n", bat->unit_queue[i]);
}
inter2 = inter2->next;
}
fprintf(fic, "\n\n\n%d\n\n", taille(ancre));
inter1 = ancre.debut;
while (inter1!=NULL) //on sauvegarde toutes les unités
{
unite = inter1->unite;
fprintf(fic, "%d %d %d %d\n", unite->x, unite->y, unite->xdest, unite->ydest);
fprintf(fic, "%d %d %d %d %d %d\n", unite->hp, unite->hp_max, unite->damage, unite->side, unite->type, unite->unitsize);
fprintf(fic, "%d %d %d %d %d\n", unite->frame, unite->state, unite->priority, unite->prec, unite->direction);
fprintf(fic, "%d %d %d %d %f %d\n", unite->cote, unite->prod, (int)(unite->speed/SCALE), unite->range, unite->delay, unite->vision);
//on se permet de ne pas mettre les temps depuis la dernière animation/attaque
if (!unite->bat)
fprintf(fic, "%d %d\n", -1, -1);
else if (unite->bat->hp<=0)
fprintf(fic, "%d %d\n", -1, -1);
else
fprintf(fic, "%d %d\n", unite->bat->x, unite->bat->y);
fprintf(fic, "\n");
inter1 = inter1->next;
}
fprintf(fic, "\n\n\n");
//les valeurs "globales" (on ecrit la structure joueur)
fprintf(fic, "%d %d %d %d\n", joueur.xcamera, joueur.ycamera, joueur.xecran, joueur.yecran);
fprintf(fic, "%d %d %d %d\n", joueur.bois, joueur.marbre, joueur.viande, joueur.nend_b);
fprintf(fic, "%d %d\n", joueur.level, joueur.map_num);
//on ne met pas prevwheel
//on ne met pas non plus les valeurs à petite durée d'utilisation
fprintf(fic, "%d\n", getSecInt(&joueur.debut, &now));
fprintf(fic, "\n");
fclose(fic);
}
//remet tout à zero
void reset(Ancre *ancre, Ancre_b *ancre_b, Joueur *joueur, Tile carte[MAPSIZEX][MAPSIZEY])
{
int i, j;
for (i=0;i<MAPSIZEX;i++)
{
for (j=0;j<MAPSIZEY;j++) //chaque tuile de la map
{
carte[i][j].type = GRASS;
carte[i][j].position = P_HERBE;
carte[i][j].block = 0;
carte[i][j].res = 0;
carte[i][j].visible = 0;
carte[i][j].erige = NULL;
}
}
//les valeurs "globales"
joueur->xcamera = 0;
joueur->ycamera = 0;
joueur->xecran = ECRANX;
joueur->yecran = ECRANY;
joueur->prevwheel = mouse_z;
joueur->bois = 0;
joueur->marbre = 0;
joueur->viande = 0;
joueur->nend_b = 1;
joueur->nend_e = 0;
joueur->quit = 0;
joueur->pause = 0;
joueur->xprev = 0;
joueur->yprev = 0;
joueur->act = RIEN;
joueur->clic_prec = 0;
joueur->level = EASY;
joueur->change = 1;
joueur->chang_taill = 1;
getTime(&joueur->debut);
getTime(&joueur->last_clic);
getTime(&joueur->last_spawn);
libere(&joueur->selection, 0);
libere(ancre, 1);
libere_b(ancre_b, 1);
}
//pour la création des petits menus dans l'UI
BITMAP *create_menu(Sprites sprites, int type)
{
int i;
BITMAP *rep, *inter;
rep = create_bitmap(XSCREEN-SEPARE, UI_HEIGHT); //la bonne taille
blit(sprites.r_bar, rep, 0, 0, 0, 0, XSCREEN-SEPARE, UI_HEIGHT);
inter = create_bitmap(BOX_W, BOX_H); //les boites individuelles pour chaque truc possible à "acheter"
rectfill(inter, 0, 0, BOX_W, BOX_H, MAG);
draw_sprite(inter, sprites.bois_i, MARGE, MARGE); //les icones des ressources
draw_sprite(inter, sprites.pierre_i, MARGE + RES_W, MARGE);
draw_sprite(inter, sprites.viande_i, MARGE + 2*RES_W, MARGE);
switch (type)
{
case MAIRIE: //y'a qu'une option
masked_blit(inter, rep, 0, 0, 0, 0, BOX_W, BOX_H);
masked_blit(sprites.paysant_i, rep, 0, 0, 0, BOX_H-ICON_S, ICON_S, ICON_S); //on met l'icone au bon endroit
textprintf_ex(rep, font, RES_S + (2*MARGE), YTEXT, COL_UI_ACC, -1, "%d", WOOD_PEAS); //on met les quantités de ressources necessaires
textprintf_ex(rep, font, RES_W + RES_S + (2*MARGE), YTEXT, COL_UI_ACC, -1, "%d", ROCK_PEAS);
textprintf_ex(rep, font, 2*RES_W + RES_S + (2*MARGE), YTEXT, COL_UI_ACC, -1, "%d", 0);
break;
case CASERNE: //y'a qu'une optionn (pour l'instant)
masked_blit(inter, rep, 0, 0, 0, 0, BOX_W, BOX_H);
masked_blit(sprites.epee_i, rep, 0, 0, 0, BOX_H-ICON_S, ICON_S, ICON_S); //on met l'icone au bon endroit
textprintf_ex(rep, font, RES_S + (2*MARGE), YTEXT, COL_UI_ACC, -1, "%d", WOOD_SOLD); //on met les quantités de ressources necessaires
textprintf_ex(rep, font, RES_W + RES_S + (2*MARGE), YTEXT, COL_UI_ACC, -1, "%d", ROCK_SOLD);
textprintf_ex(rep, font, 2*RES_W + RES_S + (2*MARGE), YTEXT, COL_UI_ACC, -1, "%d", 0);
break;
case PEASANT: //y'a deux options (pour l'instant)
for (i=0;i<2;i++)
{
masked_blit(inter, rep, 0, 0, 0, i*BOX_H, BOX_W, BOX_H);
textprintf_ex(rep, font, RES_S + (2*MARGE), i*BOX_H + YTEXT, COL_UI_ACC, -1, "%d", (!i)?WOOD_MAINB:WOOD_BARACKS); //on met les quantités de ressources necessaires
textprintf_ex(rep, font, RES_W + RES_S + (2*MARGE), i*BOX_H + YTEXT, COL_UI_ACC, -1, "%d", (!i)?ROCK_MAINB:ROCK_BARACKS);
textprintf_ex(rep, font, 2*RES_W + RES_S + (2*MARGE), i*BOX_H + YTEXT, COL_UI_ACC, -1, "%d", 0);
}
masked_blit(sprites.mairie_i, rep, 0, 0, 0, BOX_H - ICON_S, ICON_S, ICON_S); //on met l'icone au bon endroit
masked_blit(sprites.caserne_i, rep, 0, 0, 0, 2*BOX_H - ICON_S, ICON_S, ICON_S); //on met l'icone au bon endroit
break;
default:
break;
}
destroy_bitmap(inter);
return rep;
}
//charge le tableau de boutons
void load_buttons(Sprites *sprites)
{
int i, j;
BITMAP *inter;
sprites->fond[0] = load_bitmap(MENU_FOND, NULL); ERR_CHARG(sprites->fond[0])
sprites->fond[1] = load_bitmap(PAUSE_FOND, NULL); ERR_CHARG(sprites->fond[1])
//chargement des boutons du menu
inter = load_bitmap(MENU_BUTTON, NULL); ERR_CHARG(inter)
for (i=0;i<2;i++)
{
for (j=0;j<3;j++)
{
sprites->hover_unit[i][j] = create_bitmap(HOVER_W, BOUTON_H);
blit(inter, sprites->hover_unit[i][j], i*HOVER_W, j*BOUTON_H, 0, 0, HOVER_W, BOUTON_H);
}
}
for (i=0;i<3;i++)
{
sprites->buttons[MAIN_MENU][i][0] = create_bitmap(BOUTON_W, BOUTON_H);
rectfill(sprites->buttons[MAIN_MENU][i][0], 0, 0, BOUTON_W, BOUTON_H, MAG);
for (j=0;j<3;j++)
{
sprites->buttons[MAIN_MENU][i][j+1] = create_bitmap(BOUTON_W, BOUTON_H);
blit(inter, sprites->buttons[MAIN_MENU][i][j+1], 2*HOVER_W + i*BOUTON_W, j*BOUTON_H, 0, 0, BOUTON_W, BOUTON_H);
}
}
destroy_bitmap(inter);
//chargement des boutons du menu pause
inter = load_bitmap(PAUSE_BUTTON, NULL); ERR_CHARG(inter)
for (i=0;i<3;i++)
{
for (j=0;j<4;j++)
{
sprites->buttons[PAUSE_MENU][i][j] = create_bitmap(BOUTON_W, BOUTON_H);
blit(inter, sprites->buttons[PAUSE_MENU][i][j], i*BOUTON_W, j*BOUTON_H, 0, 0, BOUTON_W, BOUTON_H);
}
}
destroy_bitmap(inter);
inter = load_bitmap(MAP_BUTTON, NULL); ERR_CHARG(inter)
for (i=0;i<3;i++)
{
for (j=0;j<4;j++)
{
sprites->buttons[MAP_MENU][i][j] = create_bitmap(BOUTON_W, BOUTON_H);
blit(inter, sprites->buttons[MAP_MENU][i][j], i*BOUTON_W, j*BOUTON_H, 0, 0, BOUTON_W, BOUTON_H);
}
}
destroy_bitmap(inter);
inter = load_bitmap(DIFF_BUTTON, NULL); ERR_CHARG(inter)
for (i=0;i<3;i++)
{
for (j=0;j<4;j++)
{
sprites->buttons[DIFF_MENU][i][j] = create_bitmap(BOUTON_W, BOUTON_H);
blit(inter, sprites->buttons[DIFF_MENU][i][j], i*BOUTON_W, j*BOUTON_H, 0, 0, BOUTON_W, BOUTON_H);
}
}
destroy_bitmap(inter);
inter = load_bitmap(SAVE_BUTTON, NULL); ERR_CHARG(inter)
for (i=0;i<3;i++)
{
for (j=0;j<4;j++)
{
sprites->buttons[SAVE_MENU][i][j] = create_bitmap(BOUTON_W, BOUTON_H);
blit(inter, sprites->buttons[SAVE_MENU][i][j], i*BOUTON_W, j*BOUTON_H, 0, 0, BOUTON_W, BOUTON_H);
}
}
destroy_bitmap(inter);
sprites->flags = load_bitmap(FLAGS, NULL); ERR_CHARG(sprites->flags)
inter = load_bitmap(VICTORY_BUTTON, NULL); ERR_CHARG(inter)
for (i=0;i<3;i++)
{
for (j=0;j<2;j++)
{
sprites->v_buttons[i][j] = create_bitmap(BOUTON_W, BOUTON_H);
blit(inter, sprites->v_buttons[i][j], i*BOUTON_W, j*BOUTON_H, 0, 0, BOUTON_W, BOUTON_H);
}
}
destroy_bitmap(inter);
}
//ce sousprogramme sert à charger les bitmaps et sprites
void load_sprites(Sprites *sprites)
{
int i, j;
BITMAP *inter[5]; //des bitmaps intermediaires, quand besoin est
char nom[50];
{ //les unités
//on charge les bitmaps du soldat
inter[0] = load_bitmap(EPEE, NULL);
for (i=0;i<2;i++)
{
for (j=0;j<NUMFRAMES;j++)
{
sprites->sword[i][j] = create_bitmap(COTE, COTE);
blit(inter[0], sprites->sword[i][j], j*COTE, i*COTE, 0, 0, COTE, COTE);
ERR_CHARG(sprites->sword[i][j])
}
}
destroy_bitmap(inter[0]);
//on charge les bitmaps du paysant
inter[0] = load_bitmap(PAYSANT, NULL);
for (i=0;i<3;i++)
{
for (j=0;j<NUMFRAMES;j++)
{
sprites->peasant[i][j] = create_bitmap(COTE, COTE);
blit(inter[0], sprites->peasant[i][j], j*COTE, i*COTE, 0, 0, COTE, COTE);
ERR_CHARG(sprites->peasant[i][j])
}
}
destroy_bitmap(inter[0]);
//on charge les bitmaps de l'ennemi
inter[0] = load_bitmap(MONSTRE, NULL);
for (i=0;i<2;i++)
{
for (j=0;j<NUMFRAMES;j++)
{
sprites->ennemi[i][j] = create_bitmap(COTE, COTE);
blit(inter[0], sprites->ennemi[i][j], j*COTE, i*COTE, 0, 0, COTE, COTE);
ERR_CHARG(sprites->ennemi[i][j])
}
}
destroy_bitmap(inter[0]);
}
{ //les cases
//on charge les bitmaps des tuiles "herbe"
for (i=0;i<15;i++)
{
sprintf(nom, HERBE, RES, i);
sprites->herbe[i] = load_bitmap(nom, NULL); ERR_CHARG(sprites->herbe[i])
}
//les tuile "bridge"
for (i=0;i<4;i++)
{
sprintf(nom, HERBE, RES, i+15);
inter[0] = load_bitmap(nom, NULL); ERR_CHARG(inter[0])
sprites->herbe[i+15] = create_bitmap(COTE, COTE);
blit(sprites->herbe[P_SABLE], sprites->herbe[i+15], 0, 0, 0, 0, COTE, COTE);
masked_blit(inter[0], sprites->herbe[i+15], 0, 0, 0, 0, COTE, COTE);
destroy_bitmap(inter[0]);
}
//on charge les bitmaps des tuiles "eau"
for (i=0;i<13;i++)
{
sprintf(nom, EAU, RES, i);
sprites->eau[i] = load_bitmap(nom, NULL); ERR_CHARG(sprites->eau[i])
}
//on charge les bitmaps des tuiles "montagnes"
for (i=0;i<13;i++)
{
sprintf(nom, MONTAGNE, RES, i);
sprites->montagne[i] = load_bitmap(nom, NULL); ERR_CHARG(sprites->montagne[i])
}
//on charge les bitmaps des tuiles "arbre"
inter[0] = load_bitmap(ARBRE0, NULL); ERR_CHARG(inter[0])
inter[1] = load_bitmap(ARBRE1, NULL); ERR_CHARG(inter[1])
inter[2] = load_bitmap(ARBRE2, NULL); ERR_CHARG(inter[2])
inter[3] = load_bitmap(ARBRE3, NULL); ERR_CHARG(inter[3])
inter[4] = load_bitmap(ARBRE4, NULL); ERR_CHARG(inter[4])
for (i=0;i<5;i++)
{
sprites->arbre[i] = create_bitmap(COTE, COTE);
blit(sprites->herbe[P_HERBE], sprites->arbre[i], 0, 0, 0, 0, COTE, COTE); //on met sur fond d'herbe
masked_blit(inter[i], sprites->arbre[i], 0, 0, 0, 0, COTE, COTE);
destroy_bitmap(inter[i]);
}
//on charge les bitmaps des tuiles "pierre"
inter[0] = load_bitmap(PIERRE0, NULL); ERR_CHARG(inter[0])
for (i=0;i<1;i++)
{
sprites->pierre[i] = create_bitmap(COTE, COTE);
blit(sprites->herbe[P_SABLE], sprites->pierre[i], 0, 0, 0, 0, COTE, COTE); //on met sur fond de sable
masked_blit(inter[i], sprites->pierre[i], 0, 0, 0, 0, COTE, COTE);
destroy_bitmap(inter[i]);
}
//on charge les bitmaps des tuiles "batiment"
for (i=0;i<4;i++)
{
sprintf(nom, MAIRIE0, RES, i);
inter[0] = load_bitmap(nom, NULL); ERR_CHARG(inter[0])
sprites->batiment[0][i] = create_bitmap(COTE, COTE);
blit(sprites->herbe[P_HERBE], sprites->batiment[0][i], 0, 0, 0, 0, COTE, COTE);
masked_blit(inter[0], sprites->batiment[0][i], 0, 0, 0, 0, COTE, COTE);
sprites->batiment[1][i] = create_bitmap(COTE, COTE);
blit(sprites->herbe[P_HERBE], sprites->batiment[1][i], 0, 0, 0, 0, COTE, COTE);
masked_blit(inter[0], sprites->batiment[1][i], 0, 0, 0, 0, COTE, COTE);
destroy_bitmap(inter[0]);
}
//la caserne
for (i=0;i<4;i++)
{
sprintf(nom, CASERNE0, RES, i);
inter[0] = load_bitmap(nom, NULL); ERR_CHARG(inter[0])
sprites->batiment[0][i+4] = create_bitmap(COTE, COTE);
blit(sprites->herbe[P_HERBE], sprites->batiment[0][i+4], 0, 0, 0, 0, COTE, COTE);
masked_blit(inter[0], sprites->batiment[0][i+4], 0, 0, 0, 0, COTE, COTE);
sprites->batiment[1][i+4] = create_bitmap(COTE, COTE);
blit(sprites->herbe[P_HERBE], sprites->batiment[1][i+4], 0, 0, 0, 0, COTE, COTE);
masked_blit(inter[0], sprites->batiment[1][i+4], 0, 0, 0, 0, COTE, COTE);
destroy_bitmap(inter[0]);
}
//on charge les bitmaps des campemants ennemis
for (i=0;i<4;i++)
{
sprintf(nom, CAMP0, RES, i);
inter[0] = load_bitmap(nom, NULL); ERR_CHARG(inter[0])
sprites->camp[0][i] = create_bitmap(COTE, COTE);
blit(sprites->herbe[P_HERBE], sprites->camp[0][i], 0, 0, 0, 0, COTE, COTE);
masked_blit(inter[0], sprites->camp[0][i], 0, 0, 0, 0, COTE, COTE);
destroy_bitmap(inter[0]);
}
}
{ //les autres bitmaps
//on charge le brouillard de guerre
sprites->brouillard = load_bitmap(FOG_TILE, NULL); ERR_CHARG(sprites->brouillard)
sprites->fog = load_bitmap(BROUILLARD, NULL); ERR_CHARG(sprites->fog)
//on charge la bitmap de la souris
sprites->souris = load_bitmap(MOUSE, NULL); ERR_CHARG(sprites->souris)
//on charge les bitmaps des pt'is icones
sprites->bois_i = load_bitmap(BOIS, NULL); ERR_CHARG(sprites->bois_i)
sprites->pierre_i = load_bitmap(PIERRE, NULL); ERR_CHARG(sprites->pierre_i)
sprites->viande_i = load_bitmap(VIANDE, NULL); ERR_CHARG(sprites->viande_i)
sprites->camp_i = load_bitmap(CAMP_ICON, NULL); ERR_CHARG(sprites->camp_i)
sprites->enemy_i = load_bitmap(MANQUE, NULL); ERR_CHARG(sprites->enemy_i)
sprites->pause_i[0] = load_bitmap(PAUSE_ICON, NULL); ERR_CHARG(sprites->pause_i[0])
sprites->pause_i[1] = load_bitmap(PAUSE_ICON_HOVER, NULL); ERR_CHARG(sprites->pause_i[1])
sprites->paysant_i = load_bitmap(PAYSANT_ICON, NULL); ERR_CHARG(sprites->paysant_i)
sprites->epee_i = load_bitmap(EPEE_ICON, NULL); ERR_CHARG(sprites->epee_i)
sprites->mairie_i = load_bitmap(MAIRIE_ICON, NULL); ERR_CHARG(sprites->mairie_i)
sprites->caserne_i = load_bitmap(CASERNE_ICON, NULL); ERR_CHARG(sprites->caserne_i)
//on charge les bitmaps "ignorées" (celles en bas et en bas à gauche pour pouvoir déplacer la map
sprites->ign_l = load_bitmap(IGN_L, NULL); ERR_CHARG(sprites->ign_l)
sprites->ign_d = load_bitmap(IGN_D, NULL); ERR_CHARG(sprites->ign_d)
sprites->c_bar = load_bitmap(C_BAR, NULL); ERR_CHARG(sprites->c_bar)
sprites->r_bar = load_bitmap(UNIT_MENU, NULL); ERR_CHARG(sprites->r_bar)
sprites->info_bar = load_bitmap(INFO_BAR, NULL); ERR_CHARG(sprites->info_bar)
//on charge les petits menus en bas à gauche dans l'ui
for (i=0;i<3;i++)
{
sprites->small_menu[i] = create_menu(*sprites, i);
}
//on charge les fleurs
for (i=0;i<10;i++)
{
sprintf(nom, FLEUR, RES, i);
sprites->flower[i] = load_bitmap(nom, NULL);
}
//chargement des boutons du menu
load_buttons(sprites);
}
}
//fin du fichier