-
Notifications
You must be signed in to change notification settings - Fork 0
/
original_jump.cpp
1732 lines (1359 loc) · 46.1 KB
/
original_jump.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
//OLD JUMP FUNCTION (for landing):
#include <SFML/Window.hpp>
#include "Character.h"
#include <vector>
#include "Misc.h"
#include "enemyOnPlatform.h"
#include <String>
#define VELOCITYX 10
#define VELOCITYY -20
// 400/2 - 76/2 - position x, cnetered
#define POSXCENTER 362
#define GRAVITY 3
#define TIME 20
// endzones need VELOCITYX changed to 5 to slow player down
//
//
//
Character::Character(Enemy & eObject, Misc & mObject, float x1, float y1, std::vector<Misc> & vector, sf::RenderWindow & inWindow)
{
miscObject = &mObject;
EnemyObject = &eObject;
gPlatformsMoved = "none";
x = x1;
y = y1;
rightEndzoneLine = (1200);
leftEndzoneLine = (400 - 76 / 2);//1162
//keeps track of every movement even in mid zone where positionx stays same (positionx used for local display)
currentCharacterPlacement = 100;// 1162 - 75;//400 - (76 / 2);
}
//falling
int Character::isOnPlatform(sf::RenderWindow & window, sf::Sprite & marioSpriteR, sf::Sprite & marioSpriteL, int SCEENHEIGHT, int& goingDown, std::vector<platform> & vector, int screenWidth, int& characterX, int& characterY, float& positionY, float& positionX)
{
//finds a platform to land on
for (std::vector<platform>::iterator it = vector.begin(); it != vector.end(); ++it)
{
if (it->type != "platform")
{
continue;
}
//if (((it->x >= -76) && (it->x <= screenWidth)) &&
// ((characterX + 76 >= it->x) && (characterX <= (it->x + 150))) &&
// //(characterY >= (it->y - 96)) && (characterY <= (it->y - 76 + 11))
// //josh,this isn't exactly right!
// ((characterY + 76 <= (it->y + 35)) && (characterY + 76 >= (it->y - 15)))
// && (goingDown == 1))
//{
//currentLeftEdge = currentLeftEdge + VELOCITYX;
if (((it->x >= (-76)) && (it->x <= (screenWidth))) &&
((positionX + 76 >= it->x) && (positionX <= (it->x + 300))) &&
//(characterY >= (it->y - 96)) && (characterY <= (it->y - 76 + 11))
//josh,this isn't exactly right!
((positionY + 76 <= (it->y + 35)) && (positionY + 76 >= (it->y - 15)))
&& (goingDown == 1))
{
//this causes changes when a or s pressed
marioSpriteL.setPosition(positionX, it->y - 76);
marioSpriteR.setPosition(positionX, it->y - 76);
positionY = (it->y - 76);
return(1);
}
}
//not on bar
return(0);
}
////////////
int Character::movesLeftInRightEndZoneToo(int facingLeft, const int SCREENHEIGHT, const int SCREENWIDTH, sf::RenderWindow & window, int& goingDown, int& temp1, int& temp2, std::vector<platform> & vector, sf::Sprite & marioSpriteL, sf::Sprite & marioSpriteR, Character & character, int& isLeft, float& positionY, float& positionX)
{
int goingDownBypass = 1;
int answer = character.isOnPlatform(window, marioSpriteR, marioSpriteL, SCREENHEIGHT, goingDownBypass, vector, SCREENWIDTH, temp1, temp2, positionY, positionX);
//on platform
if (answer == 1)
{
currentCharacterPlacement = currentCharacterPlacement - VELOCITYX;
//currentLeftEdge = currentLeftEdge - VELOCITYX;
positionX = positionX - VELOCITYX;
//if (currentCharacterPlacement < rightEndzoneLine)
//{
// character.isMoving = "left";
// return(1);
//}
//is still on platform?
answer = character.isOnPlatform(window, marioSpriteR, marioSpriteL, SCREENHEIGHT, goingDownBypass, vector, SCREENWIDTH, temp1, temp2, positionY, positionX);
//was on, moved off
if (answer == 0)
{
//drop - off platform
return(-1);
}
//still on platform after move - left in right endzone
else
{
//josh, this uncommented doesn't work ?
//currentCharacterPlacement = currentCharacterPlacement - VELOCITYX;
//currentLeftEdge = currentLeftEdge - VELOCITYX;
//positionX = positionX - VELOCITYX;
marioSpriteL.setPosition(positionX, positionY);
marioSpriteR.setPosition(positionX, positionY);
if (currentCharacterPlacement < rightEndzoneLine)
{
character.isMoving = "left";
return(1);
}
//window.clear();
//EnemyObject->moveEnemies(window, 10, -1, 0);
//window.draw(marioSpriteR);
//EnemyObject->moveEnemies(window, 10, -1, 0);
//miscObject.moveEnemies(window, 10, 0, 1);
//platform::SearchVectorForPlatforms(vector, window, 0, 0.0f, 0);
//window.display();
return(1);
}
}
//just walk left not on platform starts here - right endzone
else
{
//////////
if (positionY >= SCREENHEIGHT - 76)
{
currentCharacterPlacement = currentCharacterPlacement - VELOCITYX;
positionX = positionX - VELOCITYX;
if (currentCharacterPlacement < rightEndzoneLine)
{
character.isMoving = "left";
return(1);
}
//currentLeftEdge = currentLeftEdge - VELOCITYX;
marioSpriteL.setPosition(positionX, (SCREENHEIGHT)-(76));
marioSpriteR.setPosition(positionX, (SCREENHEIGHT)-(76));
//plasaatform::SearchVectorForPlatforms(vector, window, 0, 0.0f, 0);
//window.clear();
//window.draw(marioSpriteR);
//platform::SearchVectorForPlatforms(vector, window, 0, 0.0f, 0);
//window.display();
return(1);
}
else
{
//remove these in time -- //josh, look at this, there are four
int no = 0;
int goingDown2 = 0;
//whileFunction(facingLeft, character, clock, window, marioSpriteR, marioSpriteL, SCREENHEIGHT, goingDown, vector, SCREENWIDTH, no, no, goingDown2, positionY, positionX);
return(-1);
}
}
return(1);
}
//movent in left endzone and mid section
int Character::movesLeftInEndZoneToo(int facingLeft, const int SCREENHEIGHT, const int SCREENWIDTH, sf::RenderWindow & window, int& goingDown, int& temp1, int& temp2, std::vector<platform> & vector, sf::Sprite & marioSpriteL, sf::Sprite & marioSpriteR, Character & character, int& isLeft, float& positionY, float& positionX)
{
//not in this section
int goingDownBypass = 1;
if (currentCharacterPlacement > rightEndzoneLine)
{
//checks for while function in main
int val = movesLeftInRightEndZoneToo(facingLeft, SCREENHEIGHT, SCREENWIDTH, window, goingDown, temp1, temp2, vector, marioSpriteL, marioSpriteR, character, isLeft, positionY, positionX);
if (val == -1)
{
return(-1);
}
return(1);
}
if (positionX <= 0)
{
positionX = 0;
//return(1);
}
// calls this when not on platform last run with updated positionx, etc.
// if playrt starts off platform cannot step onto a platform
//int notNeeded1, notNeeded2 = 0;
int answer = character.isOnPlatform(window, marioSpriteR, marioSpriteL, SCREENHEIGHT, goingDownBypass, vector, SCREENWIDTH, temp1, temp2, positionY, positionX);
//on platform
if (answer == 1)
{
//in mid section
if (currentCharacterPlacement >= leftEndzoneLine)
{
//josh, bit of a hack, was 10 to small, : 652
positionX = POSXCENTER;
//platform::SearchVectorForPlatforms(vector, window, VELOCITYX, 0.0f, 0);
currentCharacterPlacement = currentCharacterPlacement - VELOCITYX;
if (currentCharacterPlacement < leftEndzoneLine)
{
marioSpriteL.setPosition(positionX, positionY);
marioSpriteR.setPosition(positionX, positionY);
return(1);
}
//currentLeftEdge = currentLeftEdge - VELOCITYX;
marioSpriteL.setPosition(POSXCENTER, positionY);
marioSpriteR.setPosition(POSXCENTER, positionY);
//platform::SearchVectorForPlatforms(vector, window, 0, 0.0f, 0);
//window.clear();
//window.draw(marioSpriteR);
isMoving = "left";
//platform::SearchVectorForPlatforms(vector, window, VELOCITYX, 0.0f, 0);
////window.display();
return(1);
}
//in left endzone, on platform
else
{
currentCharacterPlacement = currentCharacterPlacement - VELOCITYX;
//currentLeftEdge = currentLeftEdge - VELOCITYX;
//left wall
marioSpriteL.setPosition(positionX, positionY);
marioSpriteR.setPosition(positionX, positionY);
positionX = positionX - VELOCITYX;
////window.clear();
//window.draw(marioSpriteR);
////character.isMoving == "none";
//platform::SearchVectorForPlatforms(vector, window, 0, 0.0f, 0);
//window.display();
//JOSH, ?
return(1);
}
//is still on platform?
answer = character.isOnPlatform(window, marioSpriteR, marioSpriteL, SCREENHEIGHT, goingDownBypass, vector, SCREENWIDTH, temp1, temp2, positionY, positionX);
//was on, moved off
if (answer == 0)
{
return(-1);
}
//still on platform after move
else
{ //mid section
if (currentCharacterPlacement >= leftEndzoneLine)
{
currentCharacterPlacement = currentCharacterPlacement - VELOCITYX;
if (currentCharacterPlacement < leftEndzoneLine)
{
marioSpriteL.setPosition(positionX, positionY);
marioSpriteR.setPosition(positionX, positionY);
return(1);
}
marioSpriteL.setPosition(POSXCENTER, positionY);
marioSpriteR.setPosition(POSXCENTER, positionY);
//window.clear();
window.draw(marioSpriteR);
//isMoving = "yes";
platform::SearchVectorForPlatforms(vector, window, VELOCITYX, 0.0f, 0);
//window.display();
return(1);
}
//leftendzone
else
{
//josh
currentCharacterPlacement = currentCharacterPlacement - VELOCITYX;
positionX = positionX - VELOCITYX;
//left wall
marioSpriteL.setPosition(positionX, positionY);
marioSpriteR.setPosition(positionX, positionY);
//window.clear();
////window.draw(marioSpriteR);
//haracter.isMoving == "none";
/////platform::SearchVectorForPlatforms(vector, window, 0 , 0.0f, 0);
////window.display();
return(1);
}
}
}//end of answer 1 - original, off platform
else
{
// was never on platform
//in left endzone
//move character twice to stay consistant with abpve. Idea is the player is on the ground
//so can't move on to a platform with double move
if (positionY >= SCREENHEIGHT - 76)
{
if (currentCharacterPlacement < leftEndzoneLine)
{
if (positionX < (0))
{
marioSpriteL.setPosition(0, positionY);
marioSpriteR.setPosition(0, positionY);
positionX = 0;
currentCharacterPlacement = 0;
return(1);
}
//not less than zero and is in left endzone
else
{
//left wall
currentCharacterPlacement = currentCharacterPlacement - VELOCITYX;
positionX = positionX - VELOCITYX;
//currentLeftEdge = currentLeftEdge - VELOCITYX;
marioSpriteL.setPosition(positionX, positionY);
marioSpriteR.setPosition(positionX, positionY);
window.clear();
window.draw(marioSpriteR);
//character.isMoving == "none";
platform::SearchVectorForPlatforms(vector, window, 0, 0.0f, 0);
//window.display();
return(1);
}
}
// moving left in mid zone
else
{
//josh, !!!!
//float rightSide = currentCharacterPlacement - leftEndzoneLine;
//float currentCharacterPlacement2 = currentCharacterPlacement;
currentCharacterPlacement = currentCharacterPlacement - VELOCITYX;
//float remainder = currentCharacterPlacement - currentCharacterPlacement2;
//if (currentCharacterPlacement2 >= leftEndzoneLine && currentCharacterPlacement < leftEndzoneLine)
//{
if (currentCharacterPlacement < leftEndzoneLine)
{
//here
//int leftAmount = leftEndzoneLine - currentCharacterPlacement;
//positionX = 362 - leftAmount;
marioSpriteL.setPosition(positionX, positionY);
marioSpriteR.setPosition(positionX, positionY);
return(1);
//platform::SearchVectorForPlatforms(vector, window, 1, 0.0f, 0);
}
else
{
//positionX = positionX - 2;
marioSpriteL.setPosition(POSXCENTER, positionY);
marioSpriteR.setPosition(POSXCENTER, positionY);
//window.clear();
isMoving = "left";
//josh, is this okay?
positionX = 362;
}
//character.EnemyObject->changePlatformEdgesForEnemy(window, 10);
////platform::SearchVectorForPlatforms(vectorPlatforms, window, -10, 0.0f, 0);
//character.EnemyObject->moveEnemies(window, 20, -10, 0);
//window.clear();
//window.draw(marioSpriteR);
//platform::SearchVectorForPlatforms(vector, window, VELOCITYX, 0.0f, 0);
//window.display();
return(1);
}
}
else
{
//not used //josh, look at this, there are four
int no = 0;
int goingDown2 = 0;
/////
//whileFunction(facingLeft, character, clock, window, marioSpriteR, marioSpriteL, SCREENHEIGHT, goingDown, vector, SCREENWIDTH, no, no, goingDown2, positionY, positionX);
return(-1);
/////
}
}
return(1);
}
int Character::movesRightInRightEndZoneToo(int facingLeft, const int SCREENHEIGHT, const int SCREENWIDTH, sf::RenderWindow & window, int& goingDown, int& characterLeft, int& characterY, std::vector<platform> & vector, sf::Sprite & marioSpriteL, sf::Sprite & marioSpriteR, Character & character, int& isLeft, float& positionY, float& positionX)
{
int goingDownBypass = 1;
//stops character at right wall
if (currentCharacterPlacement >= ((SCREENWIDTH / 2) + SCREENWIDTH + (SCREENWIDTH / 2) - 38))
{
currentCharacterPlacement = ((SCREENWIDTH / 2) + SCREENWIDTH + (SCREENWIDTH / 2) - 38);
return(1);
}
//not used
sf::Vector2f position = marioSpriteR.getPosition();
int temp1 = position.x;
int temp2 = position.y;
positionX = temp1;
positionY = temp2;
// first there is a check if on platform, than there is a change in position
// after position is changed there is an immediate check for off platform
// if not off platfomr the function runs again and once again is on platform
// changes position and checks for off platform.
//int notNeeded1, notNeeded2 = 0;
int answer = character.isOnPlatform(window, marioSpriteR, marioSpriteL, SCREENHEIGHT, goingDownBypass, vector, SCREENWIDTH, characterLeft, characterY, positionY, positionX);
//on platform
if (answer == 1)
{
//right endzone
//josh,...
platform::SearchVectorForPlatforms(vector, window, 0.0f, 0.0f, 0);
currentCharacterPlacement = currentCharacterPlacement + VELOCITYX;
positionX = positionX + VELOCITYX;
//currentLeftEdge = currentLeftEdge + VELOCITYX;
marioSpriteR.setPosition(positionX, positionY);
marioSpriteL.setPosition(positionX, positionY);
//is still on platform?
answer = character.isOnPlatform(window, marioSpriteR, marioSpriteL, SCREENHEIGHT, goingDownBypass, vector, SCREENWIDTH, characterLeft, characterY, positionY, positionX);
//was on, moved off
if (answer == 0)
{
return(-1);
}
//still on platform after move - right endzone - mmoves right
//josh, hack, two of these solve later
else
{
//platform::SearchVectorForPlatforms(vector, window, 0, 0.0f, 0);
//currentCharacterPlacement = currentCharacterPlacement + VELOCITYX;
//currentLeftEdge = currentLeftEdge - VELOCITYX;
//positionX = positionX + VELOCITYX;
marioSpriteL.setPosition(positionX, positionY);
marioSpriteR.setPosition(positionX, positionY);
//window.clear();
//window.draw(marioSpriteL);
//platform::SearchVectorForPlatforms(vector, window, 0.0f, 0.0f, 0);
//window.display();
return(1);
}
}//not on platform
if (positionY >= SCREENHEIGHT - 76)
{
//walk in right endzone, walks right
////////////////////
if ((currentCharacterPlacement >= rightEndzoneLine) && (positionY >= (SCREENHEIGHT)-(76)))
{
currentCharacterPlacement = currentCharacterPlacement + VELOCITYX;
positionX = positionX + VELOCITYX;
//currentLeftEdge = currentLeftEdge + VELOCITYX;
//isLeft = 0;
marioSpriteL.setPosition(positionX, (SCREENHEIGHT)-(76));
marioSpriteR.setPosition(positionX, (SCREENHEIGHT)-(76));
//window.clear();
//window.draw(marioSpriteL);
//platform::SearchVectorForPlatforms(vector, window, 0, 0, 1);
//window.display();
return(1);
}
}
else //josh, look at this, there are four
{
return(-1);
///////
///////
}
return(1);
}
////////////
//enemies first,
//for player, don't clear and do draw and do display. Keep platforms!
//in between both endzones or in left endzone
int Character::movesRightInEndZoneToo(int facingLeft, const int SCREENHEIGHT, const int SCREENWIDTH, sf::RenderWindow & window, int& goingDown, int& characterLeft, int& characterY, std::vector<platform> & vector, sf::Sprite & marioSpriteL, sf::Sprite & marioSpriteR, Character & character, int& isLeft, float& positionY, float& positionX)
{
//EnemyObject->moveEnemies(window, 2, -1, 0);
int goingDownBypass = 1;
//not in this section
if (currentCharacterPlacement >= rightEndzoneLine)
{
//calls while to drop
int val = movesRightInRightEndZoneToo(facingLeft, SCREENHEIGHT, SCREENWIDTH, window, goingDown, characterLeft, characterY, vector, marioSpriteL, marioSpriteR, character, isLeft, positionY, positionX);
{
if (val == -1)
{
return(-1);
}
return(1);
}
}
//not used anymore
sf::Vector2f position = marioSpriteR.getPosition();
int temp1 = position.x;
int temp2 = position.y;
//int notNeeded1, notNeeded2 = 0;
int answer = character.isOnPlatform(window, marioSpriteR, marioSpriteL, SCREENHEIGHT, goingDownBypass, vector, SCREENWIDTH, characterLeft, characterY, positionY, positionX);
//on platform
if (answer == 1)
{
//moving right in left hand endzone - on platform
if (currentCharacterPlacement < leftEndzoneLine)
{
//character.isMoving == "none";
//move platforms
//platform::SearchVectorForPlatforms(vector, window, 0.0f, 0.0f, 0);
currentCharacterPlacement = currentCharacterPlacement + VELOCITYX;
positionX = positionX + VELOCITYX;
marioSpriteL.setPosition(positionX, positionY);
marioSpriteR.setPosition(positionX, positionY);
if (currentCharacterPlacement >= leftEndzoneLine)
{
marioSpriteL.setPosition(POSXCENTER, positionY);
marioSpriteR.setPosition(POSXCENTER, positionY);
return(1);
}
////window.clear();
//window.draw(marioSpriteL);
//platform::SearchVectorForPlatforms(vector, window, 0.0f, 0.0f, 0);
//window.display();
return(1);
////currentLeftEdge = currentLeftEdge + VELOCITYX;
}
//moving right midzone - om platform
else
{
//platform::SearchVectorForPlatforms(vector, window, -VELOCITYX, 0.0f, 0);
currentCharacterPlacement = currentCharacterPlacement + VELOCITYX;
if (currentCharacterPlacement >= rightEndzoneLine)
{
return(1);
}
marioSpriteL.setPosition(POSXCENTER, positionY);
marioSpriteR.setPosition(POSXCENTER, positionY);
//window.clear();
isMoving = "right";
//window.draw(marioSpriteL);
//platform::SearchVectorForPlatforms(vector, window, -VELOCITYX, 0.0f, 0);
//window.display();
return(1);
//currentLeftEdge = currentLeftEdge + VELOCITYX;
}
//is still on platform?
answer = character.isOnPlatform(window, marioSpriteR, marioSpriteL, SCREENHEIGHT, goingDownBypass, vector, SCREENWIDTH, characterLeft, characterY, positionY, positionX);
//was on, moved off
if (answer == 0)
{
//drop - off platform
//remove these:
int no = 0;
int no1 = 0;
int goingDown2 = 0;
//calls fall
return(-1);
//whileFunction(facingLeft, character, clock, window, marioSpriteR, marioSpriteL, SCREENHEIGHT, goingDown, vector, SCREENWIDTH, no, no1, goingDown2, positionY, positionX);
}
//still on platform after move
else
{
//in mid zone
if (currentCharacterPlacement >= leftEndzoneLine)
{
//platform::SearchVectorForPlatforms(vector, window, 0, 0.0f, 0);
currentCharacterPlacement = currentCharacterPlacement + VELOCITYX;
if (currentCharacterPlacement >= rightEndzoneLine)
{
return(1);
}
isMoving = "right";
//currentLeftEdge = currentLeftEdge - VELOCITYX;
//positionX = positionX + VELOCITYX;
marioSpriteL.setPosition(POSXCENTER, positionY);
marioSpriteR.setPosition(POSXCENTER, positionY);
//window.clear();
//window.draw(marioSpriteL);
//platform::SearchVectorForPlatforms(vector, window, -VELOCITYX, 0.0f, 0);
//window.display();
return(1);
}
//in leftzone
else
{
//character.isMoving == "none";
currentCharacterPlacement = currentCharacterPlacement + VELOCITYX;
positionX = positionX + VELOCITYX;
if (currentCharacterPlacement >= rightEndzoneLine)
{
marioSpriteL.setPosition(POSXCENTER, positionY);
marioSpriteR.setPosition(POSXCENTER, positionY);
return(1);
}
marioSpriteL.setPosition(positionX, positionY);
marioSpriteR.setPosition(positionX, positionY);
//window.clear();
//window.draw(marioSpriteL);
//platform::SearchVectorForPlatforms(vector, window,0, 0.0f, 0);
//window.display();
return(1);
}
}
}
//not on platform
else
{
//not on platform
if (positionY >= SCREENHEIGHT - 76)
{
//not on platform
//left endzone
if (currentCharacterPlacement < leftEndzoneLine)
{
//platform::SearchVectorForPlatforms(vector, window, -2.0f, 0.0f, 0);
currentCharacterPlacement = currentCharacterPlacement + VELOCITYX;
positionX = positionX + VELOCITYX;
if (currentCharacterPlacement >= leftEndzoneLine)
{
positionX = 362;
marioSpriteL.setPosition(POSXCENTER, positionY);
marioSpriteR.setPosition(POSXCENTER, positionY);
return(1);
}
//currentLeftEdge = currentLeftEdge + VELOCITYX;
//isLeft = 0;
marioSpriteL.setPosition(positionX, positionY);
marioSpriteR.setPosition(positionX, positionY);
//if (currentCharacterPlacement >= leftEndzoneLine)
//{
// positionX = 362;
// marioSpriteL.setPosition(positionX, positionY);
// marioSpriteR.setPosition(positionX, positionY);
//
//
//}
//window.clear();
//runs on every press of 'S'
//window.draw(marioSpriteL);
//platform::SearchVectorForPlatforms(vector, window, 0, 0, 1);
//character.isMoving = "none";
//EnemyObject->moveEnemies(window, 2, 0, 0);
//window.display();
return(1);
}
//in middle - moving right - not on platform
else
{
currentCharacterPlacement = currentCharacterPlacement + VELOCITYX;
if (currentCharacterPlacement >= rightEndzoneLine)
{
return(1);
}
//currentLeftEdge = currentLeftEdge + VELOCITYX;
marioSpriteL.setPosition(POSXCENTER, positionY);
marioSpriteR.setPosition(POSXCENTER, positionY);
//josh, look at this
//window.clear();
//window.draw(marioSpriteL);
isMoving = "right";
//platform::SearchVectorForPlatforms(vector, window, -VELOCITYX, 0.0f, 0);
//EnemyObject->changePlatformEdgesForEnemy(window, -5);
//window.display();
return(1);
}
}//is not on ground -- josh, look at this, there are four
else
{
int no = 0;
int goingDown2 = 0;
//whileFunction(facingLeft, character, clock, window, marioSpriteR, marioSpriteL, SCREENHEIGHT, goingDown, vector, SCREENWIDTH, no, no, goingDown2, positionY, positionX);
return(-1);
}
}
return(1);
}
////////////
//
//
///////
//moves character up and down and moves platforms too (left and right)
int Character::JumpInEndZone(int& line, const int SCREENWIDTH, const int SCREENHEIGHT, Character & character, std::vector<platform> & vector, float& positionX, float& positionY, float& velocityY, float& velocityX,
float& gravity, int facingLeft, sf::RenderWindow & window, sf::Sprite & marioSpriteR, sf::Sprite & marioSpriteL, int& goingDown, int& characterOnBar)
{
//josh, for now
//goingDown = 1;
//highestPlatform = 1;
//do {
clock1.restart();
sf::Time elapsed1 = clock1.getElapsedTime();
while (elapsed1.asMilliseconds() <= 40)
{
elapsed1 = clock1.getElapsedTime();
}
clock1.restart();
//sets horizontal velocity to right or left
if (facingLeft == 1)
{
//character.EnemyObject->changePlatformEdgesForEnemy(window, -11);
velocityX = -VELOCITYX;
currentCharacterPlacement = currentCharacterPlacement - VELOCITYX;
if ((positionX > leftEndzoneLine) && (positionX < rightEndzoneLine))
{
//character.gPlatformsMoved == "left";
//character.EnemyObject->changePlatformEdgesForEnemy(window, 20);
//character.EnemyObject->moveEnemies(window, 10, -0, 0);
}
}
else
{
//character.EnemyObject->changePlatformEdgesForEnemy(window, -11);
velocityX = VELOCITYX;
currentCharacterPlacement = currentCharacterPlacement + VELOCITYX;
if ((positionX > leftEndzoneLine) && (positionX < rightEndzoneLine))
{
//character.gPlatformsMoved == "right";
//character.EnemyObject->changePlatformEdgesForEnemy(window, -20);
//character.EnemyObject->moveEnemies(window, -10, 0, 0);
}
}
int firstPositionX = positionX;
int firstPositionY = positionY;
//runs each time and updates postionx and positiony
positionY += velocityY;
positionX += velocityX;
velocityY += gravity;
int secondPositionY = positionY;
int secondPositionX = positionX;
//if positive going down - not working yet
int horizontalChange = secondPositionX - firstPositionX;
//for dropping
if (firstPositionY > secondPositionY)
{
// //use this later
goingDown = 0;
//highestPlatform = 0;
}
if (firstPositionY <= secondPositionY)
{
//highestPlatform = 1;
goingDown = 1;
}
//if landing with jump
if (positionY > (600 - 76))
{
positionY = (600 - 76);
//in right endzone
if (currentCharacterPlacement >= rightEndzoneLine)
{
gPlatformsMoved = "none";
marioSpriteL.setPosition(positionX, 600 - 76);
marioSpriteR.setPosition(positionX, 600 - 76);
//window.clear();
//window.draw(marioSpriteR);
//miscObject->moveEnemies(window, 10, 0, 0);
//platform::SearchVectorForPlatforms(vector, window, 0, 0, 0);
//character.EnemyObject->moveEnemies(window, 20, 0, 0);
//window.display();
//Sleep(40);
return(1);
//continue;
}//in mid zone
//this was positionX instead
else if (currentCharacterPlacement >= leftEndzoneLine)
{
if (facingLeft == 1)
{
gPlatformsMoved = "left";
}
else
{
gPlatformsMoved = "right";
}
//marioSpriteL.setPosition((SCREENWIDTH / 2) - (76 / 2), 600 - 76);
//marioSpriteR.setPosition((SCREENWIDTH / 2) - (76 / 2), 600 - 76);
positionX = POSXCENTER;
marioSpriteL.setPosition(positionX, 600 - 76);
marioSpriteR.setPosition(positionX, 600 - 76);
//platform::SearchVectorForPlatforms(vector, window, -VELOCITYX, 0, 1);
//window.clear();
//window.draw(marioSpriteR);
//miscObject->moveEnemies(window, 10, 0, 0);
////sjcharacter.EnemyObject->changePlatformEdgesForEnemy(window, 10);
//platform::SearchVectorForPlatforms(vector, window, -velocityX, 0, 1);
//character.EnemyObject->moveEnemies(window, 20, 0, 0);
//window.display();
//if (facingLeft == 1)
//{
//
// character.gPlatformsMoved = "left";
//}
//else
//{
//character.gPlatformsMoved = "right";
//}
return(1);
//continue;
}
else
{ //left endzone
gPlatformsMoved = "none";
marioSpriteL.setPosition(positionX, 600 - 76);
marioSpriteR.setPosition(positionX, 600 - 76);
//window.clear();
//window.draw(marioSpriteR);
//miscObject->moveEnemies(window, 10, 0, 0);
//platform::SearchVectorForPlatforms(vector, window, 0, 0, 0);
//character.EnemyObject->moveEnemies(window, 20, 0, 0);
//window.display();
return(1);