-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEnemyColdMachine.cpp
1640 lines (1428 loc) · 66.8 KB
/
EnemyColdMachine.cpp
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
#include "Application.h"
#include "EnemyColdMachine.h"
#include "ModuleCollision.h"
#include "ModuleEnemies.h"
#include "ModuleRender.h"
#include "SDL\include\SDL_timer.h"
#include "ModuleAudio.h"
#include "ModuleFadeToBlack.h"
EnemyColdMachine::EnemyColdMachine(int x, int y, powerUpTypes type, SDL_Texture* thisTexture) : Enemy(x, y)
{
enemyType = COLDMACHINE;
//links the correct spritesheet texture ----
enemyTex = thisTexture;
// -----------------------------------------
powerUpType = type;
life = 140;
enemyScore = 10000;
// -----------------------------------------
// Load specific boss sfx
App->audio->LoadAudio("assets/Audio/SFX/Enemies/Boss_arm_shoot.wav", "armShoot", SFX);
App->audio->LoadAudio("assets/Audio/SFX/Enemies/Boss_Blue_Balls.wav", "shuriken", SFX);
App->audio->LoadAudio("assets/Audio/SFX/Enemies/Boss_knee_laser.wav", "kneeLaser", SFX);
App->audio->LoadAudio("assets/Audio/SFX/Enemies/Boss_landing.wav", "bossLanding", SFX);
App->audio->LoadAudio("assets/Audio/SFX/Enemies/Boss_Move.wav", "bossMove", SFX);
App->audio->LoadAudio("assets/Audio/SFX/Enemies/Boss_rocket.wav", "bossRocket", SFX);
// STATIC PIECES RECTS -----------------------------------------------
// chest statics ---
coldMachine.chest.chestPiece.rect[NORMAL_ANIM] = { 212,361,183,168 };
coldMachine.chest.chestPiece.rect[DAMAGE_ANIM] = { 608,361,183,168 };
coldMachine.chest.chestPiece.position = { 0, 0};
// -----------------
// leg statics ---
coldMachine.legs.footPiece.rect[NORMAL_ANIM] = { 267,295, 134,37 };
coldMachine.legs.footPiece.rect[DAMAGE_ANIM] = { 663,295, 134,37 };
coldMachine.legs.footPiece.position = { 13,292 };
// lower leg
coldMachine.legs.lowerLegPiece.rect[NORMAL_ANIM] = { 323,199,78,90};
coldMachine.legs.lowerLegPiece.rect[DAMAGE_ANIM] = { 719,199,78,90 };
coldMachine.legs.lowerLegPiece.position = { 66, 208 };
// knee
coldMachine.legs.kneePiece.rect[NORMAL_ANIM] = { 267,124,77,75 };
coldMachine.legs.kneePiece.rect[DAMAGE_ANIM] = { 663,124,77,75 };
coldMachine.legs.kneePiece.position = { 19, 189 };
// upper leg
coldMachine.legs.upperLegPiece.rect[NORMAL_ANIM] = { 285,46,102,78 };
coldMachine.legs.upperLegPiece.rect[DAMAGE_ANIM] = { 681,46,102,78 };
coldMachine.legs.upperLegPiece.position = { 37,137 };
// hip
coldMachine.legs.hipPiece.rect[NORMAL_ANIM] = { 403,234,136,54 };//259,0,136,46 };
coldMachine.legs.hipPiece.rect[DAMAGE_ANIM] = { 655,0,136,46 };
coldMachine.legs.hipPiece.position = { 11 ,129 };//,137 };
// --------------------------------------------------------------------
// --------------------------------------------------------------------
// ANIMATED parts
// chest animations ------
// chest cannon
coldMachine.chest.chestCannonAnim[NORMAL_ANIM].PushBack({ 81,466,32,32 }); // max closed
coldMachine.chest.chestCannonAnim[NORMAL_ANIM].PushBack({ 114,466,32,32 });
coldMachine.chest.chestCannonAnim[NORMAL_ANIM].PushBack({ 147,466,32,32 });
for (uint i = 0; i < 4; i++)
coldMachine.chest.chestCannonAnim[NORMAL_ANIM].PushBack({ 180,466,32,32 }); // max opened 24 frames
coldMachine.chest.chestCannonAnim[NORMAL_ANIM].PushBack({ 147,466,32,32 });
coldMachine.chest.chestCannonAnim[NORMAL_ANIM].PushBack({ 114,466,32,32 });
coldMachine.chest.chestCannonAnim[NORMAL_ANIM].PushBack({ 81,466,32,32 }); // max closed
coldMachine.chest.chestCannonAnim[NORMAL_ANIM].speed = 0.125f;
coldMachine.chest.chestCannonAnim[NORMAL_ANIM].repeat = false;
coldMachine.chest.chestCannonAnim[DAMAGE_ANIM].PushBack({ 477,466,32,32 }); // max closed
coldMachine.chest.chestCannonAnim[DAMAGE_ANIM].PushBack({ 510,466,32,32 });
coldMachine.chest.chestCannonAnim[DAMAGE_ANIM].PushBack({ 543,466,32,32 });
for (uint i = 0; i < 4; i++)
coldMachine.chest.chestCannonAnim[DAMAGE_ANIM].PushBack({ 576,466,32,32 }); // max opened
coldMachine.chest.chestCannonAnim[DAMAGE_ANIM].PushBack({ 543,466,32,32 });
coldMachine.chest.chestCannonAnim[DAMAGE_ANIM].PushBack({ 510,466,32,32 });
coldMachine.chest.chestCannonAnim[DAMAGE_ANIM].PushBack({ 477,466,32,32 }); // max closed
coldMachine.chest.chestCannonAnim[DAMAGE_ANIM].speed = 0.125f;
coldMachine.chest.chestCannonAnim[NORMAL_ANIM].repeat = false;
// chest missile launcher
coldMachine.chest.shoulderLauncherAnim[NORMAL_ANIM].PushBack({ 114,418,32,32 }); // max closed
coldMachine.chest.shoulderLauncherAnim[NORMAL_ANIM].PushBack({ 147,418,32,32 });
coldMachine.chest.shoulderLauncherAnim[NORMAL_ANIM].PushBack({ 180,418,32,32 }); // max opened
coldMachine.chest.shoulderLauncherAnim[NORMAL_ANIM].PushBack({ 180,418,32,32 }); // max opened
coldMachine.chest.shoulderLauncherAnim[NORMAL_ANIM].PushBack({ 147,418,32,32 });
coldMachine.chest.shoulderLauncherAnim[NORMAL_ANIM].PushBack({ 114,418,32,32 }); // max closed
coldMachine.chest.shoulderLauncherAnim[NORMAL_ANIM].speed = 0.125f;
coldMachine.chest.shoulderLauncherAnim[NORMAL_ANIM].repeat = false;
coldMachine.chest.shoulderLauncherAnim[DAMAGE_ANIM].PushBack({ 510,418,32,32 }); // max closed
coldMachine.chest.shoulderLauncherAnim[DAMAGE_ANIM].PushBack({ 543,418,32,32 });
coldMachine.chest.shoulderLauncherAnim[DAMAGE_ANIM].PushBack({ 576,418,32,32 }); // max opened
coldMachine.chest.shoulderLauncherAnim[DAMAGE_ANIM].PushBack({ 576,418,32,32 }); // max opened
coldMachine.chest.shoulderLauncherAnim[DAMAGE_ANIM].PushBack({ 543,418,32,32 });
coldMachine.chest.shoulderLauncherAnim[DAMAGE_ANIM].PushBack({ 510,418,32,32 }); // max closed
coldMachine.chest.shoulderLauncherAnim[DAMAGE_ANIM].speed = 0.125f;
coldMachine.chest.shoulderLauncherAnim[DAMAGE_ANIM].repeat = false;
// dumb eye open and close cycle
coldMachine.chest.eyeAnim[NORMAL_ANIM].PushBack({ 81,370,32,32 }); // max closed
coldMachine.chest.eyeAnim[NORMAL_ANIM].PushBack({ 114,370,32,32 });
coldMachine.chest.eyeAnim[NORMAL_ANIM].PushBack({ 147,370,32,32 });
for (uint i = 0; i < 4; ++i) // 32 frames opened
{
coldMachine.chest.eyeAnim[NORMAL_ANIM].PushBack({ 180,370,32,32 }); // max opened
}
coldMachine.chest.eyeAnim[NORMAL_ANIM].PushBack({ 147,370,32,32 });
coldMachine.chest.eyeAnim[NORMAL_ANIM].PushBack({ 114,370,32,32 });
coldMachine.chest.eyeAnim[NORMAL_ANIM].speed = 0.125f;
coldMachine.chest.eyeAnim[NORMAL_ANIM].repeat = false;
coldMachine.chest.eyeAnim[DAMAGE_ANIM].PushBack({ 477,370,32,32 }); // max closed
coldMachine.chest.eyeAnim[DAMAGE_ANIM].PushBack({ 510,370,32,32 });
coldMachine.chest.eyeAnim[DAMAGE_ANIM].PushBack({ 543,370,32,32 });
for (uint i = 0; i < 4; i++)
{
coldMachine.chest.eyeAnim[DAMAGE_ANIM].PushBack({ 576,370,32,32 }); // max opened
}
coldMachine.chest.eyeAnim[DAMAGE_ANIM].PushBack({ 543,370,32,32 });
coldMachine.chest.eyeAnim[DAMAGE_ANIM].PushBack({ 510,370,32,32 });
coldMachine.chest.eyeAnim[DAMAGE_ANIM].speed = 0.125f;
coldMachine.chest.eyeAnim[DAMAGE_ANIM].repeat = false;
// back shuriken launcher
coldMachine.chest.shurikenLauncherAnim[NORMAL_ANIM].PushBack({ 303,333,48,28 }); // max closed
coldMachine.chest.shurikenLauncherAnim[NORMAL_ANIM].PushBack({ 358,333,48,28 });
for (uint i = 0; i < 10; i++)
coldMachine.chest.shurikenLauncherAnim[NORMAL_ANIM].PushBack({ 410,333,48,28 });
coldMachine.chest.shurikenLauncherAnim[NORMAL_ANIM].PushBack({ 462,333,48,28 });// max opened // 84 frames
coldMachine.chest.shurikenLauncherAnim[NORMAL_ANIM].PushBack({ 358,333,48,28 });
coldMachine.chest.shurikenLauncherAnim[NORMAL_ANIM].PushBack({ 303,333,48,28 }); // max closed
coldMachine.chest.shurikenLauncherAnim[NORMAL_ANIM].speed = 0.125f;
coldMachine.chest.shurikenLauncherAnim[NORMAL_ANIM].repeat = false;
coldMachine.chest.shurikenLauncherAnim[NORMAL_ANIM].finish = true; // fake condition
coldMachine.chest.shurikenLauncherAnim[DAMAGE_ANIM].PushBack({ 699,333,48,28 }); // max closed
coldMachine.chest.shurikenLauncherAnim[DAMAGE_ANIM].PushBack({ 754,333,48,28 });
for (uint i = 0; i < 10; i++)
coldMachine.chest.shurikenLauncherAnim[DAMAGE_ANIM].PushBack({ 806,333,48,28 });
coldMachine.chest.shurikenLauncherAnim[DAMAGE_ANIM].PushBack({ 462,333,48,28 }); // max opened // 84 frames NORMAL SPRITE,DAMAGE NOT PRESENT
coldMachine.chest.shurikenLauncherAnim[DAMAGE_ANIM].PushBack({ 754,333,48,28 });
coldMachine.chest.shurikenLauncherAnim[DAMAGE_ANIM].PushBack({ 699,333,48,28 }); // max closed
coldMachine.chest.shurikenLauncherAnim[DAMAGE_ANIM].speed = 0.125f;
coldMachine.chest.shurikenLauncherAnim[DAMAGE_ANIM].repeat = false;
coldMachine.chest.shurikenLauncherAnim[DAMAGE_ANIM].finish = true; // fake condition
// ------------------------------------------------------------------------------------
// LEG animations
// lower leg missile launcher
coldMachine.legs.missileLauncherAnim[NORMAL_ANIM].PushBack({ 191,247,32,32 }); // max closed
coldMachine.legs.missileLauncherAnim[NORMAL_ANIM].PushBack({ 224,247,32,32 });
coldMachine.legs.missileLauncherAnim[NORMAL_ANIM].PushBack({ 257,247,32,32 });
coldMachine.legs.missileLauncherAnim[NORMAL_ANIM].PushBack({ 290,247,32,32 }); // max opened
coldMachine.legs.missileLauncherAnim[NORMAL_ANIM].PushBack({ 257,247,32,32 });
coldMachine.legs.missileLauncherAnim[NORMAL_ANIM].PushBack({ 224,247,32,32 });
coldMachine.legs.missileLauncherAnim[NORMAL_ANIM].speed = 0.125f;
coldMachine.legs.missileLauncherAnim[NORMAL_ANIM].repeat = false;
coldMachine.legs.missileLauncherAnim[DAMAGE_ANIM].PushBack({ 587,247,32,32 }); // max closed
coldMachine.legs.missileLauncherAnim[DAMAGE_ANIM].PushBack({ 620,247,32,32 });
coldMachine.legs.missileLauncherAnim[DAMAGE_ANIM].PushBack({ 653,247,32,32 });
coldMachine.legs.missileLauncherAnim[DAMAGE_ANIM].PushBack({ 686,247,32,32 }); // max opened
coldMachine.legs.missileLauncherAnim[DAMAGE_ANIM].PushBack({ 653,247,32,32 });
coldMachine.legs.missileLauncherAnim[DAMAGE_ANIM].PushBack({ 620,247,32,32 });
coldMachine.legs.missileLauncherAnim[DAMAGE_ANIM].speed = 0.125f;
coldMachine.legs.missileLauncherAnim[DAMAGE_ANIM].repeat = false;
// knee eye beam launcher
coldMachine.legs.kneeAnim[NORMAL_ANIM].PushBack({ 123,160,32,32 }); // max closed
coldMachine.legs.kneeAnim[NORMAL_ANIM].PushBack({ 160,160,32,32 });
coldMachine.legs.kneeAnim[NORMAL_ANIM].PushBack({ 197,160,32,32 });
coldMachine.legs.kneeAnim[NORMAL_ANIM].PushBack({ 235,160,32,32 }); //1// max opened
coldMachine.legs.kneeAnim[NORMAL_ANIM].PushBack({ 235,160,32,32 }); //2// max opened
coldMachine.legs.kneeAnim[NORMAL_ANIM].PushBack({ 235,160,32,32 }); //3// max opened
coldMachine.legs.kneeAnim[NORMAL_ANIM].PushBack({ 235,160,32,32 }); //4// max opened
coldMachine.legs.kneeAnim[NORMAL_ANIM].PushBack({ 197,160,32,32 });
coldMachine.legs.kneeAnim[NORMAL_ANIM].PushBack({ 160,160,32,32 });
coldMachine.legs.kneeAnim[NORMAL_ANIM].speed = 0.125f;
coldMachine.legs.kneeAnim[NORMAL_ANIM].repeat = false;
coldMachine.legs.kneeAnim[DAMAGE_ANIM].PushBack({ 519,160,32,32 }); // max closed
coldMachine.legs.kneeAnim[DAMAGE_ANIM].PushBack({ 556,160,32,32 });
coldMachine.legs.kneeAnim[DAMAGE_ANIM].PushBack({ 593,160,32,32 });
coldMachine.legs.kneeAnim[DAMAGE_ANIM].PushBack({ 631,160,32,32 }); //1// max opened
coldMachine.legs.kneeAnim[DAMAGE_ANIM].PushBack({ 631,160,32,32 }); //2// and make the max opened lasts a little more
coldMachine.legs.kneeAnim[DAMAGE_ANIM].PushBack({ 631,160,32,32 }); //3
coldMachine.legs.kneeAnim[DAMAGE_ANIM].PushBack({ 631,160,32,32 }); //4
coldMachine.legs.kneeAnim[DAMAGE_ANIM].PushBack({ 593,160,32,32 });
coldMachine.legs.kneeAnim[DAMAGE_ANIM].PushBack({ 556,160,32,32 });
coldMachine.legs.kneeAnim[DAMAGE_ANIM].speed = 0.125f;
coldMachine.legs.kneeAnim[DAMAGE_ANIM].repeat = false;
// knee flash reflection when shoots
coldMachine.legs.kneeFlashReflectionAnim.PushBack({ 542,569,17,32 });
coldMachine.legs.kneeFlashReflectionAnim.PushBack({ 508,569,17,32 });
coldMachine.legs.kneeFlashReflectionAnim.PushBack({ 479,569,17,32 });
coldMachine.legs.kneeFlashReflectionAnim.PushBack({ 446,569,29,32 });
coldMachine.legs.kneeFlashReflectionAnim.PushBack({ 415,569,29,32 });
coldMachine.legs.kneeFlashReflectionAnim.PushBack({ 386,569,29,32 });
coldMachine.legs.kneeFlashReflectionAnim.PushBack({ 357,569,29,32 });
coldMachine.legs.kneeFlashReflectionAnim.speed = 0.125f;
coldMachine.legs.kneeFlashReflectionAnim.repeat = false;
// arm shootgun
coldMachine.legs.armShootgunAnim[NORMAL_ANIM].PushBack({ 172,0,57,99 }); // idle, pointing down, off
coldMachine.legs.armShootgunAnim[NORMAL_ANIM].PushBack({ 91,0,81,63 });
coldMachine.legs.armShootgunAnim[NORMAL_ANIM].PushBack({ 0,0,91,45 }); // shooting pos, lasts 24 frames
coldMachine.legs.armShootgunAnim[NORMAL_ANIM].PushBack({ 0,0,91,45 }); // shooting pos,
coldMachine.legs.armShootgunAnim[NORMAL_ANIM].PushBack({ 0,0,91,45 }); // shooting pos,
coldMachine.legs.armShootgunAnim[NORMAL_ANIM].PushBack({ 0,0,91,45 }); // shooting pos,
coldMachine.legs.armShootgunAnim[NORMAL_ANIM].PushBack({ 91,0,81,63 });
coldMachine.legs.armShootgunAnim[NORMAL_ANIM].PushBack({ 172,0,57,99 }); // idle, pointing down, off
coldMachine.legs.armShootgunAnim[NORMAL_ANIM].speed = 0.125f;
coldMachine.legs.armShootgunAnim[NORMAL_ANIM].repeat = false;
coldMachine.legs.armShootgunAnim[DAMAGE_ANIM].PushBack({ 568,0,57,99 }); // idle, bad sprite
coldMachine.legs.armShootgunAnim[DAMAGE_ANIM].PushBack({ 487,0,81,63 });
coldMachine.legs.armShootgunAnim[DAMAGE_ANIM].PushBack({ 396,0,91,45 }); // shooting pos
coldMachine.legs.armShootgunAnim[DAMAGE_ANIM].PushBack({ 396,0,91,45 }); // shooting pos
coldMachine.legs.armShootgunAnim[DAMAGE_ANIM].PushBack({ 396,0,91,45 }); // shooting pos
coldMachine.legs.armShootgunAnim[DAMAGE_ANIM].PushBack({ 396,0,91,45 }); // shooting pos
coldMachine.legs.armShootgunAnim[DAMAGE_ANIM].PushBack({ 487,0,81,63 });
coldMachine.legs.armShootgunAnim[DAMAGE_ANIM].PushBack({ 568,0,57,99 }); // idle, bad sprite
coldMachine.legs.armShootgunAnim[DAMAGE_ANIM].speed = 0.125f;
coldMachine.legs.armShootgunAnim[DAMAGE_ANIM].repeat = false;
// BOMBARDIER animation
coldMachine.bombardier.anim.PushBack({ 988,0,36,24 }); // start //drop bomb
coldMachine.bombardier.anim.PushBack({ 800,26,63,24 }); // more fire, still not really open the bombs gate
coldMachine.bombardier.anim.PushBack({ 924,0,63,22 });
coldMachine.bombardier.anim.PushBack({ 800,0,64,21 });
coldMachine.bombardier.anim.PushBack({ 865,0,58,22 });
coldMachine.bombardier.anim.PushBack({ 800,0,64,21 });
coldMachine.bombardier.anim.PushBack({ 924,0,63,22 }); // end, then drop another bomb/restart cycle
coldMachine.bombardier.anim.speed = 0.25f;
coldMachine.bombardier.anim.repeat = false;
// ------------------------------------------------------------------------------------
collider = App->collision->AddCollider({ 0, 0, 32, 16 }, COLLIDER_TYPE::COLLIDER_ENEMY, (Module*)App->enemies);
// sets the first boss state
coldMachine.state = bossState::LANDING;
position.y = -329;//-137; // spawn position y
position.x = x + 157; // spawn position x
fposition.y = position.y;
coldMachine.stopAnimations = true;
// first contact to ground path animation
// first step
// lower leg path
coldMachine.firstContact.lowerLeg.PushBack({ 0, 1.0f }, 1);
coldMachine.firstContact.lowerLeg.PushBack({ 0, 0 }, 48);
coldMachine.firstContact.lowerLeg.PushBack({ 0, -1.0f }, 1); // END 48 frames
// knee path
coldMachine.firstContact.knee.PushBack({ 0,1.0f },1);
coldMachine.firstContact.knee.PushBack({ 0, 0}, 8);
coldMachine.firstContact.knee.PushBack({ 0, 1.0f }, 1);
coldMachine.firstContact.knee.PushBack({ 0,0 }, 24);
coldMachine.firstContact.knee.PushBack({ 0, -1.0f }, 1);
coldMachine.firstContact.knee.PushBack({ 0, 0 }, 16);
coldMachine.firstContact.knee.PushBack({ 0, -1.0f }, 1); // END 48 frames
// upper leg path
coldMachine.firstContact.upperLeg.PushBack({ 0, 1},1);
coldMachine.firstContact.upperLeg.PushBack({ 0, 0 }, 4);
coldMachine.firstContact.upperLeg.PushBack({ 0, 1 }, 1);
coldMachine.firstContact.upperLeg.PushBack({ 0, 0 }, 4);
coldMachine.firstContact.upperLeg.PushBack({ 0, 1 }, 1);
coldMachine.firstContact.upperLeg.PushBack({ 0, 0 }, 4);
coldMachine.firstContact.upperLeg.PushBack({ 0, 1 }, 1);
coldMachine.firstContact.upperLeg.PushBack({ 0, 0 }, 12);
coldMachine.firstContact.upperLeg.PushBack({ 0, -1 }, 1);
coldMachine.firstContact.upperLeg.PushBack({ 0, 0 }, 8);
coldMachine.firstContact.upperLeg.PushBack({ 0, -1 }, 1);
coldMachine.firstContact.upperLeg.PushBack({ 0, 0 }, 8);
coldMachine.firstContact.upperLeg.PushBack({ 0, -1 }, 1);
coldMachine.firstContact.upperLeg.PushBack({ 0, 0 }, 8);
coldMachine.firstContact.upperLeg.PushBack({ 0, -1 }, 1); // END 48 frames
// hip path, chest is the same
coldMachine.firstContact.hip.PushBack({0, 1}, 1);
coldMachine.firstContact.chest.PushBack({ 0, 1 }, 1);
for (uint i = 0; i < 8; ++i)
{
coldMachine.firstContact.hip.PushBack({ 0, 0 }, 2);
coldMachine.firstContact.chest.PushBack({ 0, 0 }, 2);
coldMachine.firstContact.hip.PushBack({ 0, 1 }, 1);
coldMachine.firstContact.chest.PushBack({ 0, 1 }, 1);
}
for (uint i = 0; i < 9; ++i)
{
coldMachine.firstContact.hip.PushBack({ 0, 0 }, 4);
coldMachine.firstContact.chest.PushBack({ 0, 0 }, 4);
coldMachine.firstContact.hip.PushBack({ 0, -1 }, 1);
coldMachine.firstContact.chest.PushBack({ 0, -1 }, 1);
}
coldMachine.firstContact.lowerLeg.loop = false;
coldMachine.firstContact.knee.loop = false;
coldMachine.firstContact.upperLeg.loop = false;
coldMachine.firstContact.hip.loop = false;
coldMachine.firstContact.chest.loop = false;
// ---------------------------------------------------------
// Fase 1 to fase 2 path animations
coldMachine.f1Tof2Path.foot.PushBack({ -0.5, 1 }, 20);
coldMachine.f1Tof2Path.lowerLeg.PushBack( {-0.5, 1}, 20);
coldMachine.f1Tof2Path.knee.PushBack({ -0.5, 1 }, 20);
coldMachine.f1Tof2Path.upperLeg.PushBack({ -0.5, 1 }, 20);
coldMachine.f1Tof2Path.hip.PushBack({ -0.5, 1 }, 20);
coldMachine.f1Tof2Path.chest.PushBack({ 0, 1 }, 20);
//original.y = 60;
//original.x = position.x;
// add colliders
int k = 0;
collider = coldMachine.chestCollider = extraColliders[k++] = App->collision->AddCollider({ 0,0,110,130}, COLLIDER_ENEMY, (Module*)App->enemies);
coldMachine.legCollider = extraColliders[k++] = App->collision->AddCollider({ 0,0,60,180 }, COLLIDER_ENEMY, (Module*)App->enemies);
coldMachine.upEyeCollider = extraColliders[k++] = App->collision->AddCollider({ 0,0,20,32 }, COLLIDER_ENEMY, (Module*)App->enemies);
coldMachine.kneeCollider = extraColliders[k++] = App->collision->AddCollider({ 0,0,39,40 }, COLLIDER_ENEMY, (Module*)App->enemies);
}
void EnemyColdMachine::Move()
{
switch (coldMachine.state)
{
case bossState::LANDING:
decelerationToFloor();
position.y = fposition.y;
break;
case bossState::FIRSTCONTACT:
firstContactAnimation();
break;
case bossState::FASE1:
// checks if we are throwing missiles (activated on returned rects, animation frame dependent)
if (coldMachine.legs.throwMissiles) missilesLogic();
if (coldMachine.legs.throwKneeBeam) kneeBeamLogic();
break;
case bossState::F1TOF2:
F1ToF2Transition();
position.y = fposition.y;
break;
case bossState::FASE2:
fase2MovementLogic();
fase2AttackManager();
if (coldMachine.legs.throwMissiles && !coldMachine.leftCorner && !coldMachine.move)
missilesLogic(); // trick
else
{
if (coldMachine.legs.throwMissiles)
{
coldMachine.legs.throwMissiles = false;
coldMachine.legs.missilesWaveCount = 0;
coldMachine.legs.missilesCount = 0;
}
}
//position.y = fposition.y;
break;
case bossState::TOEXPLODE:
toExplode();
break;
}
//position.x += 1; // GENERAL POSITION
// update general fase timer
coldMachine.now_cycle_time = SDL_GetTicks() - coldMachine.start_cycle_time;
// check fase timer
if (coldMachine.state == bossState::FASE1)
{
if (coldMachine.now_cycle_time > coldMachine.fase1_total_time || coldMachine.destroyedFase1)
{
coldMachine.state = bossState::F1TOF2;
// update original positions for path animation
updateOriginalPositions();
// instantiate particles
addBossParticles();
// deactivate visible hip
coldMachine.legs.destroyedHip = true;
coldMachine.move = true;
coldMachine.bombardier.instantiate = false;
//PLAY SFX
App->audio->ControlAudio("bossMove", SFX, PLAY, 3);
// resets missile function data
coldMachine.legs.missilesWaveCount = 0;
coldMachine.legs.missilesCount = 0;
coldMachine.legs.shootedMissile = false;
// shutdown missiles throwing
coldMachine.legs.throwMissiles = false;
// resets timers
coldMachine.legs.start_missiles_time = SDL_GetTicks();
coldMachine.legs.start_launch_time = SDL_GetTicks();
// delete leg relative colliders
if (coldMachine.legCollider != nullptr)
{
coldMachine.legCollider->to_delete = true;
coldMachine.legCollider = nullptr;
}
if (coldMachine.kneeCollider != nullptr)
{
coldMachine.kneeCollider->to_delete = true;
coldMachine.kneeCollider = nullptr;
}
}
}
// check fase2 timer
if (coldMachine.state == bossState::FASE2)
{
if (coldMachine.now_cycle_time > coldMachine.fase2_total_time || coldMachine.destroyedFase2)
{
coldMachine.state = bossState::TOEXPLODE;
// update original positions for path animation
updateOriginalPositions();
// instantiate particles
addBossParticles();
// update timer to auto destroy enemy
coldMachine.start_exploding_time = SDL_GetTicks();
}
}
// updates colliders position
if (coldMachine.chestCollider != nullptr)
coldMachine.chestCollider->SetPos(position.x + coldMachine.chest.chestPiece.position.x + 36,
position.y + coldMachine.chest.chestPiece.position.y + 20);
if (coldMachine.legCollider != nullptr)
coldMachine.legCollider->SetPos(position.x + coldMachine.legs.upperLegPiece.position.x + 26,
position.y + coldMachine.legs.upperLegPiece.position.y + 10);
if (coldMachine.kneeCollider != nullptr)
coldMachine.kneeCollider->SetPos(position.x + coldMachine.legs.kneePiece.position.x + 5,
position.y + coldMachine.legs.kneePiece.position.y + 30);
if (coldMachine.upEyeCollider != nullptr)
coldMachine.upEyeCollider->SetPos(position.x + coldMachine.chest.chestPiece.position.x + 16,
position.y + coldMachine.chest.chestPiece.position.y + 10);
}
void EnemyColdMachine::OnCollision(Collider* c1, Collider* c2)
{
if (c1->type != COLLIDER_WALL)
{
//LOG("Collision");
//only up eye and knee eye can receive damage, but only when its frames are more than 1 (open or opening animation state)
if (c2 == coldMachine.kneeCollider)
{
if ((int)coldMachine.legs.kneeAnim[coldMachine.current_sprite_type].current_frame > 0)
{
LOG("Knee Collision");
if (readyToRumble && c1->type == COLLIDER_UNIT) // collisions logic for unit orbit
{
coldMachine.start_damage_time = SDL_GetTicks();
coldMachine.legs.life -= c1->damage;
LOG("KNEE LIFE: %d", coldMachine.legs.life);
}
else if (c1->type != COLLIDER_UNIT)
{
coldMachine.start_damage_time = SDL_GetTicks();
coldMachine.legs.life -= c1->damage;
}
if (coldMachine.legs.life <= 0)
{
coldMachine.destroyedFase1 = true;
}
}
}
if (c2 == coldMachine.upEyeCollider)
{
if ((int)coldMachine.chest.eyeAnim[coldMachine.current_sprite_type].current_frame > 0)
{
LOG("Eye Collision");
if (readyToRumble && c1->type == COLLIDER_UNIT) // collisions logic for unit orbit
{
coldMachine.start_damage_time = SDL_GetTicks();
coldMachine.chest.life -= c1->damage;
LOG("EYE LIFE: %d", coldMachine.chest.life);
}
else if (c1->type != COLLIDER_UNIT)
{
coldMachine.start_damage_time = SDL_GetTicks();
coldMachine.chest.life -= c1->damage;
}
if (coldMachine.chest.life <= 0)
{
coldMachine.destroyedFase1 = true;
}
}
}
}
}
const Collider* EnemyColdMachine::GetCollider() const
{
return extraColliders[collisionColliderIndex];
}
void EnemyColdMachine::fase2AttackManager()
{
// shurikens attack logic
// checks shuriken timer, !SHURIKEN CONDITION HAPPENS when ColdEnemy its ONLY on left corner!
if (coldMachine.leftCorner) //&& coldMachine.moveToLeft) //while on left corner
{
coldMachine.chest.now_shuriken_time = SDL_GetTicks() - coldMachine.chest.start_shuriken_time;
if (coldMachine.chest.now_shuriken_time > coldMachine.chest.shuriken_waves_time && !coldMachine.chest.throwShuriken)
{
LOG("Left corner reached and countdown is over: WAVE of shuriken");
// start shuriken timer and activate shuriken mode
coldMachine.chest.start_shuriken_time = SDL_GetTicks();
coldMachine.chest.throwShuriken = true;
// resets animation data
coldMachine.chest.shurikenLauncherAnim[coldMachine.current_sprite_type].current_frame = 0;
coldMachine.chest.shurikenLauncherAnim[coldMachine.current_sprite_type].finish = false;
}
// check shuriken delay between shurikens
if (coldMachine.chest.throwShuriken)
{
if (coldMachine.chest.now_shuriken_time > coldMachine.chest.shuriken_cadenece_time)
{
// resets timer
coldMachine.chest.start_shuriken_time = SDL_GetTicks();
// instantiate next shuriken
coldMachine.chest.numShurikens++;
LOG("SHURIKEN %d", coldMachine.chest.numShurikens);
App->enemies->AddEnemy(SHURIKEN, position.x + coldMachine.chest.chestPiece.position.x + 100,
position.y + coldMachine.chest.chestPiece.position.y - 6, NONE);
//PLAY SFX
App->audio->ControlAudio("shuriken", SFX, PLAY);
if (coldMachine.chest.numShurikens > 2) // max 3 shurikens per wave
{
coldMachine.chest.start_shuriken_time = SDL_GetTicks();
coldMachine.chest.throwShuriken = false;
coldMachine.chest.numShurikens = 0;
}
}
}
}
if (!coldMachine.leftCorner && !coldMachine.move)
{
if (!coldMachine.chest.throwGlassCannon)
{
// update start time for glass cannon
coldMachine.chest.start_glass_cannon_time = SDL_GetTicks();
// update condition
coldMachine.chest.throwGlassCannon = true;
}
else
{
coldMachine.chest.now_glass_cannon_time = SDL_GetTicks() - coldMachine.chest.start_glass_cannon_time;
if (coldMachine.chest.now_glass_cannon_time > coldMachine.chest.time_waiting_for_glass && !coldMachine.chest.shootedGlass)
{
LOG("Opening GLASS CANNON gate");
coldMachine.chest.shootedGlass = true;
//PLAY SFX
App->audio->ControlAudio("glassLaser", SFX, PLAY);
}
// checks animation data to instantiate the shoot on correct frame
if ((int)coldMachine.chest.chestCannonAnim[coldMachine.current_sprite_type].current_frame == 3 &&
!coldMachine.chest.instantiatedGlass)
{
LOG("INSTANTIATING GLASS");
coldMachine.chest.instantiatedGlass = true;
// instantiate particles
// glass shot particle
App->particles->AddParticle(App->enemies->glassShoot, position.x + coldMachine.chest.chestPiece.position.x,
position.y + coldMachine.chest.chestPiece.position.y + 120,
COLLIDER_ENEMY_SHOT, {-2,0});
// glass shot effect
App->particles->AddParticle(App->enemies->glassShootEffect, position.x + coldMachine.chest.chestPiece.position.x - 25,
position.y + coldMachine.chest.chestPiece.position.y + 114,
COLLIDER_NONE, { scrollSpeed,0 });
// glass rotary trails upwards static
App->particles->AddParticle(App->enemies->glassRotary, position.x + coldMachine.chest.chestPiece.position.x - 10,
position.y + coldMachine.chest.chestPiece.position.y + 120,
COLLIDER_NONE, { scrollSpeed,0 }, 50);
App->particles->AddParticle(App->enemies->glassRotary, position.x + coldMachine.chest.chestPiece.position.x - 45,
position.y + coldMachine.chest.chestPiece.position.y + 120,
COLLIDER_NONE, { scrollSpeed,0 }, 250);
App->particles->AddParticle(App->enemies->glassRotary, position.x + coldMachine.chest.chestPiece.position.x - 80,
position.y + coldMachine.chest.chestPiece.position.y + 120,
COLLIDER_NONE, { scrollSpeed,0 }, 450);
App->particles->AddParticle(App->enemies->glassRotary, position.x + coldMachine.chest.chestPiece.position.x - 115,
position.y + coldMachine.chest.chestPiece.position.y + 120,
COLLIDER_NONE, { scrollSpeed,0 }, 850);
App->particles->AddParticle(App->enemies->glassRotary, position.x + coldMachine.chest.chestPiece.position.x - 150,
position.y + coldMachine.chest.chestPiece.position.y + 120,
COLLIDER_NONE, { scrollSpeed,0 }, 1050);
}
}
}
else
{
// resets condition
if (coldMachine.chest.instantiatedGlass)
{
coldMachine.chest.throwGlassCannon = false;
coldMachine.chest.shootedGlass = false;
coldMachine.chest.instantiatedGlass = false;
// resets animation data
coldMachine.chest.chestCannonAnim[coldMachine.current_sprite_type].current_frame = 0;
coldMachine.chest.chestCannonAnim[coldMachine.current_sprite_type].finish = false;
}
}
}
void EnemyColdMachine::toExplode()
{
if (going_up)
{
if (wave > 1.0f)
going_up = false;
else
wave += 0.07f;
}
else
{
if (wave < -1.0f)
going_up = true;
else
wave -= 0.07f;
}
coldMachine.chest.chestPiece.position.y = original.chest.y + int(8.0f * sinf(wave));
coldMachine.now_exploding_time = SDL_GetTicks() - coldMachine.start_exploding_time;
if (coldMachine.now_exploding_time > coldMachine.time_exploding)
{
killMe = true;
App->fade->FadeToBlack((Module*)App->scene_lvl3, (Module*)App->winScreen, 3.0f);
}
}
void EnemyColdMachine::fase2MovementLogic()
{
if (going_up)
{
if (wave > 1.0f)
going_up = false;
else
wave += 0.07f;
}
else
{
if (wave < -1.0f)
going_up = true;
else
wave -= 0.07f;
}
coldMachine.chest.chestPiece.position.y = original.chest.y + int(8.0f * sinf(wave));
if (coldMachine.move)
{
if (coldMachine.moveToLeft)
{
if (coldMachine.chest.chestPiece.position.x > -208)
{
coldMachine.fposition.x -= 0.5f;
coldMachine.chest.chestPiece.position.x = coldMachine.fposition.x;
}
else
{
// stop mov
coldMachine.move = false;
// arrives at corner functionality
coldMachine.leftCorner = true;
}
}
else
{
if (coldMachine.chest.chestPiece.position.x <= 0)
{
coldMachine.fposition.x += 0.5f;
coldMachine.chest.chestPiece.position.x = coldMachine.fposition.x;
}
else
{
coldMachine.move = false;
coldMachine.leftCorner = false;
}
}
}
else
{
if (coldMachine.moveToLeft && coldMachine.leftCorner)
{
// next move will be to right
coldMachine.moveToLeft = false;
// arrives at left corner attack logic
coldMachine.leftCorner = true;
// start left corner timer
coldMachine.start_corner_time = SDL_GetTicks();
}
if (!coldMachine.moveToLeft && !coldMachine.leftCorner)
{
// next move will be to right
coldMachine.moveToLeft = true;
// arrives at left corner attack logic
coldMachine.leftCorner = false;
// start left corner timer
coldMachine.start_corner_time = SDL_GetTicks();
}
// update current left corner time
coldMachine.now_corner_time = SDL_GetTicks() - coldMachine.start_corner_time;
if (coldMachine.now_corner_time > coldMachine.total_corner_time)
{
if (!coldMachine.move)
{
coldMachine.move = true;
//PLAY SFX
App->audio->ControlAudio("bossMove", SFX, PLAY, 3);
}
if (coldMachine.leftCorner) coldMachine.leftCorner = false; // only shurikens fase
}
}
}
void EnemyColdMachine::updateOriginalPositions()
{
original.foot = coldMachine.legs.footPiece.position;
original.lowerLeg = coldMachine.legs.lowerLegPiece.position;
original.knee = coldMachine.legs.kneePiece.position;
original.upperLeg = coldMachine.legs.upperLegPiece.position;
original.hip = coldMachine.legs.hipPiece.position;
original.chest = coldMachine.chest.chestPiece.position;
}
void EnemyColdMachine::F1ToF2Transition()
{
// update path animations
coldMachine.legs.footPiece.position = original.foot + coldMachine.f1Tof2Path.foot.GetCurrentSpeed();
coldMachine.legs.lowerLegPiece.position = original.lowerLeg + coldMachine.f1Tof2Path.lowerLeg.GetCurrentSpeed();
coldMachine.legs.kneePiece.position = original.knee + coldMachine.f1Tof2Path.knee.GetCurrentSpeed();
coldMachine.legs.upperLegPiece.position = original.upperLeg + coldMachine.f1Tof2Path.upperLeg.GetCurrentSpeed();
coldMachine.legs.hipPiece.position = original.hip + coldMachine.f1Tof2Path.hip.GetCurrentSpeed();
coldMachine.chest.chestPiece.position = original.chest + coldMachine.f1Tof2Path.chest.GetCurrentSpeed();
// updates general positions
// check chest position to switch to fase2
if (coldMachine.chest.chestPiece.position.y > 180)
{
coldMachine.state = bossState::FASE2;
// "destroy" bottom part
coldMachine.legs.destroyed = true;
// start new fase timer
coldMachine.start_cycle_time = SDL_GetTicks();
// start eye blink timer
coldMachine.chest.start_eye_time = SDL_GetTicks();
// store chest position y to sinusoidal fixed y
//position.y = coldMachine.chest.chestPiece.position.y - 237;
original.chest.y = coldMachine.chest.chestPiece.position.y - 7;// + 20;//position.y;//coldMachine.chest.chestPiece.position.y;
//original.chest.x = position.x + coldMachine.chest.chestPiece.position.x;
coldMachine.fposition.x = original.chest.x;
coldMachine.fposition.y = original.chest.y;
//position.y = original.chest.y;
}
/*// start attack timers
coldMachine.legs.start_missiles_time = SDL_GetTicks();
coldMachine.legs.start_kneeBeam_time = SDL_GetTicks();
coldMachine.legs.start_armShooting_time = SDL_GetTicks();
// start countdown timer Fase1
coldMachine.start_cycle_time = SDL_GetTicks();*/
}
void EnemyColdMachine::kneeBeamLogic()
{
// instantiate laser beam
if (!coldMachine.legs.shootedLaserBeam)
{
// instantiate laser beam
App->particles->AddParticle(App->enemies->coldMachineKneeLaser, position.x + coldMachine.legs.kneePiece.position.x - 10,
position.y + 40 + coldMachine.legs.kneePiece.position.y, COLLIDER_ENEMY_SHOT, { -2,0 }, 0);
// instantiate shoot explosion effect
App->particles->AddParticle(App->enemies->coldMachineKneeLaserShotEffect, position.x + coldMachine.legs.kneePiece.position.x + 4,
position.y + 45 + coldMachine.legs.kneePiece.position.y, COLLIDER_NONE, { scrollSpeed,0 }, 0);
// update condition
coldMachine.legs.shootedLaserBeam = true;
//PLAY SFX
App->audio->ControlAudio("kneeLaser", SFX, PLAY);
}
}
void EnemyColdMachine::missilesLogic()
{
// shoot the first missile of the wave
if (!coldMachine.legs.shootedMissile)
{
// increment missiles count
coldMachine.legs.missilesCount++;
// instantiate the missile
LOG("Missile %d instantiated", coldMachine.legs.missilesCount);
//PLAY SFX
App->audio->ControlAudio("bossRocket", SFX, PLAY);
// instantiate missile
// FASE 1 logic
if (coldMachine.state == bossState::FASE1)
{
App->enemies->AddEnemy(HOMINGMISSILE, position.x + coldMachine.legs.lowerLegPiece.position.x +
coldMachine.legs.missileCanyonsPos[coldMachine.legs.missilesCount - 1].x,
position.y + coldMachine.legs.lowerLegPiece.position.y +
coldMachine.legs.missileCanyonsPos[coldMachine.legs.missilesCount - 1].y, NONE);
// instantiate missile flash
App->particles->AddParticle(App->enemies->coldMachineLegMissileFlash, position.x + coldMachine.legs.lowerLegPiece.position.x +
coldMachine.legs.missileCanyonsPos[coldMachine.legs.missilesCount - 1].x,
position.y - 3 + coldMachine.legs.lowerLegPiece.position.y +
coldMachine.legs.missileCanyonsPos[coldMachine.legs.missilesCount - 1].y,
COLLIDER_NONE, { scrollSpeed,0 }, 0);
}
else
{
App->enemies->AddEnemy(HOMINGMISSILE, position.x + coldMachine.chest.chestPiece.position.x +
coldMachine.chest.missileCanyonsPos[coldMachine.legs.missilesCount - 1].x,
position.y + coldMachine.chest.chestPiece.position.y +
coldMachine.chest.missileCanyonsPos[coldMachine.legs.missilesCount - 1].y, NONE);
// instantiate missile flash
App->particles->AddParticle(App->enemies->coldMachineLegMissileFlash, position.x + coldMachine.chest.chestPiece.position.x +
coldMachine.chest.missileCanyonsPos[coldMachine.legs.missilesCount - 1].x,
position.y - 3 + coldMachine.chest.chestPiece.position.y +
coldMachine.chest.missileCanyonsPos[coldMachine.legs.missilesCount - 1].y,
COLLIDER_NONE, { scrollSpeed,0 }, 0);
}
// update the condition
coldMachine.legs.shootedMissile = true;
// update timer
coldMachine.legs.start_launch_time = SDL_GetTicks();
// check if we finish the wave and activate timer
if (coldMachine.legs.missilesCount == 4) // max 4 missiles per wave
{
coldMachine.legs.start_missiles_wave = SDL_GetTicks();
coldMachine.legs.missilesWaveCount++; // update finished wave count
LOG("Finished missiles wave %d", coldMachine.legs.missilesWaveCount);
}
}
if (coldMachine.legs.missilesCount < 4) // max missiles per wave
{
// update timer for next missile shoot
coldMachine.legs.current_missile_time = SDL_GetTicks() - coldMachine.legs.start_launch_time;
if (coldMachine.legs.current_missile_time > coldMachine.legs.time_between_missiles)
{
coldMachine.legs.shootedMissile = false; // launch next missile
}
}
else // wait for wave 2 of 2
{
coldMachine.legs.now_missile_wave_time = SDL_GetTicks() - coldMachine.legs.start_missiles_wave;
if (coldMachine.legs.now_missile_wave_time > coldMachine.legs.time_between_waves)
{
// reset missileCount for activate next wave
coldMachine.legs.missilesCount = 0;
// update missile start launch timer
coldMachine.legs.start_launch_time = SDL_GetTicks();
}
}
}
void EnemyColdMachine::firstContactAnimation()
{
// update path animations
coldMachine.legs.lowerLegPiece.position = original.lowerLeg + coldMachine.firstContact.lowerLeg.GetCurrentSpeed();
coldMachine.legs.kneePiece.position = original.knee + coldMachine.firstContact.knee.GetCurrentSpeed();
coldMachine.legs.upperLegPiece.position = original.upperLeg + coldMachine.firstContact.upperLeg.GetCurrentSpeed();
coldMachine.legs.hipPiece.position = original.hip + coldMachine.firstContact.hip.GetCurrentSpeed();
coldMachine.chest.chestPiece.position = original.chest + coldMachine.firstContact.chest.GetCurrentSpeed();
// check countdown timer to switch to fase1
coldMachine.now_cycle_time = SDL_GetTicks() - coldMachine.start_cycle_time;
if (coldMachine.now_cycle_time > coldMachine.total_firstContact_time)
{
// switch enemy state
coldMachine.state = bossState::FASE1;
// start attack timers
coldMachine.legs.start_missiles_time = SDL_GetTicks();
coldMachine.legs.start_kneeBeam_time = SDL_GetTicks();
coldMachine.legs.start_armShooting_time = SDL_GetTicks();
// start countdown timer Fase1
coldMachine.start_cycle_time = SDL_GetTicks();
}
}
void EnemyColdMachine::decelerationToFloor()
{
if (position.y < -138)
{
if (coldMachine.ySpeed < 2.5f)
coldMachine.ySpeed += 0.07f;
fposition.y += coldMachine.ySpeed;
}
else
{
coldMachine.state = bossState::FIRSTCONTACT;
// and assign actual positions for path entry animation
updateOriginalPositions();
// instantiate particles
addBossParticles();
// start countdown timer
coldMachine.start_cycle_time = SDL_GetTicks();
//PLAY SFX
App->audio->ControlAudio("bossLanding", SFX, PLAY);
}
}
void EnemyColdMachine::Draw()
{
// update all cycle attack timers
coldMachine.legs.now_missiles_time = SDL_GetTicks() - coldMachine.legs.start_missiles_time;
coldMachine.legs.now_kneeBeam_time = SDL_GetTicks() - coldMachine.legs.start_kneeBeam_time;
coldMachine.legs.now_armShooting_time = SDL_GetTicks() - coldMachine.legs.start_armShooting_time;
// damage timer
coldMachine.now_damage_time = SDL_GetTicks() - coldMachine.start_damage_time;
if (coldMachine.now_damage_time > coldMachine.total_damage_time)
{
receiveDamage = false;
coldMachine.current_sprite_type = swapAnimType::NORMAL_ANIM;
}