ELEC2645 (2018/19) / Mbed 2 deprecated el17lw

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Tests.h Source File

Tests.h

00001 #ifndef TESTS_H
00002 #define TESTS_H
00003 
00004 #include "N5110.h"
00005 #include "Gamepad.h"
00006 #include "mbed.h"
00007 #include "Skateboarder.h"
00008 #include "Coin.h"
00009 #include "Fire.h"
00010 #include "Platforms.h"
00011 
00012 /** Tests Class
00013 * @brief Allows the user to input a set stimulus to test sprites by printing to LCD and terminal. 
00014 * @author Lewis Wooltorton
00015 * @date May 2019
00016 
00017 @code
00018 
00019 #include "N5110.h"
00020 #include "Gamepad.h"
00021 #include "mbed.h"
00022 #include "Tests.h"
00023 
00024 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
00025 Gamepad gamepad;
00026 Tests test;  // Create a test object if tests are to be done.
00027 
00028 void init_game();
00029 
00030 int main() {
00031   init_game();
00032   while(1) {
00033     lcd.setContrast(gamepad.read_pot());  // Contrast is controlled by pot.
00034     lcd.clear();  
00035     // Blelow line is an example of testing sprites. See documentation for 
00036     // parameters and details.
00037     test.run_tests(1,1,Left,Skate_right,20,20,20,10,30,50,5,lcd);     
00038     lcd.refresh();
00039     wait(0.01);  
00040   }     
00041 }  
00042  
00043 void init_game() {
00044   test.init(20);  // Argument is the vertical position of test platforms.
00045   gamepad.init();
00046   lcd.init(); 
00047   lcd.normalMode();      
00048   lcd.setBrightness(0.5); 
00049 }
00050 @endcode
00051 
00052 */
00053 
00054 class Tests {
00055  public:
00056   // Constructor and destructor.
00057   /**
00058   * @brief Constructor 
00059   * @details Non user specified.
00060   */
00061   Tests();
00062   /**
00063   * @brief Destructor 
00064   * @details Non user specified.
00065   */
00066   ~Tests();
00067   
00068   // Member methods.
00069   /**
00070   * @brief Initalises the Tests.
00071   * @param platforms_y @details The vertical position of the platforms
00072   */ 
00073   void init(int platforms_y); 
00074   /**
00075   * @brief Runs all the Tests with input stimulus.
00076   * @param joy_x @details The x coordinate of the joystick
00077   * @param joy_y @details The y coordinate of the joystick
00078   * @param sprite @details the skateboarder sprite to be printed (from the enum class Sprite_value)
00079   * @param coin_x @details The x coordinate of the coin
00080   * @param coin_y @details The y coordinate of the coin
00081   * @param fire_y @details The y coordinate of the fire
00082   * @param line_1_start @details The starting x coordinate of line 1
00083   * @param line_2_start @details The starting x coordinate of line 2
00084   * @param line_3_start @details The starting x coordinate of line 3
00085   * @param line_length @details The length of each line in the platform object
00086   * @param &lcd @details The lcd object from the N5110 class
00087   */
00088   void run_tests(float joy_x, float joy_y, Sprite_value sprite, int coin_x, int coin_y, int fire_y, int line_1_start, int line_2_start, int line_3_start, int line_length, N5110 &lcd);
00089   
00090  private:
00091   void test_skater(float joy_x, float joy_y, Sprite_value sprite, N5110 &lcd);
00092   void test_coin(int coin_x, int coin_y, N5110 &lcd);
00093   void test_fire(int fire_y, N5110 &lcd);
00094   void test_platforms(int line_1_start, int line_2_start, int line_3_start, int line_length, N5110 &lcd);
00095   
00096   Skateboarder _skater;
00097   Coin _coin;
00098   Fire _fire;
00099   Platforms _platforms;
00100   int _moving_counter;
00101   Line _line_1;
00102   Line _line_2;
00103   Line _line_3;
00104 };
00105 #endif
00106