Mochu Yao explorer game
Dependencies: mbed
Revision 39:0debc17bad29, committed 2020-05-15
- Comitter:
- el17my
- Date:
- Fri May 15 09:03:36 2020 +0000
- Parent:
- 38:42ff379fa48c
- Commit message:
- the final version
Changed in this revision
--- a/main.cpp Fri May 15 02:47:10 2020 +0000 +++ b/main.cpp Fri May 15 09:03:36 2020 +0000 @@ -15,12 +15,14 @@ #include "Gamepad.h" #include "N5110.h" #include "Menu.h" +#include "test.h" // objects Gamepad gamepad; N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); Menu _menu; +test _test; int main() { gamepad.init(); @@ -30,6 +32,8 @@ lcd.setBrightness(0.5); while(1) { lcd.clear(); + _test.test_item(30,30,lcd); + _test.test_surface(lcd); _menu.run_engine(lcd, gamepad); lcd.refresh(); wait(0.01); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/test.cpp Fri May 15 09:03:36 2020 +0000 @@ -0,0 +1,49 @@ +#include "test.h" + +test::test() {} + +test::~test() {} + +void test::init(int _y1,int _y2) { + _surface.init(20,40); + _item.init(); + _speed = 0; + _jump_height = 20;} + +void test::test_explorer(float joy_x, int speed, Explorer_sprite sprite, N5110 &lcd,int jump_height) { + lcd.clear(); + _player.set_x_coordinate(joy_x, _speed, right); + _player.set_y_coordinate(true, _jump_height, 0); + lcd.drawSprite(_player.get_x(),_player.get_y(),10,10, + (int *)_player.get_form(sprite)); // Prints object. + lcd.refresh(); + wait(1); } + +void test::test_item(int item_x, int item_y, N5110 &lcd) { + lcd.clear(); + _item.set_item(item_x, item_y); // Sets object with input stimulus. + lcd.drawSprite(_item.get_item_x(),_item.get_item_y(),5,6,(int*)_item.get_item_form()); + lcd.refresh(); + wait(0.5); } + +void test::test_surface(N5110 &lcd) { + _surface.line_1(); + line_1_value = _surface.getline_1(); + _surface.line_2(); + line_2_value = _surface.getline_2(); + _surface.line_3(); + line_3_value = _surface.getline_3(); + _surface.line_4(); + line_4_value = _surface.getline_4(); + _surface.line_5(); + line_5_value = _surface.getline_5(); + _surface.line_6(); + line_6_value = _surface.getline_6(); + lcd.drawLine(line_1_value.left,line_1_value.y,line_1_value.right,line_1_value.y,FILL_BLACK); + lcd.drawLine(line_2_value.left,line_2_value.y,line_2_value.right,line_2_value.y,FILL_BLACK); + lcd.drawLine(line_3_value.left,line_3_value.y,line_3_value.right,line_3_value.y,FILL_BLACK); + lcd.drawLine(line_4_value.left,line_4_value.y,line_4_value.right,line_4_value.y,FILL_BLACK); + lcd.drawLine(line_5_value.left,line_5_value.y,line_5_value.right,line_5_value.y,FILL_BLACK); + lcd.drawLine(line_6_value.left,line_6_value.y,line_6_value.right,line_6_value.y,FILL_BLACK); + lcd.refresh(); + wait(1); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/test.h Fri May 15 09:03:36 2020 +0000 @@ -0,0 +1,78 @@ +#ifndef TESTS_H +#define TESTS_H + +#include "N5110.h" +#include "Gamepad.h" +#include "mbed.h" +#include "explorer.h" +#include "item.h" +#include "surface.h" + +/** Test Class +* @brief run the code to do the debug process +* @author Yao mochu +* @date May 2020 +*/ + + + +class test { + public: + // Constructor and destructor. + /** + * @brief Constructor + * @details Non user specified. + */ + test(); + /** + * @brief Destructor + * @details Non user specified. + */ + ~test(); + + // Member methods. + /** + * @brief Initalises the Tests. + * @param _y1 @details the height of lower level + * @param _y2 @details the height of upper level + */ + void init(int _y1,int _y2); + // Member methods. + /** + * @brief test the explorer. + * @param joy_x @details the control of x coordinate + * @param sprite @details the form of the explorer + * @param lcd @details the lcd class + * @param ifjump @details testing the explorer is jumping or not + * @param jump_height @details the upper height + * @param y_flag @details the platform to stay + */ + void test_explorer(float joy_x, int speed, Explorer_sprite sprite, N5110 &lcd, int jump_height); + // Member methods. + /** + * @brief test the item. + * @param random_x @details the control of x coordinate + * @param random_y @details the form of the explorer + * @param lcd @details the lcd class + */ + void test_item(int random_x, int random_y, N5110 &lcd); + /** + * @brief test the item + * @param lcd @details the lcd class + */ + void test_surface(N5110 &lcd); + private: + item _item; + Explorer _player; + Surface _surface; + int _speed; + int _jump_height; + Line line_1_value; + Line line_2_value; + Line line_3_value; + Line line_4_value; + Line line_5_value; + Line line_6_value; + }; +#endif + \ No newline at end of file