Changeset 10999 for code/branches/cpp11_v2/src/modules/jump
- Timestamp:
- Dec 30, 2015, 2:31:14 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/modules/jump/Jump.cc
r10920 r10999 610 610 const int numJ = 4; 611 611 612 enum PlatformType613 { 614 PLATFORM_EMPTY, PLATFORM_STATIC, PLATFORM_HMOVE, PLATFORM_VMOVE, PLATFORM_DISAPPEAR, PLATFORM_TIMER, PLATFORM_FAKE612 enum class PlatformType 613 { 614 EMPTY, STATIC, HMOVE, VMOVE, DISAPPEAR, TIMER, FAKE 615 615 }; 616 616 617 enum ItemType618 { 619 ITEM_NOTHING, ITEM_SPRING, ITEM_PROPELLER, ITEM_ROCKET, ITEM_BOOTS, ITEM_SHIELD617 enum class ItemType 618 { 619 NOTHING, SPRING, PROPELLER, ROCKET, BOOTS, SHIELD 620 620 }; 621 621 … … 631 631 for (int j = 0; j < numJ; ++j) 632 632 { 633 matrix[i][j].type = P LATFORM_EMPTY;633 matrix[i][j].type = PlatformType::EMPTY; 634 634 matrix[i][j].done = false; 635 635 } … … 637 637 PlatformType platformtype1; 638 638 PlatformType platformtype2; 639 ItemType itemType = I TEM_NOTHING;639 ItemType itemType = ItemType::NOTHING; 640 640 641 641 if (rand()%2 == 0) 642 642 { 643 itemType = I TEM_SPRING;643 itemType = ItemType::SPRING; 644 644 } 645 645 else if (rand()%2 == 0 && sectionNumber_ > 3) … … 648 648 { 649 649 case 0: 650 itemType = I TEM_PROPELLER;650 itemType = ItemType::PROPELLER; 651 651 break; 652 652 case 1: 653 itemType = I TEM_ROCKET;653 itemType = ItemType::ROCKET; 654 654 break; 655 655 case 2: 656 itemType = I TEM_BOOTS;656 itemType = ItemType::BOOTS; 657 657 break; 658 658 case 3: 659 itemType = I TEM_SHIELD;659 itemType = ItemType::SHIELD; 660 660 break; 661 661 default: … … 667 667 { 668 668 case 0: 669 platformtype1 = P LATFORM_STATIC;670 platformtype2 = P LATFORM_STATIC;669 platformtype1 = PlatformType::STATIC; 670 platformtype2 = PlatformType::STATIC; 671 671 break; 672 672 case 1: 673 platformtype1 = P LATFORM_STATIC;674 platformtype2 = P LATFORM_STATIC;673 platformtype1 = PlatformType::STATIC; 674 platformtype2 = PlatformType::STATIC; 675 675 break; 676 676 case 2: 677 platformtype1 = P LATFORM_STATIC;678 platformtype2 = P LATFORM_HMOVE;677 platformtype1 = PlatformType::STATIC; 678 platformtype2 = PlatformType::HMOVE; 679 679 break; 680 680 case 3: 681 platformtype1 = P LATFORM_STATIC;682 platformtype2 = P LATFORM_DISAPPEAR;681 platformtype1 = PlatformType::STATIC; 682 platformtype2 = PlatformType::DISAPPEAR; 683 683 break; 684 684 case 4: 685 platformtype1 = P LATFORM_STATIC;686 platformtype2 = P LATFORM_VMOVE;685 platformtype1 = PlatformType::STATIC; 686 platformtype2 = PlatformType::VMOVE; 687 687 break; 688 688 case 5: 689 platformtype1 = P LATFORM_STATIC;690 platformtype2 = P LATFORM_TIMER;689 platformtype1 = PlatformType::STATIC; 690 platformtype2 = PlatformType::TIMER; 691 691 break; 692 692 case 6: 693 platformtype1 = P LATFORM_HMOVE;694 platformtype2 = P LATFORM_STATIC;693 platformtype1 = PlatformType::HMOVE; 694 platformtype2 = PlatformType::STATIC; 695 695 break; 696 696 case 7: 697 platformtype1 = P LATFORM_HMOVE;698 platformtype2 = P LATFORM_HMOVE;697 platformtype1 = PlatformType::HMOVE; 698 platformtype2 = PlatformType::HMOVE; 699 699 break; 700 700 case 8: 701 platformtype1 = P LATFORM_HMOVE;702 platformtype2 = P LATFORM_HMOVE;701 platformtype1 = PlatformType::HMOVE; 702 platformtype2 = PlatformType::HMOVE; 703 703 break; 704 704 case 9: 705 platformtype1 = P LATFORM_HMOVE;706 platformtype2 = P LATFORM_DISAPPEAR;705 platformtype1 = PlatformType::HMOVE; 706 platformtype2 = PlatformType::DISAPPEAR; 707 707 break; 708 708 case 10: 709 platformtype1 = P LATFORM_HMOVE;710 platformtype2 = P LATFORM_VMOVE;709 platformtype1 = PlatformType::HMOVE; 710 platformtype2 = PlatformType::VMOVE; 711 711 break; 712 712 case 11: 713 platformtype1 = P LATFORM_HMOVE;714 platformtype2 = P LATFORM_TIMER;713 platformtype1 = PlatformType::HMOVE; 714 platformtype2 = PlatformType::TIMER; 715 715 break; 716 716 case 12: 717 platformtype1 = P LATFORM_DISAPPEAR;718 platformtype2 = P LATFORM_STATIC;717 platformtype1 = PlatformType::DISAPPEAR; 718 platformtype2 = PlatformType::STATIC; 719 719 break; 720 720 case 13: 721 platformtype1 = P LATFORM_DISAPPEAR;722 platformtype2 = P LATFORM_HMOVE;721 platformtype1 = PlatformType::DISAPPEAR; 722 platformtype2 = PlatformType::HMOVE; 723 723 break; 724 724 case 14: 725 platformtype1 = P LATFORM_DISAPPEAR;726 platformtype2 = P LATFORM_DISAPPEAR;725 platformtype1 = PlatformType::DISAPPEAR; 726 platformtype2 = PlatformType::DISAPPEAR; 727 727 break; 728 728 case 15: 729 platformtype1 = P LATFORM_DISAPPEAR;730 platformtype2 = P LATFORM_DISAPPEAR;729 platformtype1 = PlatformType::DISAPPEAR; 730 platformtype2 = PlatformType::DISAPPEAR; 731 731 break; 732 732 case 16: 733 platformtype1 = P LATFORM_DISAPPEAR;734 platformtype2 = P LATFORM_VMOVE;733 platformtype1 = PlatformType::DISAPPEAR; 734 platformtype2 = PlatformType::VMOVE; 735 735 break; 736 736 case 17: 737 platformtype1 = P LATFORM_DISAPPEAR;738 platformtype2 = P LATFORM_TIMER;737 platformtype1 = PlatformType::DISAPPEAR; 738 platformtype2 = PlatformType::TIMER; 739 739 break; 740 740 case 18: 741 platformtype1 = P LATFORM_VMOVE;742 platformtype2 = P LATFORM_STATIC;741 platformtype1 = PlatformType::VMOVE; 742 platformtype2 = PlatformType::STATIC; 743 743 break; 744 744 case 19: 745 platformtype1 = P LATFORM_VMOVE;746 platformtype2 = P LATFORM_HMOVE;745 platformtype1 = PlatformType::VMOVE; 746 platformtype2 = PlatformType::HMOVE; 747 747 break; 748 748 case 20: 749 platformtype1 = P LATFORM_VMOVE;750 platformtype2 = P LATFORM_DISAPPEAR;749 platformtype1 = PlatformType::VMOVE; 750 platformtype2 = PlatformType::DISAPPEAR; 751 751 break; 752 752 case 21: 753 platformtype1 = P LATFORM_VMOVE;754 platformtype2 = P LATFORM_VMOVE;753 platformtype1 = PlatformType::VMOVE; 754 platformtype2 = PlatformType::VMOVE; 755 755 break; 756 756 case 22: 757 platformtype1 = P LATFORM_VMOVE;758 platformtype2 = P LATFORM_VMOVE;757 platformtype1 = PlatformType::VMOVE; 758 platformtype2 = PlatformType::VMOVE; 759 759 break; 760 760 case 23: 761 platformtype1 = P LATFORM_VMOVE;762 platformtype2 = P LATFORM_TIMER;761 platformtype1 = PlatformType::VMOVE; 762 platformtype2 = PlatformType::TIMER; 763 763 break; 764 764 case 24: 765 platformtype1 = P LATFORM_TIMER;766 platformtype2 = P LATFORM_STATIC;765 platformtype1 = PlatformType::TIMER; 766 platformtype2 = PlatformType::STATIC; 767 767 break; 768 768 case 25: 769 platformtype1 = P LATFORM_TIMER;770 platformtype2 = P LATFORM_HMOVE;769 platformtype1 = PlatformType::TIMER; 770 platformtype2 = PlatformType::HMOVE; 771 771 break; 772 772 case 26: 773 platformtype1 = P LATFORM_TIMER;774 platformtype2 = P LATFORM_DISAPPEAR;773 platformtype1 = PlatformType::TIMER; 774 platformtype2 = PlatformType::DISAPPEAR; 775 775 break; 776 776 case 27: 777 platformtype1 = P LATFORM_TIMER;778 platformtype2 = P LATFORM_VMOVE;777 platformtype1 = PlatformType::TIMER; 778 platformtype2 = PlatformType::VMOVE; 779 779 break; 780 780 case 28: 781 platformtype1 = P LATFORM_TIMER;782 platformtype2 = P LATFORM_TIMER;781 platformtype1 = PlatformType::TIMER; 782 platformtype2 = PlatformType::TIMER; 783 783 break; 784 784 default: 785 platformtype1 = P LATFORM_TIMER;786 platformtype2 = P LATFORM_TIMER;785 platformtype1 = PlatformType::TIMER; 786 platformtype2 = PlatformType::TIMER; 787 787 break; 788 788 } … … 807 807 if (platformtype1 == platformtype2 && sectionNumber_ > 10 && rand()%2 == 0) 808 808 { 809 matrix[rand()%numI][rand()%numJ].type = P LATFORM_EMPTY;810 matrix[rand()%numI][rand()%numJ].type = P LATFORM_EMPTY;809 matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; 810 matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; 811 811 } 812 812 … … 816 816 if (rand()%2 == 0) 817 817 { 818 matrix[rand()%numI][rand()%numJ].type = P LATFORM_EMPTY;819 } 820 else 821 { 822 matrix[rand()%numI][rand()%numJ].type = P LATFORM_FAKE;818 matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; 819 } 820 else 821 { 822 matrix[rand()%numI][rand()%numJ].type = PlatformType::FAKE; 823 823 } 824 824 } … … 827 827 if (rand()%2 == 0) 828 828 { 829 matrix[rand()%numI][rand()%numJ].type = P LATFORM_EMPTY;830 } 831 else 832 { 833 matrix[rand()%numI][rand()%numJ].type = P LATFORM_FAKE;829 matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; 830 } 831 else 832 { 833 matrix[rand()%numI][rand()%numJ].type = PlatformType::FAKE; 834 834 } 835 835 if (rand()%2 == 0) 836 836 { 837 matrix[rand()%numI][rand()%numJ].type = P LATFORM_EMPTY;838 } 839 else 840 { 841 matrix[rand()%numI][rand()%numJ].type = P LATFORM_FAKE;837 matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; 838 } 839 else 840 { 841 matrix[rand()%numI][rand()%numJ].type = PlatformType::FAKE; 842 842 } 843 843 } … … 846 846 if (rand()%2 == 0) 847 847 { 848 matrix[rand()%numI][rand()%numJ].type = P LATFORM_EMPTY;849 } 850 else 851 { 852 matrix[rand()%numI][rand()%numJ].type = P LATFORM_FAKE;848 matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; 849 } 850 else 851 { 852 matrix[rand()%numI][rand()%numJ].type = PlatformType::FAKE; 853 853 } 854 854 if (rand()%2 == 0) 855 855 { 856 matrix[rand()%numI][rand()%numJ].type = P LATFORM_EMPTY;857 } 858 else 859 { 860 matrix[rand()%numI][rand()%numJ].type = P LATFORM_FAKE;856 matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; 857 } 858 else 859 { 860 matrix[rand()%numI][rand()%numJ].type = PlatformType::FAKE; 861 861 } 862 862 if (rand()%2 == 0) 863 863 { 864 matrix[rand()%numI][rand()%numJ].type = P LATFORM_EMPTY;865 } 866 else 867 { 868 matrix[rand()%numI][rand()%numJ].type = P LATFORM_FAKE;864 matrix[rand()%numI][rand()%numJ].type = PlatformType::EMPTY; 865 } 866 else 867 { 868 matrix[rand()%numI][rand()%numJ].type = PlatformType::FAKE; 869 869 } 870 870 } … … 889 889 switch(matrix[i][j].type) 890 890 { 891 case P LATFORM_EMPTY:891 case PlatformType::EMPTY: 892 892 matrix[i][j].done = true; 893 893 break; 894 case P LATFORM_STATIC:894 case PlatformType::STATIC: 895 895 xPosition = randomXPosition(numJ, j); 896 896 zPosition = sectionBegin + i*sectionLength/numI; … … 898 898 matrix[i][j].done = true; 899 899 break; 900 case P LATFORM_FAKE:900 case PlatformType::FAKE: 901 901 xPosition = randomXPosition(numJ, j); 902 902 zPosition = sectionBegin + i*sectionLength/numI; … … 904 904 matrix[i][j].done = true; 905 905 break; 906 case P LATFORM_TIMER:906 case PlatformType::TIMER: 907 907 xPosition = randomXPosition(numJ, j); 908 908 zPosition = sectionBegin + i*sectionLength/numI; … … 910 910 matrix[i][j].done = true; 911 911 break; 912 case P LATFORM_DISAPPEAR:912 case PlatformType::DISAPPEAR: 913 913 xPosition = randomXPosition(numJ, j); 914 914 zPosition = sectionBegin + i*sectionLength/numI; … … 916 916 matrix[i][j].done = true; 917 917 break; 918 case P LATFORM_HMOVE:918 case PlatformType::HMOVE: 919 919 xVelocity = randomSpeed(); 920 if (j <= numJ-3 && matrix[i][j+1].type == P LATFORM_HMOVE && matrix[i][j+2].type == PLATFORM_HMOVE && rand()%2 == 0)920 if (j <= numJ-3 && matrix[i][j+1].type == PlatformType::HMOVE && matrix[i][j+2].type == PlatformType::HMOVE && rand()%2 == 0) 921 921 { 922 922 leftBoundary = randomXPositionLeft(numJ, j); … … 929 929 matrix[i][j+2].done = true; 930 930 } 931 else if (j <= numJ-2 && matrix[i][j+1].type == P LATFORM_HMOVE && rand()%2 == 0)931 else if (j <= numJ-2 && matrix[i][j+1].type == PlatformType::HMOVE && rand()%2 == 0) 932 932 { 933 933 leftBoundary = randomXPositionLeft(numJ, j); … … 949 949 } 950 950 break; 951 case P LATFORM_VMOVE:951 case PlatformType::VMOVE: 952 952 zVelocity = randomSpeed(); 953 if (i <= numI-3 && matrix[i+1][j].type == P LATFORM_VMOVE && matrix[i+2][j].type == PLATFORM_VMOVE && rand()%2 == 0)953 if (i <= numI-3 && matrix[i+1][j].type == PlatformType::VMOVE && matrix[i+2][j].type == PlatformType::VMOVE && rand()%2 == 0) 954 954 { 955 955 lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd); … … 962 962 matrix[i+2][j].done = true; 963 963 } 964 else if (i <= numI-2 && matrix[i+1][j].type == P LATFORM_VMOVE && rand()%2 == 0)964 else if (i <= numI-2 && matrix[i+1][j].type == PlatformType::VMOVE && rand()%2 == 0) 965 965 { 966 966 lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd); … … 1000 1000 switch (itemType) 1001 1001 { 1002 case I TEM_ROCKET:1002 case ItemType::ROCKET: 1003 1003 addRocket(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0); 1004 1004 break; 1005 case I TEM_PROPELLER:1005 case ItemType::PROPELLER: 1006 1006 addPropeller(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0); 1007 1007 break; 1008 case I TEM_BOOTS:1008 case ItemType::BOOTS: 1009 1009 addBoots(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0); 1010 1010 break; 1011 case I TEM_SHIELD:1011 case ItemType::SHIELD: 1012 1012 addShield(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0); 1013 1013 break; … … 1020 1020 switch (itemType) 1021 1021 { 1022 case I TEM_ROCKET:1022 case ItemType::ROCKET: 1023 1023 addRocket(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed()); 1024 1024 break; 1025 case I TEM_PROPELLER:1025 case ItemType::PROPELLER: 1026 1026 addPropeller(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed()); 1027 1027 break; 1028 case I TEM_BOOTS:1028 case ItemType::BOOTS: 1029 1029 addBoots(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed()); 1030 1030 break; 1031 case I TEM_SHIELD:1031 case ItemType::SHIELD: 1032 1032 addShield(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed()); 1033 1033 break; … … 1045 1045 switch (itemType) 1046 1046 { 1047 case I TEM_SPRING:1047 case ItemType::SPRING: 1048 1048 addSpring(itemPlatform); 1049 1049 break; 1050 case I TEM_ROCKET:1050 case ItemType::ROCKET: 1051 1051 addRocket(itemPlatform); 1052 1052 break; 1053 case I TEM_PROPELLER:1053 case ItemType::PROPELLER: 1054 1054 addPropeller(itemPlatform); 1055 1055 break; 1056 case I TEM_BOOTS:1056 case ItemType::BOOTS: 1057 1057 addBoots(itemPlatform); 1058 1058 break; 1059 case I TEM_SHIELD:1059 case ItemType::SHIELD: 1060 1060 addShield(itemPlatform); 1061 1061 break;
Note: See TracChangeset
for help on using the changeset viewer.