Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Gamepad N5110
Levels.h
00001 #ifndef LEVELS_H 00002 #define LEVELS_H 00003 00004 #include "mbed.h" 00005 #include "Gamepad.h" 00006 #include "N5110.h" 00007 /** Pos struct for position of moving platforms and spikes*/ 00008 struct Pos { 00009 //////////hoz1////////// 00010 int x; /**< x cord of hoz1 */ 00011 int y; /**< y cord of hoz1 */ 00012 int d; /**< direction of hoz1 (0 is right, 1 is left) */ 00013 int c; /**< counter for hoz1 */ 00014 int l; /**< length of hoz1 */ 00015 int h; /**< height of hoz1 */ 00016 //////////hoz2////////// 00017 int x2; /**< x cord of hoz2 */ 00018 int y2; /**< y cord of hoz2 */ 00019 int d2; /**< direction of hoz2 (0 is right, 1 is left) */ 00020 int c2; /**< counter for hoz2 */ 00021 int l2; /**< length of hoz2 */ 00022 int h2; /**< length of hoz2 */ 00023 //////////ver1////////// 00024 int vx; /**< x cord of ver1 */ 00025 int vy; /**< y cord of ver1 */ 00026 int vd; /**< direction of ver 1 (0 is down, 1 is up) */ 00027 int vc; /**< counter for ver1 */ 00028 int vl; /**< length of ver1 */ 00029 int vh; /**< height of ver1 */ 00030 //////////ver2////////// 00031 int vx2; /**< x cord of ver2 */ 00032 int vy2; /**< y cord of ver2 */ 00033 int vd2; /**< direction of ver2 (0 is down, 1 is up) */ 00034 int vc2; /**< counter for ver2 */ 00035 int vl2; /**< length of ver2 */ 00036 int vh2; /**< height of ver2 */ 00037 //////////spikes////////// 00038 int sx; /**< x cord of spikes */ 00039 int sy; /**< y cord of spikes */ 00040 int sl; /**< length of spikes */ 00041 00042 }; 00043 00044 00045 /** Levels Class 00046 * @brief Class for creating and printing levels 00047 * @author Adam P. Baker 00048 * @date 9 May 2019 00049 */ 00050 class Levels 00051 { 00052 public: 00053 /** Constructor */ 00054 Levels(); 00055 00056 /** Deconstructor */ 00057 ~Levels(); 00058 00059 /** Initialises all variables and pos struct. 00060 *@returns pos struct 00061 */ 00062 Pos init(Pos pos); 00063 00064 /** Displays the level Blockhead is on 00065 *@param N5110 class which controlls lcd screen 00066 *@param what level Blockhead is on (int) 00067 *@returns pos struct 00068 */ 00069 Pos what_level(N5110 &lcd, int level); 00070 00071 private: 00072 00073 Pos init_hoz1(Pos pos); //initializes data for horizontal moving platform 1 00074 Pos init_hoz2(Pos pos); //initializes data for horizontal moving platform 2 00075 Pos init_ver1(Pos pos); //initializes data for vertical moving platform 1 00076 Pos init_ver2(Pos pos); //initializes data for vertical moving platform 2 00077 Pos init_spike(Pos pos); //initializes data for spikes 00078 void init_counter1(); //initializes counter 1 00079 void init_counter2(); //initializes counter 2 00080 00081 Pos pass_data_hoz1(Pos pos, Pos hoz); //transfer hoz1 into spare variables of original pos struct. 00082 Pos pass_data_hoz2(Pos pos, Pos hoz2); //transfer hoz2 into spare variables of original pos struct. 00083 Pos pass_data_ver1(Pos pos, Pos ver); //transfer ver into spare variables of original pos struct. 00084 Pos pass_data_ver2(Pos pos, Pos ver2); //transfer ver2 into spare variables of original pos struct. 00085 00086 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 00087 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 00088 void spike_up(N5110 &lcd, int x, int y); //creates a singular spike 00089 Pos spike_row_up(N5110 &lcd, Pos pos, int x, int y, int n); //creates a row of spikes of n length 00090 00091 void speech_counter1(); //increment counter1 00092 void speech_counter2(); //inrement counter2 00093 void speech_one(N5110 &lcd); //print string 'why hello there' word by word 00094 void speech_two(N5110 &lcd); //print string 'you must be ' word by word 00095 void speech_three(N5110 &lcd); //print string 'the new guy' word by word 00096 void speech_four(N5110 &lcd); //print string 'use joy stick to move-go right' word by word 00097 void speech_five(N5110 &lcd); //print string 'shame what' word by word 00098 void speech_six(N5110 &lcd); //print string 'happened to' word by word 00099 void speech_seven(N5110 &lcd); //print string 'the last lad...' word by word 00100 void speech_eight(N5110 &lcd); //print string 'press button a to jump' word by word 00101 void speech_nine(N5110 &lcd); //print string 'I was just' word by word 00102 void speech_ten(N5110 &lcd); //print string 'starting to' word by word 00103 void speech_elleven(N5110 &lcd); //print string 'like him' word by word 00104 void speech_twelve(N5110 &lcd); //print string 'as well!' word by word 00105 void speech_thirteen(N5110 &lcd); //print string 'Here's an idea..' word by word 00106 void speech_forteen(N5110 &lcd); //print string 'try a wall jump' word by word 00107 00108 Pos level_one(N5110 &lcd); //prints level one 00109 Pos init_level_one(Pos pos); 00110 void speech_level_one(N5110 &lcd); 00111 00112 Pos level_two(N5110 &lcd); //prints level two 00113 void speech_level_two(N5110 &lcd); 00114 Pos init_level_two(Pos pos); 00115 00116 Pos level_three(N5110 &lcd); //prints level three 00117 void speech_level_three(N5110 &lcd); 00118 Pos init_level_three(Pos pos); 00119 00120 Pos level_four(N5110 &lcd); //prints level four 00121 Pos init_level_four(Pos pos); 00122 00123 Pos level_five(N5110 &lcd); //prints level five 00124 Pos init_level_five(Pos pos); 00125 00126 Pos level_six(N5110 &lcd); //prints level six 00127 Pos init_level_six(Pos pos); 00128 00129 Pos level_seven(N5110 &lcd); //prints level seven 00130 Pos init_level_seven(Pos pos); 00131 00132 Pos level_eight(N5110 &lcd); //prints level eight 00133 Pos init_level_eight(Pos pos); 00134 00135 Pos level_nine(N5110 &lcd); //prints level nine 00136 Pos init_level_nine(Pos pos); 00137 00138 Pos level_ten(N5110 &lcd); //prints level ten 00139 00140 Pos level_zero(N5110 &lcd); //prints level ten 00141 00142 Pos _pos; //struct containing position and direction of moving platforms 00143 Pos _hoz1; 00144 Pos _hoz2; 00145 Pos _ver1; 00146 Pos _ver2; 00147 00148 int _counter1; //counters for displaying speech 00149 int _counter2; 00150 }; 00151 00152 #endif
Generated on Fri Jul 15 2022 00:42:15 by
