-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
7275 lines (6603 loc) · 321 KB
/
Copy pathMain.cpp
File metadata and controls
7275 lines (6603 loc) · 321 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
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
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//defines
#define SDL_MAIN_USE_CALLBACKS//Pour le main
//includes
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <SDL3_image/SDL_image.h>
#include <SDL3_ttf/SDL_ttf.h>
#include <SDL3_mixer/SDL_mixer.h>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include "Main.h"
#include "State.h"
#include "Entity.h"
#include "Personnages.h"
#include "Player.h"
#include "Database.h"
#include <steam/steam_api.h>
#include "ObjectPool.h"
//CURRENT STUFF TO DO FOR TUESDAY PLAYTEST LISTS
/*
*FINISHED:
* IF I UPGRADE A WEAPON DURING THE SPECIAL ABILITY IT WILL GO BACK TO THE OLD ONE AFTER THE END OF THE CAPACITY INSTEAD OF KEEPING THE ONE BOUGHT
* Posibilité. comme Vampire survivor upgrade pop pup en jeu si on veut upgrade ou attendre
* debut Stage 2
* LES FONTS
* LE UI DU SHOP A REFAIRE.
* La database
*IMPLEMENTATION DATABASE DANS SCORE
*Steamwork API a faire
Menu Avec des etoiles qui bougent
UPDATE LEVELS
Object pool (Bullet)
*TO DO :
*SOUNDS + BONUS DEER LVL FOR VERSION 1.O.0
*Observer a finir
*/
static constexpr Sint32 TILE_SIZE = 32;
static constexpr Sint32 ANIM_ROW_BEGIN = 0;
static constexpr Sint32 ANIM_ROW_END = 0;
static constexpr Sint32 ANIM_COL_BEGIN = 0;
static constexpr Sint32 ANIM_COL_END = 6;
static constexpr Sint32 PRESENT_SIZE = 8;
//Fonction FPS
static Uint32 TimerCallback(void *userdata, SDL_TimerID timerID, Uint32 interval) {
bool *updateFlag = static_cast<bool *>(userdata);
*updateFlag = true;
return interval;
}
//Fonction pour que le tire ce fait chaque 2 sec
static Uint32 ShootCallback(void *userdata, SDL_TimerID timerID, Uint32 interval) {
bool *updateFlag = static_cast<bool *>(userdata);
*updateFlag = true;
SDL_Log(0, "Timer Test");
return interval;
}
Player *player;
Uint8 r = 0, g = 0, b = 0;
class GameApp final {
public:
SDL_Window *window = nullptr;
SDL_Renderer *renderer = nullptr;
SDL_Texture *spritesheet = nullptr;
//Ajout du state
State StateActuel = State::Menu;
float animTimer = 0.0f;
int currentCol = ANIM_COL_BEGIN;
int currentRow = ANIM_ROW_BEGIN;
const float frameDuration = 0.15f;
float colorTime = 0.0f;
//GENERAL
//backgrounds
SDL_Texture *textureBackgroundMenu = nullptr;
SDL_Texture *textureBackground = nullptr;
SDL_Texture *textureBackground2 = nullptr;
SDL_Texture *textureBackground3 = nullptr;
//-> MENU <- Font et Texts
TTF_Font *font = nullptr;
TTF_Font *MenuFont = nullptr;
TTF_Font *ShopFont = nullptr;
TTF_Font *tutoFont = nullptr;//<- juste pour montrer les touches
TTF_Text *tutoText = nullptr;
TTF_Text *tutoText2 = nullptr;
TTF_TextEngine *textEngine = nullptr;
TTF_Text *fpsText = nullptr;
TTF_Text *MenuTitle = nullptr; //Pour rajouter un Titre
TTF_Text *MenuTitle2 = nullptr;
TTF_Text *BoutonCreditsText = nullptr;
SDL_Texture *DeerLogo = nullptr;
//Texture etoiles
SDL_Texture *textureStars = nullptr;
SDL_Texture *textureCerfCarrot = nullptr;
SDL_FRect MenuCerfCarrotPosition={700,550,100,125};
SDL_FRect MenuCerfFraisePosition={1075,675,100,100};
//Texte special
TTF_Font *MenuSpecialFont = nullptr;
TTF_Text *MenuSpecialDraw = nullptr;
//AUDIO
MIX_Mixer *mixer = nullptr;
MIX_Track *trackMusique = nullptr;
MIX_Track *trackGame = nullptr;
MIX_Track *trackSFX = nullptr;
//son pour les boutons
MIX_Audio *audioClick = nullptr;
//Son Bouton Mouvement
MIX_Audio *audioBoutonMouvement = nullptr;
//Son pour tirer
MIX_Audio *audioShoot = nullptr;
MIX_Track *trackShoot = nullptr;
//Pour ennemi mort
MIX_Audio *audioEnemyDeath = nullptr;
MIX_Track *trackEnemyDeath = nullptr;
//Quand joueur ce fait toucher (damage)
MIX_Audio *audioPlayerHit= nullptr;
MIX_Track *trackPlayerHit = nullptr;
//creation des boutons pour le menu
SDL_FRect BoutonPlay = {760, 600, 400, 80};
bool bClickedOnPlay = false;
bool bClickedOnQuit = false;
bool bClickedOnScore = false;
bool bClickedOnShop = false;
SDL_FRect BoutonScore = {785, 700, 350, 70};
SDL_FRect BoutonShop = {810, 790, 300, 60};
SDL_FRect BoutonQuit = {835, 870, 250, 50};
SDL_FRect BoutonCredits = {860, 940, 200, 40};
//Pour taille de police
TTF_Font *StartFont = nullptr;
TTF_Font *ScoreFont = nullptr;
TTF_Font *QuitFont = nullptr;
TTF_Font *CreditsFont = nullptr;
TTF_Text *TextStart = nullptr;
TTF_Text *TextQuit = nullptr;
TTF_Text *TextScore = nullptr; //Pour les boutons Start Quit et TBh
TTF_Text *TextShop = nullptr;
TTF_Text *TextQuitReturnMenu = nullptr;
// -> ChoixNiveau <-
//Font titre meme que les autres
TTF_Font *ChoixNiveauFont = nullptr;
TTF_Font *DialogueFont = nullptr;
TTF_Text *ChoixNiveauTitre = nullptr;
TTF_Text *ChoixNiveau1Text = nullptr;
TTF_Text *ChoixNiveau2Text = nullptr;
TTF_Text *ChoixNiveau3Text = nullptr;
TTF_Text *ChoixBonusText = nullptr;
//Texture qui montre un preview des niveaux
SDL_Texture *textureStage1Preview = nullptr;
SDL_Texture *textureStage2Preview = nullptr;
SDL_Texture *textureStage3Preview = nullptr;
//text pour dire si accecible ou non
TTF_Text *StageLocked = nullptr;
TTF_Text *StageAvailable = nullptr;
SDL_FRect BoutonChoixNiveau1 ={200, 550, 300,300};
SDL_FRect BoutonChoixNiveau2 ={800, 550, 300,300};
SDL_FRect BoutonChoixNiveau3 ={1400, 550, 300,300};
SDL_FRect BoutonChoixBonus = {750 , 1000, 400, 60};
// -> BONUS <-
TTF_Text *ChoixBonusTitre = nullptr;
TTF_Text *ChoixBonus1Text = nullptr;
TTF_Text *ChoixBonus2Text = nullptr;
SDL_FRect ChoixTextureCerf={1100,950,100,120};
SDL_FRect BoutonChoixBonus1 ={300, 550, 300,300};
SDL_FRect BoutonChoixBonus2 ={1400, 550, 300,300};
//Texture qui montre un preview des niveau Bonus
SDL_Texture *textureBonus1Preview = nullptr;
SDL_Texture *textureBonus2Preview = nullptr;
// -> INTRONIVEAU 1 / 2 / 3 <-
SDL_Texture *HumainTexture = nullptr;
SDL_Texture *DeerTexture = nullptr;
int indexMessageIntroNiveau1 = 0;
int indexMessageIntroNiveau2 = 0;
int indexMessageIntroNiveau3 = 0;
static const int NB_MESSAGES_IntroNiveau1 = 3;
const char *phrasesIntroNiveau1[NB_MESSAGES_IntroNiveau1] = {
"Human: We must defend against this invasion!",
"Deer: Your small planet will make a fine addition to our empire.",
"Human: We will free our world!"
};
static const int NB_MESSAGES_IntroNiveau2 = 4;
const char *phrasesIntroNiveau2[NB_MESSAGES_IntroNiveau2] = {
"Human: Our defenses are holding... for now.",
"Human: We must strike where they least expect it.",
"Human: Their mages hide in towers... an easy target.",
"Deer: Come... we are waiting for you."
};
static const int NB_MESSAGES_IntroNiveau3 = 4;
const char *phrasesIntroNiveau3[NB_MESSAGES_IntroNiveau3] = {
"Human: Those mages are no more!",
"Deer: When the flames rise, only the strong will survive.",
"Human: The fire of hate gives way to the ash of grief",
"Deer: I am the fire!"
};
TTF_Text* texteIntroCerfEtHUmain = nullptr; // Le texte qui sera affiché
// -> GAME <- Text et Fonts
TTF_Font *InventoryFont = nullptr; // Game + Shop
TTF_Text *InventoryText = nullptr; // Game + Shop
SDL_FRect MeatInventory ={1700.0f, 10.0f, 60.0f,60.0f};
SDL_Texture *MeatInventoryTexture = nullptr;
SDL_Texture *ScoreUI = nullptr;
SDL_Texture *HealUI = nullptr;
SDL_FRect scoreSize = { 1570.0f, 975.0f, 300.0f, 60.0f };
SDL_FRect healSize = {50.0f,1000.0f,250.0f,100.0f};
SDL_FRect shieldSize = {150.0f, 1000, 250, 100 };
TTF_Text *dynamicscoreText = nullptr;
TTF_Font *dynamicscoreFont = nullptr;
TTF_Text *dynamicPlayerHeal = nullptr;
TTF_Font *dynamicPlayerHealFont = nullptr;
TTF_Font *competenceSpecialFont = nullptr;
TTF_Text *competenceSpecialText = nullptr;
TTF_Text *competenceSpecialText2 = nullptr;// Gris de base
//Font pour le Shield HP amount
TTF_Font *dynamicShieldHPFont = nullptr;
TTF_Text *dynamicShieldHPText = nullptr;
SDL_Texture *ShieldUI = nullptr;
//Texture fraise
SDL_Texture* textureStrawberry = nullptr;
//Texture Cerf
SDL_Texture *textureCerf = nullptr;
//Texture des differents Bullets
SDL_Texture *textureBulletNormal = nullptr;
SDL_Texture *textureBulletFire = nullptr;
SDL_Texture *textureBulletIce = nullptr;
SDL_Texture *textureBulletGold = nullptr;
//Texture du meat
SDL_Texture *textureMeat = nullptr;
//Texture boss
SDL_Texture *textureBossStage_1_2 = nullptr;
//Meteor Texture
SDL_Texture *textureMeteor = nullptr;
//Texture Cerf Mage
SDL_Texture *textureCerfMage = nullptr;
//Texture Cerf MageIce
SDL_Texture *textureCerfMageIce = nullptr;
//Texture Cerf Healer
SDL_Texture *textureCerfHealer = nullptr;
//Texture Player Ship
SDL_Texture *texturePlayerShip = nullptr;
//Texture missile
SDL_Texture *textureMissile = nullptr;
//Texture Laser
SDL_Texture *textureLaser = nullptr;
//Texture Shields
SDL_Texture *textureSmallShield = nullptr;
SDL_Texture *textureMediumShield = nullptr;
SDL_Texture *textureLargeShield = nullptr;
//Texture HP Boost icon
SDL_Texture *textureHpBoost = nullptr;
//Texture Missile Joueur
SDL_Texture *textureSmallMissilePlayer = nullptr;
SDL_Texture *textureMediumMissilePlayer = nullptr;
SDL_Texture *textureLargeMissilePlayer = nullptr;
//texture terre
SDL_Texture *textureTerre = nullptr;
SDL_FRect planetSize{825,300,275,275};
//Texture IceCube
SDL_Texture *textureIceCube = nullptr;
//Texture Snowflake
SDL_Texture *textureSnowflake = nullptr;
//Texture Cerf Melee
SDL_Texture *textureCerfMelee = nullptr;
//Texture Barricade
//Style1 (Mauve)
SDL_Texture *textureBarricadeStyle1 = nullptr;
//Style2 (Bleu)
SDL_Texture *textureBarricadeStyle2 = nullptr;
//Style3 (Rouge)
SDL_Texture *textureBarricadeStyle3 = nullptr;
// -> WINSCREEN <-
TTF_Font *WinScreenFont = nullptr;
TTF_Font *WinScreenSousFont = nullptr;
TTF_Text *WinScreenTitleText = nullptr;
TTF_Text *WinScreenSousTitleText = nullptr;
TTF_Text *WinScreenReturnMenuText = nullptr;
SDL_FRect BoutonWinReturnMenu = {825,700,300,100};
// -> DEATHSCREEN <-
float deathFadeAlpha = 0.0f;
bool bIsResetDone = false;
TTF_Font *DeathScreenFont = nullptr;
TTF_Font *DeathScreenSousFont = nullptr;
TTF_Text *DeathScreenTitleText = nullptr;
TTF_Text *DeathScreenSousTitleText = nullptr;
TTF_Text *DeathScreenReturnMenuText = nullptr;
SDL_FRect BoutonDeathReturnMenu = {825,700,300,100};
// -> PAUSE <-
SDL_FRect BoutonResume = {850,490,300,80};
SDL_FRect BoutonGoShop = {850, 600, 300, 80};
SDL_FRect BoutonReturnMenu = {850,710,300,80};
TTF_Font *FontPause = nullptr;
TTF_Text *TextResume = nullptr;
TTF_Text *TextPauseGoShop = nullptr;
TTF_Text *TextReturnMenuPause = nullptr;
// -> Score <- Text et Fonts
TTF_Font *ReturnBoutonFont = nullptr;
SDL_FRect BoutonQuitRetourMenu = {1600, 900, 200, 100};
TTF_Text *ScoreMenuText = nullptr;
// -> Shop <- Text et Fonts
//Fonts
TTF_Font *BoutonUpgradeFont = nullptr;
TTF_Font *Arme_Shield_DescriptionFont = nullptr;
TTF_Font *currentMeatShopFont = nullptr;
//Texts
TTF_Text *BoutonUpgradeText = nullptr;
TTF_Text *BoutonMissileUpgradeText = nullptr;
TTF_Text *BoutonShieldUpgradeText = nullptr;
TTF_Text *BoutonHpBoostText = nullptr;
//Text armes
TTF_Text *ArmeFireText = nullptr;
TTF_Text *ArmeIceText = nullptr;
TTF_Text *ArmeTBDText = nullptr;
//Text shields
TTF_Text *ShieldSmallText = nullptr;
TTF_Text *ShieldMediumText = nullptr;
TTF_Text *ShieldLargeText = nullptr;
//Pour faciliter le joueur a savoir si il peut en acheter un ou non une arme
TTF_Text *statusFire = nullptr;
TTF_Text *statusIce = nullptr;
TTF_Text *statusTbd = nullptr;
//Pour faciliter le joueur a savoir si il peut en acheter un ou non un shield
TTF_Text *statusSmallShield = nullptr;
TTF_Text *statusMediumShield = nullptr;
TTF_Text *statusLargeShield = nullptr;
TTF_Text *currentMeatShop = nullptr;//savoir combien de meat on a en ce moment
TTF_Text *resumeGameShopText = nullptr;
//rectangle
SDL_FRect MeatInventoryShop ={180.0f, 80.0f, 100.0f,100.0f};
SDL_FRect BoutonResumeGameShop = {1350.0f, 900.0f, 200.0f,100.0f};
//Boutons
SDL_FRect BoutonUpgrade = {735, 800, 125, 100};
SDL_FRect BoutonMissileUpgrade = {935,800,125,100};
SDL_FRect BoutonShieldUpgrade = {1135, 800, 125, 100};
SDL_FRect BoutonHpUpgrade = {1335, 800, 125, 100};
//PopUp Boutons
SDL_FRect BoutonUpgradePopUp = {435, 700, 125, 100};
SDL_FRect BoutonMissileUpgradePopUp = {635,700,125,100};
SDL_FRect BoutonShieldUpgradePopUp = {1235, 700, 125, 100};
SDL_FRect BoutonHpUpgradePopUp = {1435, 700, 125, 100};
TTF_Text *ShopMenuText = nullptr;
// -> Credits <- Text et Fonts
TTF_Font *Credits_Shop_Score_WinScreen_DeathScreen_ChoixNiveau_ChoixBonus_TitleFont = nullptr;
TTF_Font *CreditsNameFont = nullptr;
TTF_Font *CreditsRoleFont = nullptr;
TTF_Text *CreditsMenuText = nullptr;
TTF_Text *CreditsName1Text = nullptr;
TTF_Text *CreditsName2Text = nullptr;
TTF_Text *CreditsName3Text = nullptr;
TTF_Text *CreditsRoleText = nullptr;
TTF_Text *CreditsRoleText2 = nullptr;
TTF_Text *CreditsRoleText3 = nullptr;
// -> UpgradePopUp <- Text et Fonts
TTF_Font *fontWaitPopUp = nullptr;
TTF_Font *fontPricePopUp = nullptr;
TTF_Font *fontSousTitrePopUp = nullptr;
TTF_Text *textSousTitreArmePopUp = nullptr;
TTF_Text *textSousTitreSupportPopUp = nullptr;
SDL_FRect BoutonWaitPopUp = {1600.0f, 900.0f, 200.0f,100.0f};
TTF_Text *textWaitPopUp = nullptr;
TTF_Text *textPrix1 = nullptr;//10
TTF_Text *textPrix2 = nullptr;//50
TTF_Text *textPrix3 = nullptr;//250
SDL_FRect PopUpMeat = {810,370,140,140};
TTF_Font *currentMeatPopUPFont = nullptr;
TTF_Text *currentMeatPopUp = nullptr;
// -> TOUCHE CLAVIER PATTERN COMMAND<-
Player* player = nullptr;
std::map<SDL_Scancode, Command*> keyBindings;
std::map<SDL_Scancode, Command*> keyReleaseBindings;
std::vector<float> frameTimes;
const size_t MAX_SAMPLES = 100;
bool shouldUpdateText = false;
SDL_TimerID fpsTimerID;
SDL_TimerID ShootTimerID;
float currentFPS = 0.0f;
float deltaTime = 0.f;
// La liste de toutes les entités du jeu
std::vector<Entity *> entities;
//PATRON DE CONCEPTION SINGLETON
//Point unique en avant du constructeur qui est devenue private
static GameApp &GetInstance() {
static GameApp instance;
return instance;
}
GameApp(GameApp const &) = delete;
void operator=(GameApp const &) = delete;
//CONTROLLER
SDL_Gamepad* gameController = nullptr; // Manette
const Sint16 DEADZONE = 8000; // Zone morte du gamepad
//Boutons gbutton
int selectedButtonMenu = 0;
int selectedButtonChoixNiveau = 0;
int selectedButtonChoixBonus = 0;
int selectedButtonScore = 0;
int selectedButtonWin = 0;
int selectedButtonDeath = 0;
int selectedButtonShop = 0;
int selectedButtonPopUp = 0;
int selectedButtonCredits = 0;
int selectedButtonPause = 0;
//Point Meat
int currentMeat = 0;
int meatGrab = 1;
//Meat Rendu
int lastMeat = -1;
//Point HP
int currentHP = 150;
int lastHP = 1;
//Point Shield
int lastShield = 1;
//Pour SHOP
//Pour les armes
int currentWeaponLevel = 0;
int globalWeaponLevel = 0;
//Pour Les shields
int currentShieldLevel = 0;
int globalShieldLevel = 0;
//Pour Le HpBoost
int currentHpBoostLevel = 0;
int globalHpBoostLevel = 0;
//Pour le Missile Player
int currentMissilePlayerLevel = 0;
int globalMissilePlayerLevel = 0;
//POUR LES FONCTIONS DES WAVES
int currentWave = 0;
WaveType currentWaveType; //L'enum de state
bool waveInProgress = false;
float survivalTimer = 0.0f; // pour la vague survivor
float survivalDuration = 15.0f;
float meteorSpawnTimer = 0.0f;//La vitesse qu'une meteorite spawn
//Pour faire attendre un peu entre chaque vagues
bool isTransitioning = false;
float transitionTimer = 0.0f;
const float TRANSITION_DURATION = 2.0f; //2 seconde entre transition
//POUR TEXTE ET FONDU DES WAVES
TTF_Font *waveDynamicNumberFont = nullptr;
TTF_Font *waveDynamicWaveTypeFont = nullptr;
TTF_Text *waveDynamicNumberText = nullptr;
TTF_Text *waveDynamicWaveTypeText = nullptr;
TTF_Text *waveDynamicWaveType2Text = nullptr;
//BOOL POUR DIRE SI FAUT METTRE OU PAS METTRE LE UI DES WAVES
bool showWaveUI = false;
//Fondu Des Waves
float waveFadeAlpha = 0.0f;
//Pour une petite opaciter rouge si joueur ce fait toucher par une fraise ou ennemie
bool bIsDamageUI = false;
float damageFlashTimer = 0.0f;
const float damageFlashDuration = 0.3f;
//bool pour savoir si un stage est complete (Si complete on peut appuyer sur le 2eme bouton pour le stage 2)
bool bStage1Completed = false;//quand stage 1 est fini
bool bStage2Completed = false;//quand stage 2 est fini
bool bStage3Completed = false;//quand stage 3 est fini
int currentStage = 1;
//Pour les stages challenges bonus
int currentStageBonus = 1;
//pour atteindre le dernier seuil attein (Pour les weapons upgrade fix du bug)
int lastPopupMeatThreshold = -1;
//pour un fondu lorsque le UpgradePopup apparait
float popupFadeAlpha = 0.0f;
bool bPopupFadeIn = true;
//pour faire un fondu out
bool bPopupFadeOut = false;
State nextStateAfterFadeOut = State::Game; //retour au game apres Le fade
//LA DATA BASE
DataBaseStage database;
bool bDatabaseInitialized = false;
std::vector<ScoreRecord> highScores;
//Les Etoiles randoms du menu
std::vector<Stars*> randomStars;
//Les etoiles randoms dans game
std::vector<GameStars*> randomGameStars;
private:
//Score Lorsque Cerf Mort
int currentScore = 0;
int scorePerDeerKilled = 250;
//SCORE DU RENDER JEU
int lastScore = -1;
//SUCCESS STEAM
int totalEnemiesKilled = 0; // pour ACH_TRAVEL_FAR_ACCUM
GameApp() //Constructeur
{
SteamErrMsg errMsg;
if (SteamAPI_InitEx(&errMsg) != k_ESteamAPIInitResult_OK) {
SDL_Log("Steam API failed to initialize: %s", errMsg);
} else {
SDL_Log("Steam initialized! AppID: %u", SteamUtils()->GetAppID());
}
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_STEAM, "0");
//SDL_SetHint(SDL_HINT_JOYSTICK_WGI, "0");
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI, "1");
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO) == false) {
SDL_LogCritical(1, "SDL failed to initialize! %s", SDL_GetError());
abort();
}
window = SDL_CreateWindow("Deer Invaders", 1280, 720, 0);
if (window == nullptr) {
SDL_LogCritical(1, "SDL failed to create window! %s", SDL_GetError());
abort();
}
//Mon renderer
renderer = SDL_CreateRenderer(window, nullptr);
//SDL_SetRenderVSync(renderer, 1);
if (renderer == nullptr) {
SDL_LogCritical(1, "SDL failed to create renderer! %s", SDL_GetError());
abort();
}
//Le fullscreen renderer qui s'adapte entre WindowMode et FullScreen
SDL_SetRenderLogicalPresentation(renderer, 1920, 1080, SDL_LOGICAL_PRESENTATION_LETTERBOX); //4 parameters
spritesheet = IMG_LoadTexture(renderer, "assets/spritesheet.png");
if (spritesheet == nullptr) {
SDL_LogWarn(0, "SDL_image failed to load texture '%s'! %s", "assets/spritesheet.png",
SDL_GetError());
}
SDL_SetTextureScaleMode(spritesheet, SDL_SCALEMODE_NEAREST);
if (TTF_Init() == false) {
SDL_LogCritical(1, "SDL_ttf failed to initialize! %s", SDL_GetError());
abort();
}
if (!MIX_Init()) {
SDL_LogCritical(1, "SDL_mixer failed to initialize! %s", SDL_GetError());
abort();
}
mixer = MIX_CreateMixerDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, nullptr);
if (!mixer) {
SDL_LogWarn(0, "Couldn't create mixer: %s", SDL_GetError());
}
// Musique Menu
char *pathMenu = nullptr;
SDL_asprintf(&pathMenu, "assets/main_menu_-_dark.mp3", SDL_GetBasePath());
MIX_Audio *audioMenu = MIX_LoadAudio(mixer, pathMenu, false);
if (audioMenu == nullptr) {
SDL_Log("impossible de charger audio de audioMenu%s", SDL_GetError());
} else {
SDL_Log("audio is working");
}
SDL_free(pathMenu);
if (audioMenu) {
trackMusique = MIX_CreateTrack(mixer);
MIX_SetTrackAudio(trackMusique, audioMenu);
MIX_PlayTrack(trackMusique, -1); //loop infini
}
//Musique game
char *pathGame = nullptr;
SDL_asprintf(&pathGame, "assets/through space.ogg", SDL_GetBasePath());
MIX_Audio *audioGame = MIX_LoadAudio(mixer, pathGame, false);
if (audioGame == nullptr) {
SDL_Log("Impossible de charger audio de audioGame%s", SDL_GetError());
} else {
SDL_Log("audioGame is working");
}
if (audioGame) {
trackGame = MIX_CreateTrack(mixer);
MIX_SetTrackAudio(trackGame, audioGame);
}
//Click menu SOUND
char *pathClick = nullptr;
SDL_asprintf(&pathClick, "assets/Menu_UIClickedSound.wav", SDL_GetBasePath());
audioClick = MIX_LoadAudio(mixer, pathClick, false);
SDL_free(pathClick); // Toujours libere le chemin after usage
if (audioClick == nullptr) {
SDL_LogWarn(0, "Echec du chargement du son de clic: %s", SDL_GetError());
} else {
// sfx
trackSFX = MIX_CreateTrack(mixer);
MIX_SetTrackAudio(trackSFX, audioClick);
}
//Son Mouvement Boutons
char *pathBoutonMouvement = nullptr;
SDL_asprintf(&pathBoutonMouvement, "assets/MenuMouvement.wav", SDL_GetBasePath());
audioBoutonMouvement = MIX_LoadAudio(mixer, pathBoutonMouvement, false);
SDL_free(pathBoutonMouvement);
if (audioBoutonMouvement == nullptr) {
SDL_LogWarn(0, "failed ot load audioBoutonMouvement", SDL_GetError());
}
else {
trackSFX = MIX_CreateTrack(mixer);
MIX_SetTrackAudio(trackSFX, audioBoutonMouvement);
}
// Son tir
char *pathShoot = nullptr;
SDL_asprintf(&pathShoot, "assets/PlayerShoot.wav", SDL_GetBasePath());
audioShoot = MIX_LoadAudio(mixer, pathShoot, false);
SDL_free(pathShoot);
if (audioShoot) {
trackShoot = MIX_CreateTrack(mixer);
MIX_SetTrackAudio(trackShoot, audioShoot);
} else {
SDL_LogWarn(0, "Echec chargement son de tir: %s", SDL_GetError());
}
//Son Enemy Mort
char *pathDeath = nullptr;
SDL_asprintf(&pathDeath, "assets/EnemyDeath.ogg", SDL_GetBasePath());
audioEnemyDeath = MIX_LoadAudio(mixer, pathDeath, false);
SDL_free(pathDeath);
if (audioEnemyDeath) {
trackEnemyDeath = MIX_CreateTrack(mixer);
MIX_SetTrackAudio(trackEnemyDeath, audioEnemyDeath);
} else {
SDL_LogWarn(0, "Echec chargement son de mort ennemi: %s", SDL_GetError());
}
//Son Joueur quand toucher/mort
char *pathPlayerHit = nullptr;
SDL_asprintf(&pathPlayerHit, "assets/PlayerHit.wav", SDL_GetBasePath());
audioPlayerHit = MIX_LoadAudio(mixer, pathPlayerHit, false);
SDL_free(pathPlayerHit);
if (audioPlayerHit == nullptr) {
SDL_LogWarn(0, "failed ot load audioPlayerHit", SDL_GetError());
}
else {
trackPlayerHit = MIX_CreateTrack(mixer);
MIX_SetTrackAudio(trackPlayerHit, audioPlayerHit);
}
//Pour Le Logo
DeerLogo = IMG_LoadTexture(renderer, "assets/Deer_Logo.png");
if (DeerLogo == nullptr) {
SDL_LogWarn(0, "SDL_Image failed to load DeerLogo", "assets/Deer_Logo.png", SDL_GetError());
}
SDL_SetTextureScaleMode(DeerLogo, SDL_SCALEMODE_NEAREST);
textureStars = IMG_LoadTexture(renderer, "assets/textureStars.png");
if (textureStars == nullptr) {
SDL_LogWarn(0, "failed to load textureStars texture", SDL_GetError());
}
ScoreUI = IMG_LoadTexture(renderer, "assets/ScoreUICompress.png");
if (ScoreUI == nullptr) {
SDL_LogWarn(0, "SDL_IMAGE FAILED TO LOAD TEXTURE ", "assets/spritesheet.png", SDL_GetError());
}
SDL_SetTextureScaleMode(ScoreUI, SDL_SCALEMODE_NEAREST);
HealUI = IMG_LoadTexture(renderer, "assets/HealUI.png");
if (HealUI == nullptr) {
SDL_LogWarn(0, "SDL_IMAGE FAILED TO LOAD TEXTURE ", "assets/spritesheet.png", SDL_GetError());
}
SDL_SetTextureScaleMode(HealUI, SDL_SCALEMODE_NEAREST);
textEngine = TTF_CreateRendererTextEngine(renderer);
if (textEngine == nullptr) {
SDL_LogCritical(1, "SDL_ttf failed to create text engine!! %s", SDL_GetError());
abort();
}
font = TTF_OpenFont("assets/font.ttf", 24);
if (font == nullptr) {
SDL_LogWarn(0, "SDL_ttf failed to load font '%s'! %s", "assets/font.ttf", SDL_GetError());
}
fpsText = TTF_CreateText(textEngine, font, "FPS: 0", 20);
if (fpsText == nullptr) {
SDL_LogWarn(0, "SDL_ttf failed to create text '%s'! %s", "FPS: 0", SDL_GetError());
}
if (TTF_SetTextColor(fpsText, 255, 255, 255, 255) == false) {
SDL_LogWarn(0, "SDL_ttf failed to set text color to (255, 255, 255, 255)! %s", SDL_GetError());
}
//Le font du Titre
MenuFont = TTF_OpenFont("assets/SnowDeer.ttf", 120);
if (MenuFont == nullptr) {
SDL_LogWarn(0, "SDL_ttf failed to load font '%s'! %s", "assets/New Space.ttf", SDL_GetError());
}
//Rajoue du menu
MenuTitle = TTF_CreateText(textEngine, MenuFont, "Deer", 25);
if (MenuTitle == nullptr) {
SDL_LogWarn(0, "Le menu n'a pas chargé : TTF", SDL_GetError());
}
if (TTF_SetTextColor(MenuTitle, 186, 135, 89, 255) == false) {
SDL_LogWarn(0, "SDL_ttf failed to set text color to (255, 255, 255, 255)! %s", SDL_GetError());
}
MenuTitle2 = TTF_CreateText(textEngine, MenuFont, "invadeRs", 25);
if (MenuTitle2 == nullptr) {
SDL_LogWarn(0, "Le menu2 n'a pas chargé : TTF", SDL_GetError());
}
if (TTF_SetTextColor(MenuTitle2, 255, 255, 255, 255) == false) {
SDL_LogWarn(0, "SDL_ttf failed to set text color to (255, 255, 255, 255)! %s", SDL_GetError());
}
//MENU
//special font
MenuSpecialFont = TTF_OpenFont("assets/Space.ttf", 120);
if (MenuSpecialFont == nullptr) {
SDL_LogWarn(0, "SDL_ttf failed to put the font", SDL_GetError());
}
MenuSpecialDraw = TTF_CreateText(textEngine, MenuSpecialFont, "abcdefghigklmnopqrstuv", 20);
ReturnBoutonFont = TTF_OpenFont("assets/Cosmo Corner.ttf", 44);
ShopFont = TTF_OpenFont("assets/Cosmo Corner.ttf", 50);
StartFont = TTF_OpenFont("assets/Cosmo Corner.ttf", 75);
ScoreFont = TTF_OpenFont("assets/Cosmo Corner.ttf", 60);
QuitFont = TTF_OpenFont("assets/Cosmo Corner.ttf", 40);
CreditsFont = TTF_OpenFont("assets/Cosmo Corner.ttf", 30);
DialogueFont = TTF_OpenFont ("assets/ARCADE.ttf",40);
if (ReturnBoutonFont == nullptr) {
SDL_LogWarn(0, "SDL_ttf failed to set text color to (255, 255, 255, 255)! %s", SDL_GetError());
}
TextStart = TTF_CreateText(textEngine, StartFont, "Start", 25);
if (MenuSpecialDraw == nullptr) {
SDL_LogWarn(0, "Les boutons du menu n'a pas chargé : TTF", SDL_GetError());
}
TextQuit = TTF_CreateText(textEngine, QuitFont, "Quit", 25);
if (TextQuit == nullptr) {
SDL_LogWarn(0, "Les boutons du menu n'a pas chargé : TTF", SDL_GetError());
}
TextScore = TTF_CreateText(textEngine, ScoreFont, "Score", 25);
if (TextScore == nullptr) {
SDL_LogWarn(0, "Les boutons du menu n'a pas chargé : TTF", SDL_GetError());
}
TextShop = TTF_CreateText(textEngine, ShopFont, "Shop", 25);
if (TextShop == nullptr) {
SDL_LogWarn(0, "Le text du bouton Shop n'a pas fonctionner", SDL_GetError());
}
BoutonUpgradeFont = TTF_OpenFont("assets/ARCADE.ttf", 23);
BoutonUpgradeText = TTF_CreateText(textEngine, BoutonUpgradeFont, "Bullet \nUpgrade", 25);
if (TTF_SetTextColor(BoutonUpgradeText, 255, 255, 255, 255) == false) {
SDL_LogWarn(0, "Couleur du bouton amelioration n'a pas fonctionné", SDL_GetError());
}
BoutonMissileUpgradeText = TTF_CreateText(textEngine, BoutonUpgradeFont, "Missile \nUpgrade", 25);
if (TTF_SetTextColor(BoutonMissileUpgradeText,255,255,255,255) == false) {
SDL_LogWarn(0,"failed to load text color of BoutonMissileUpgradeText", SDL_GetError());
}
BoutonShieldUpgradeText = TTF_CreateText(textEngine, BoutonUpgradeFont, "Shield \nUpgrade", 25);
if (TTF_SetTextColor(BoutonShieldUpgradeText, 255, 255, 255, 255) == false) {
SDL_LogWarn(0, "Couleur de Bouton HP Upgrade", SDL_GetError());
}
BoutonHpBoostText = TTF_CreateText(textEngine, BoutonUpgradeFont, "HP \nBoost" , 25);
BoutonCreditsText = TTF_CreateText(textEngine, CreditsFont, "Credits", 25);
if (TTF_SetTextColor(TextShop, 150, 100, 255, 255) == false) {
SDL_LogWarn(0, "La couleur de TextShop n'a pas fonctionné", SDL_GetError());
}
if (TTF_SetTextColor(TextStart, 0, 255, 255, 255) == false) {
SDL_LogWarn(0, "SDL_ttf failed to set text color to (255, 255, 255, 255)! %s", SDL_GetError());
}
if (TTF_SetTextColor(TextQuit, 255, 80, 255, 255) == false) {
SDL_LogWarn(0, "SDL_ttf failed to set text color to (255, 255, 255, 255)! %s", SDL_GetError());
}
if (TTF_SetTextColor(TextScore, 80, 150, 255, 255) == false) {
SDL_LogWarn(0, "SDL_ttf failed to set text color to (255, 255, 255, 255)! %s", SDL_GetError());
}
if (TTF_SetTextColor(BoutonCreditsText, 200,150,200,255) == false) {
SDL_LogWarn(0, "SDL_ttf failed to set text color to (255, 255, 255, 255)! %s", SDL_GetError());
}
TextQuitReturnMenu = TTF_CreateText(textEngine, ReturnBoutonFont, "Return \nMenu", 25);
if (TextQuitReturnMenu == nullptr) {
SDL_LogWarn(0, "SDL_TTF failed to set the return Menu text)! %s", SDL_GetError());
}
if (TTF_SetTextColor(TextQuitReturnMenu, 0, 0, 0, 255) == false) {
SDL_LogWarn(0, "SDL_ttf failed to set color TextQuitScore %s", SDL_GetError());
}
tutoFont = TTF_OpenFont("assets/Cosmo Corner.ttf", 40);
tutoText = TTF_CreateText(textEngine, tutoFont, " Keyboard : \n Pause : P \n FullScreen : F \n Special Ability : E \n Shoot : SpaceBar ", 125);
if (tutoText == nullptr) {
SDL_LogWarn(0, "SDL_TTF failed to set the tutotext", SDL_GetError());
}
if (TTF_SetTextColor(tutoText, 255, 255, 255, 255) == false) {
SDL_LogWarn(0,"SDL_ttf failed to set the tutotext color", SDL_GetError());
}
tutoText2 = TTF_CreateText(textEngine, tutoFont, " Gamepad : \n Pause : Start \n FullScreen : Back \n Special Ability : X \n Shoot : RT ", 125);
if (tutoText2 == nullptr) {
SDL_LogWarn(0, "SDL_TTF failed to set the tutotext", SDL_GetError());
}
if (TTF_SetTextColor(tutoText2, 255, 255, 255, 255) == false) {
SDL_LogWarn(0,"SDL_ttf failed to set the tutotext color", SDL_GetError());
}
//AUDIO MENU
//FONT POUR TITRE SCORE, SHOP, CREDITS, DeathScreen
Credits_Shop_Score_WinScreen_DeathScreen_ChoixNiveau_ChoixBonus_TitleFont = TTF_OpenFont("assets/Cosmo Corner.ttf", 108);
// CHOIX NIVEAU
ChoixNiveauFont = TTF_OpenFont("assets/Cosmo Corner.ttf", 30);
if (ChoixNiveauFont == nullptr) {
SDL_LogWarn(0, "SDL_ttf failed to set the font", SDL_GetError());
}
ChoixNiveauTitre = TTF_CreateText(textEngine, Credits_Shop_Score_WinScreen_DeathScreen_ChoixNiveau_ChoixBonus_TitleFont, "Choose Your Stage", 25);
ChoixNiveau1Text = TTF_CreateText(textEngine, ChoixNiveauFont, "Defend Home", 25);
ChoixNiveau2Text = TTF_CreateText(textEngine, ChoixNiveauFont, "Invasion Deer Mages", 25);
ChoixNiveau3Text = TTF_CreateText(textEngine, ChoixNiveauFont, "Trial by fire", 25);
ChoixBonusText = TTF_CreateText(textEngine, ChoixNiveauFont, "Bonus", 25);
StageAvailable = TTF_CreateText(textEngine, ChoixNiveauFont, "Available", 25);
StageLocked = TTF_CreateText(textEngine, ChoixNiveauFont, "Locked", 25);
//Texture des previews dans ChoixNiveau
textureStage1Preview = IMG_LoadTexture(renderer,"assets/Stage1Preview.png");
if (textureStage1Preview == nullptr) {
SDL_LogWarn(0, "IMG_LoadTexture failed to load textureStage1Preview", SDL_GetError());
}
textureStage2Preview = IMG_LoadTexture(renderer,"assets/Stage2Preview.png");
if (textureStage2Preview == nullptr) {
SDL_LogWarn(0, "IMG_LoadTexture failed to load textureStage2Preview", SDL_GetError());
}
textureStage3Preview = IMG_LoadTexture(renderer,"assets/Stage3Preview.png");
if (textureStage3Preview == nullptr) {
SDL_LogWarn(0,"failed to load the image textureStage3Preview");
}
// CHOIX BONUS
ChoixBonusTitre = TTF_CreateText(textEngine, Credits_Shop_Score_WinScreen_DeathScreen_ChoixNiveau_ChoixBonus_TitleFont, "Bonus Stages", 25);
if (ChoixBonusTitre == nullptr) {
SDL_LogWarn(0, "SDL_ttf failed to set the text for ChoixBonusTitre", SDL_GetError());
}
ChoixBonus1Text = TTF_CreateText(textEngine, ChoixNiveauFont, "Impossible Meteor", 25);
ChoixBonus2Text = TTF_CreateText(textEngine, ChoixNiveauFont, "OverPopulated Deers", 25);
//texture bonus preview
textureBonus1Preview = IMG_LoadTexture(renderer,"assets/Bonus1Preview.png");
if (textureBonus1Preview == nullptr) {
SDL_LogWarn(0, "failed to load the texture for textureBonus1Preview", SDL_GetError());
}
textureBonus2Preview = IMG_LoadTexture(renderer,"assets/Bonus2Preview.png");
if (textureBonus2Preview == nullptr) {
SDL_LogWarn(0, "failed to load the texture for textureBonus2Preview", SDL_GetError());
}
//DANS INTROGAME
texteIntroCerfEtHUmain = TTF_CreateText(textEngine, DialogueFont, phrasesIntroNiveau1[0], 0);
TTF_SetTextColor(texteIntroCerfEtHUmain, 255, 255, 255, 255);
//DANS GAME
dynamicscoreFont = TTF_OpenFont("assets/font.ttf", 40);
dynamicscoreText = TTF_CreateText(textEngine, dynamicscoreFont, "Score", 25);
if (dynamicscoreText == nullptr) {
SDL_LogWarn(0, "failed to set the text of the dynamicscoreText", SDL_GetError());
}
//r g b mis dans la fonction Game
InventoryFont = TTF_OpenFont("assets/font.ttf", 40);
InventoryText = TTF_CreateText(textEngine, InventoryFont, " 0 ", 25);
if (InventoryText == nullptr) {
SDL_LogWarn(0, "SDL_ttf failed to set the inventory text", SDL_GetError());
}
dynamicPlayerHealFont = TTF_OpenFont("assets/font.ttf", 25);
dynamicPlayerHeal = TTF_CreateText(textEngine, dynamicPlayerHealFont, "Heal: 150", 25);
if (dynamicPlayerHeal == nullptr) {
SDL_LogWarn(0,"failed to create the text of dynamicPlayerHeal", SDL_GetError());
}
if (TTF_SetTextColor(dynamicPlayerHeal, 255,255,255,255) == false) {
SDL_LogWarn (1, "failed to make the color of dynamicPlayerHeal", SDL_GetError());
}
competenceSpecialFont = TTF_OpenFont("assets/Cosmo Corner.ttf", 20);
competenceSpecialText = TTF_CreateText(textEngine, competenceSpecialFont, "special Skill Available", 25);
if (competenceSpecialText == nullptr) {
SDL_LogWarn(0, "failed to create the text for competenceSpecialText", SDL_GetError());
}
if (TTF_SetTextColor(competenceSpecialText, 80, 80, 220, 255) == false) {
SDL_LogWarn(0, "failed to set the color of competenceSpecialText", SDL_GetError());
}
competenceSpecialText2 = TTF_CreateText(textEngine, competenceSpecialFont, "special Skill Available", 25);
if (competenceSpecialText2 == nullptr) {
SDL_LogWarn(0, "failed to create the text for competenceSpecialText", SDL_GetError());
}
dynamicShieldHPFont = TTF_OpenFont("assets/font.ttf", 25);
dynamicShieldHPText = TTF_CreateText(textEngine, dynamicShieldHPFont, "Shield Amount: 0", 25);
if (dynamicShieldHPText == nullptr) {
SDL_LogWarn(0, "failed to set the text of dynamicShieldHPText", 25, SDL_GetError());
}
if (TTF_SetTextColor(dynamicShieldHPText, 255, 255, 255, 255) == false) {
SDL_LogWarn(0, "failed to set the color of dynamicShieldHPText");
}
//Pour faire spawn la fraise
textureStrawberry = IMG_LoadTexture(renderer, "assets/StrawbCompress.png");
if (textureStrawberry == nullptr) {
SDL_LogWarn(0, "Erreur chargement Strawb.png: %s", SDL_GetError());
}
//Pour faire spawn la texture du Cerf
textureCerf = IMG_LoadTexture(renderer, "assets/DeerEnnemieCompress.png");
if (textureCerf == nullptr) {
SDL_LogWarn(0, "failed to set the texture of textureCerf", SDL_GetError());
}
//texture Cerf Carrot
textureCerfCarrot = IMG_LoadTexture(renderer, "assets/DeerEnnemieCarrot.png");
if (textureCerfCarrot == nullptr) {
SDL_LogWarn(0, "failed to set the texture of textureCerfCarrot", SDL_GetError());
}
//Pour les textures des differents bullets
textureBulletNormal = IMG_LoadTexture(renderer, "assets/BulletNormalCompress.png");
if (textureBulletNormal == nullptr) {
SDL_LogWarn(0, "failed to set the texture of textureBulletNormal", SDL_GetError());
}
textureBulletFire = IMG_LoadTexture(renderer, "assets/BulletFireCompress.png");
if (textureBulletFire == nullptr) {
SDL_LogWarn(0, "failed to set the texture of textureBulletFire", SDL_GetError());
}
textureBulletIce = IMG_LoadTexture(renderer, "assets/BulletIceCompress.png");
if (textureBulletIce == nullptr) {
SDL_LogWarn(0, "failed to set the texture of textureBulletIce", SDL_GetError());
}
textureBulletGold = IMG_LoadTexture(renderer, "assets/BulletGold.png");
if (textureBulletGold == nullptr) {
SDL_LogWarn(0, "failed to set the texture of textureBulletGold", SDL_GetError());
}
//MEAT TEXTURE
textureMeat = IMG_LoadTexture(renderer, "assets/Meatv3Compress.png");
if (textureMeat == nullptr) {
SDL_LogWarn(0, "failed to set the texture of textureMeat", SDL_GetError());
}
//BACKGROUNDS TEXTURE
textureBackground = IMG_LoadTexture(renderer, "assets/Background.png");
if (textureBackground == nullptr) {
SDL_LogWarn(0, "failed to set the texture of textureBackground", SDL_GetError());
}
textureBackground2 = IMG_LoadTexture(renderer, "assets/Background2.png");
if (textureBackground2 == nullptr) {
SDL_LogWarn(0, "failed to set the texture of textureBackground2", SDL_GetError());
}
textureBackgroundMenu = IMG_LoadTexture(renderer, "assets/BackgroundMenu.png");
if (textureBackgroundMenu == nullptr) {