![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Adam Baker 201166301
Dependencies: mbed Gamepad N5110
Levels/Levels.h@50:9fc8edf722a8, 2019-05-09 (annotated)
- Committer:
- adambakerwa
- Date:
- Thu May 09 12:10:41 2019 +0000
- Revision:
- 50:9fc8edf722a8
Final Submission. I have read and agreed with Statement of Academic Integrity
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
adambakerwa | 50:9fc8edf722a8 | 1 | #ifndef LEVELS_H |
adambakerwa | 50:9fc8edf722a8 | 2 | #define LEVELS_H |
adambakerwa | 50:9fc8edf722a8 | 3 | |
adambakerwa | 50:9fc8edf722a8 | 4 | #include "mbed.h" |
adambakerwa | 50:9fc8edf722a8 | 5 | #include "Gamepad.h" |
adambakerwa | 50:9fc8edf722a8 | 6 | #include "N5110.h" |
adambakerwa | 50:9fc8edf722a8 | 7 | /** Pos struct for position of moving platforms and spikes*/ |
adambakerwa | 50:9fc8edf722a8 | 8 | struct Pos { |
adambakerwa | 50:9fc8edf722a8 | 9 | //////////hoz1////////// |
adambakerwa | 50:9fc8edf722a8 | 10 | int x; /**< x cord of hoz1 */ |
adambakerwa | 50:9fc8edf722a8 | 11 | int y; /**< y cord of hoz1 */ |
adambakerwa | 50:9fc8edf722a8 | 12 | int d; /**< direction of hoz1 (0 is right, 1 is left) */ |
adambakerwa | 50:9fc8edf722a8 | 13 | int c; /**< counter for hoz1 */ |
adambakerwa | 50:9fc8edf722a8 | 14 | int l; /**< length of hoz1 */ |
adambakerwa | 50:9fc8edf722a8 | 15 | int h; /**< height of hoz1 */ |
adambakerwa | 50:9fc8edf722a8 | 16 | //////////hoz2////////// |
adambakerwa | 50:9fc8edf722a8 | 17 | int x2; /**< x cord of hoz2 */ |
adambakerwa | 50:9fc8edf722a8 | 18 | int y2; /**< y cord of hoz2 */ |
adambakerwa | 50:9fc8edf722a8 | 19 | int d2; /**< direction of hoz2 (0 is right, 1 is left) */ |
adambakerwa | 50:9fc8edf722a8 | 20 | int c2; /**< counter for hoz2 */ |
adambakerwa | 50:9fc8edf722a8 | 21 | int l2; /**< length of hoz2 */ |
adambakerwa | 50:9fc8edf722a8 | 22 | int h2; /**< length of hoz2 */ |
adambakerwa | 50:9fc8edf722a8 | 23 | //////////ver1////////// |
adambakerwa | 50:9fc8edf722a8 | 24 | int vx; /**< x cord of ver1 */ |
adambakerwa | 50:9fc8edf722a8 | 25 | int vy; /**< y cord of ver1 */ |
adambakerwa | 50:9fc8edf722a8 | 26 | int vd; /**< direction of ver 1 (0 is down, 1 is up) */ |
adambakerwa | 50:9fc8edf722a8 | 27 | int vc; /**< counter for ver1 */ |
adambakerwa | 50:9fc8edf722a8 | 28 | int vl; /**< length of ver1 */ |
adambakerwa | 50:9fc8edf722a8 | 29 | int vh; /**< height of ver1 */ |
adambakerwa | 50:9fc8edf722a8 | 30 | //////////ver2////////// |
adambakerwa | 50:9fc8edf722a8 | 31 | int vx2; /**< x cord of ver2 */ |
adambakerwa | 50:9fc8edf722a8 | 32 | int vy2; /**< y cord of ver2 */ |
adambakerwa | 50:9fc8edf722a8 | 33 | int vd2; /**< direction of ver2 (0 is down, 1 is up) */ |
adambakerwa | 50:9fc8edf722a8 | 34 | int vc2; /**< counter for ver2 */ |
adambakerwa | 50:9fc8edf722a8 | 35 | int vl2; /**< length of ver2 */ |
adambakerwa | 50:9fc8edf722a8 | 36 | int vh2; /**< height of ver2 */ |
adambakerwa | 50:9fc8edf722a8 | 37 | //////////spikes////////// |
adambakerwa | 50:9fc8edf722a8 | 38 | int sx; /**< x cord of spikes */ |
adambakerwa | 50:9fc8edf722a8 | 39 | int sy; /**< y cord of spikes */ |
adambakerwa | 50:9fc8edf722a8 | 40 | int sl; /**< length of spikes */ |
adambakerwa | 50:9fc8edf722a8 | 41 | |
adambakerwa | 50:9fc8edf722a8 | 42 | }; |
adambakerwa | 50:9fc8edf722a8 | 43 | |
adambakerwa | 50:9fc8edf722a8 | 44 | |
adambakerwa | 50:9fc8edf722a8 | 45 | /** Levels Class |
adambakerwa | 50:9fc8edf722a8 | 46 | * @brief Class for creating and printing levels |
adambakerwa | 50:9fc8edf722a8 | 47 | * @author Adam P. Baker |
adambakerwa | 50:9fc8edf722a8 | 48 | * @date 9 May 2019 |
adambakerwa | 50:9fc8edf722a8 | 49 | */ |
adambakerwa | 50:9fc8edf722a8 | 50 | class Levels |
adambakerwa | 50:9fc8edf722a8 | 51 | { |
adambakerwa | 50:9fc8edf722a8 | 52 | public: |
adambakerwa | 50:9fc8edf722a8 | 53 | /** Constructor */ |
adambakerwa | 50:9fc8edf722a8 | 54 | Levels(); |
adambakerwa | 50:9fc8edf722a8 | 55 | |
adambakerwa | 50:9fc8edf722a8 | 56 | /** Deconstructor */ |
adambakerwa | 50:9fc8edf722a8 | 57 | ~Levels(); |
adambakerwa | 50:9fc8edf722a8 | 58 | |
adambakerwa | 50:9fc8edf722a8 | 59 | /** Initialises all variables and pos struct. |
adambakerwa | 50:9fc8edf722a8 | 60 | *@returns pos struct |
adambakerwa | 50:9fc8edf722a8 | 61 | */ |
adambakerwa | 50:9fc8edf722a8 | 62 | Pos init(Pos pos); |
adambakerwa | 50:9fc8edf722a8 | 63 | |
adambakerwa | 50:9fc8edf722a8 | 64 | /** Displays the level Blockhead is on |
adambakerwa | 50:9fc8edf722a8 | 65 | *@param N5110 class which controlls lcd screen |
adambakerwa | 50:9fc8edf722a8 | 66 | *@param what level Blockhead is on (int) |
adambakerwa | 50:9fc8edf722a8 | 67 | *@returns pos struct |
adambakerwa | 50:9fc8edf722a8 | 68 | */ |
adambakerwa | 50:9fc8edf722a8 | 69 | Pos what_level(N5110 &lcd, int level); |
adambakerwa | 50:9fc8edf722a8 | 70 | |
adambakerwa | 50:9fc8edf722a8 | 71 | private: |
adambakerwa | 50:9fc8edf722a8 | 72 | |
adambakerwa | 50:9fc8edf722a8 | 73 | Pos init_hoz1(Pos pos); //initializes data for horizontal moving platform 1 |
adambakerwa | 50:9fc8edf722a8 | 74 | Pos init_hoz2(Pos pos); //initializes data for horizontal moving platform 2 |
adambakerwa | 50:9fc8edf722a8 | 75 | Pos init_ver1(Pos pos); //initializes data for vertical moving platform 1 |
adambakerwa | 50:9fc8edf722a8 | 76 | Pos init_ver2(Pos pos); //initializes data for vertical moving platform 2 |
adambakerwa | 50:9fc8edf722a8 | 77 | Pos init_spike(Pos pos); //initializes data for spikes |
adambakerwa | 50:9fc8edf722a8 | 78 | void init_counter1(); //initializes counter 1 |
adambakerwa | 50:9fc8edf722a8 | 79 | void init_counter2(); //initializes counter 2 |
adambakerwa | 50:9fc8edf722a8 | 80 | |
adambakerwa | 50:9fc8edf722a8 | 81 | Pos pass_data_hoz1(Pos pos, Pos hoz); //transfer hoz1 into spare variables of original pos struct. |
adambakerwa | 50:9fc8edf722a8 | 82 | Pos pass_data_hoz2(Pos pos, Pos hoz2); //transfer hoz2 into spare variables of original pos struct. |
adambakerwa | 50:9fc8edf722a8 | 83 | Pos pass_data_ver1(Pos pos, Pos ver); //transfer ver into spare variables of original pos struct. |
adambakerwa | 50:9fc8edf722a8 | 84 | Pos pass_data_ver2(Pos pos, Pos ver2); //transfer ver2 into spare variables of original pos struct. |
adambakerwa | 50:9fc8edf722a8 | 85 | |
adambakerwa | 50:9fc8edf722a8 | 86 | Pos moving_platform_hoz(N5110 &lcd, Pos pos, int x, int y, int w, int h, int dx, int s); //creates a moving platform depending on perameters |
adambakerwa | 50:9fc8edf722a8 | 87 | Pos moving_platform_ver(N5110 &lcd, Pos pos, int x, int y, int h, int w, int dx, int s); //creates a moving platform depending on perameters |
adambakerwa | 50:9fc8edf722a8 | 88 | void spike_up(N5110 &lcd, int x, int y); //creates a singular spike |
adambakerwa | 50:9fc8edf722a8 | 89 | Pos spike_row_up(N5110 &lcd, Pos pos, int x, int y, int n); //creates a row of spikes of n length |
adambakerwa | 50:9fc8edf722a8 | 90 | |
adambakerwa | 50:9fc8edf722a8 | 91 | void speech_counter1(); //increment counter1 |
adambakerwa | 50:9fc8edf722a8 | 92 | void speech_counter2(); //inrement counter2 |
adambakerwa | 50:9fc8edf722a8 | 93 | void speech_one(N5110 &lcd); //print string 'why hello there' word by word |
adambakerwa | 50:9fc8edf722a8 | 94 | void speech_two(N5110 &lcd); //print string 'you must be ' word by word |
adambakerwa | 50:9fc8edf722a8 | 95 | void speech_three(N5110 &lcd); //print string 'the new guy' word by word |
adambakerwa | 50:9fc8edf722a8 | 96 | void speech_four(N5110 &lcd); //print string 'use joy stick to move-go right' word by word |
adambakerwa | 50:9fc8edf722a8 | 97 | void speech_five(N5110 &lcd); //print string 'shame what' word by word |
adambakerwa | 50:9fc8edf722a8 | 98 | void speech_six(N5110 &lcd); //print string 'happened to' word by word |
adambakerwa | 50:9fc8edf722a8 | 99 | void speech_seven(N5110 &lcd); //print string 'the last lad...' word by word |
adambakerwa | 50:9fc8edf722a8 | 100 | void speech_eight(N5110 &lcd); //print string 'press button a to jump' word by word |
adambakerwa | 50:9fc8edf722a8 | 101 | void speech_nine(N5110 &lcd); //print string 'I was just' word by word |
adambakerwa | 50:9fc8edf722a8 | 102 | void speech_ten(N5110 &lcd); //print string 'starting to' word by word |
adambakerwa | 50:9fc8edf722a8 | 103 | void speech_elleven(N5110 &lcd); //print string 'like him' word by word |
adambakerwa | 50:9fc8edf722a8 | 104 | void speech_twelve(N5110 &lcd); //print string 'as well!' word by word |
adambakerwa | 50:9fc8edf722a8 | 105 | void speech_thirteen(N5110 &lcd); //print string 'Here's an idea..' word by word |
adambakerwa | 50:9fc8edf722a8 | 106 | void speech_forteen(N5110 &lcd); //print string 'try a wall jump' word by word |
adambakerwa | 50:9fc8edf722a8 | 107 | |
adambakerwa | 50:9fc8edf722a8 | 108 | Pos level_one(N5110 &lcd); //prints level one |
adambakerwa | 50:9fc8edf722a8 | 109 | Pos init_level_one(Pos pos); |
adambakerwa | 50:9fc8edf722a8 | 110 | void speech_level_one(N5110 &lcd); |
adambakerwa | 50:9fc8edf722a8 | 111 | |
adambakerwa | 50:9fc8edf722a8 | 112 | Pos level_two(N5110 &lcd); //prints level two |
adambakerwa | 50:9fc8edf722a8 | 113 | void speech_level_two(N5110 &lcd); |
adambakerwa | 50:9fc8edf722a8 | 114 | Pos init_level_two(Pos pos); |
adambakerwa | 50:9fc8edf722a8 | 115 | |
adambakerwa | 50:9fc8edf722a8 | 116 | Pos level_three(N5110 &lcd); //prints level three |
adambakerwa | 50:9fc8edf722a8 | 117 | void speech_level_three(N5110 &lcd); |
adambakerwa | 50:9fc8edf722a8 | 118 | Pos init_level_three(Pos pos); |
adambakerwa | 50:9fc8edf722a8 | 119 | |
adambakerwa | 50:9fc8edf722a8 | 120 | Pos level_four(N5110 &lcd); //prints level four |
adambakerwa | 50:9fc8edf722a8 | 121 | Pos init_level_four(Pos pos); |
adambakerwa | 50:9fc8edf722a8 | 122 | |
adambakerwa | 50:9fc8edf722a8 | 123 | Pos level_five(N5110 &lcd); //prints level five |
adambakerwa | 50:9fc8edf722a8 | 124 | Pos init_level_five(Pos pos); |
adambakerwa | 50:9fc8edf722a8 | 125 | |
adambakerwa | 50:9fc8edf722a8 | 126 | Pos level_six(N5110 &lcd); //prints level six |
adambakerwa | 50:9fc8edf722a8 | 127 | Pos init_level_six(Pos pos); |
adambakerwa | 50:9fc8edf722a8 | 128 | |
adambakerwa | 50:9fc8edf722a8 | 129 | Pos level_seven(N5110 &lcd); //prints level seven |
adambakerwa | 50:9fc8edf722a8 | 130 | Pos init_level_seven(Pos pos); |
adambakerwa | 50:9fc8edf722a8 | 131 | |
adambakerwa | 50:9fc8edf722a8 | 132 | Pos level_eight(N5110 &lcd); //prints level eight |
adambakerwa | 50:9fc8edf722a8 | 133 | Pos init_level_eight(Pos pos); |
adambakerwa | 50:9fc8edf722a8 | 134 | |
adambakerwa | 50:9fc8edf722a8 | 135 | Pos level_nine(N5110 &lcd); //prints level nine |
adambakerwa | 50:9fc8edf722a8 | 136 | Pos init_level_nine(Pos pos); |
adambakerwa | 50:9fc8edf722a8 | 137 | |
adambakerwa | 50:9fc8edf722a8 | 138 | Pos level_ten(N5110 &lcd); //prints level ten |
adambakerwa | 50:9fc8edf722a8 | 139 | |
adambakerwa | 50:9fc8edf722a8 | 140 | Pos level_zero(N5110 &lcd); //prints level ten |
adambakerwa | 50:9fc8edf722a8 | 141 | |
adambakerwa | 50:9fc8edf722a8 | 142 | Pos _pos; //struct containing position and direction of moving platforms |
adambakerwa | 50:9fc8edf722a8 | 143 | Pos _hoz1; |
adambakerwa | 50:9fc8edf722a8 | 144 | Pos _hoz2; |
adambakerwa | 50:9fc8edf722a8 | 145 | Pos _ver1; |
adambakerwa | 50:9fc8edf722a8 | 146 | Pos _ver2; |
adambakerwa | 50:9fc8edf722a8 | 147 | |
adambakerwa | 50:9fc8edf722a8 | 148 | int _counter1; //counters for displaying speech |
adambakerwa | 50:9fc8edf722a8 | 149 | int _counter2; |
adambakerwa | 50:9fc8edf722a8 | 150 | }; |
adambakerwa | 50:9fc8edf722a8 | 151 | |
adambakerwa | 50:9fc8edf722a8 | 152 | #endif |