Mochu Yao explorer game
Dependencies: mbed
Surface/surface.h
- Committer:
- el17my
- Date:
- 2020-05-15
- Revision:
- 38:42ff379fa48c
- Parent:
- 29:2d592452e3fb
File content as of revision 38:42ff379fa48c:
#ifndef LINE_H #define LINE_H #include "mbed.h" /** Line struct */ struct Line { int length;/**< the length of the line. */ int left;/**< the leftside of the line. */ int right;/**< the rightside of the line. */ int y;/**< the height of the line. */ }; //the line structer will have four main elements /** surface Class * @1 the leftside of the line move toward right then the rightside should also move to the right to keep the length * @2 the line will be random length but must be suitable * @3 makesure there are two surface for player to stay * @date April 22th 2020 * @author Yaomochu @code #include "mbed.h" #include "N5110.h" #include "Gamepad.h" #include "surface.h" #include <cstdlib> #include <ctime> N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); Gamepad gamepad; Surface _surface; Line line_1_value; Line line_2_value; Line line_3_value; Line line_4_value; Line line_5_value; Line line_6_value; int main() { _surface.init(20,40); while(1) { //draw line 1 _surface.line_1(); line_1_value = _surface.getline_1(); lcd.drawLine(line_1_value.left,line_1_value.y,line_1_value.right,line_1_value.y,FILL_BLACK); //draw line 2 _surface.line_2(); line_2_value = _surface.getline_2(); lcd.drawLine(line_2_value.left,line_2_value.y,line_2_value.right,line_2_value.y,FILL_BLACK); //draw line 3 _surface.line_3(); line_3_value = _surface.getline_3(); lcd.drawLine(line_3_value.left,line_3_value.y,line_3_value.right,line_3_value.y,FILL_BLACK); //draw line 4 _surface.line_4(); line_4_value = _surface.getline_4(); lcd.drawLine(line_4_value.left,line_4_value.y,line_4_value.right,line_4_value.y,FILL_BLACK); //draw line 5 _surface.line_5(); line_3_value = _surface.getline_5(); lcd.drawLine(line_5_value.left,line_5_value.y,line_5_value.right,line_5_value.y,FILL_BLACK); //draw line 6 _surface.line_6(); line_6_value = _surface.getline_6(); lcd.drawLine(line_6_value.left,line_6_value.y,line_6_value.right,line_6_value.y,FILL_BLACK); } } @endcode */ class Surface { public: // Constructor and Destructor. /** * @brief Constructor @details Non user specified. */ Surface(); /** * @brief Destructor @details Non user specified. */ ~Surface(); /** * @brief init the line at first to set the initial position. * @param y1 @details the lower line height. * @param y2 @details the upper line height. */ void init(int y1, int y2); /** * @brief set line1 movement. */ void line_1(); /** * @brief set line2 movement. */ void line_2(); /** * @brief set line3 movement. */ void line_3(); /** * @brief set line4 movement. */ void line_4(); /** * @brief set line5 movement. */ void line_5(); /** * @brief set line6 movement. */ void line_6(); // Accessors. /** * @brief Gets line 1. * @returns Line 1 (type: struct, Line) */ Line getline_1(); /** * @brief Gets line 2. * @returns Line 2 (type: struct, Line) */ Line getline_2(); /** * @brief Gets line 3. * @returns Line 3 (type: struct, Line) */ Line getline_3(); /** * @brief Gets line 4. * @returns Line 4 (type: struct, Line) */ Line getline_4(); /** * @brief Gets line 5. * @returns Line 5 (type: struct, Line) */ Line getline_5(); /** * @brief Gets line 6. * @returns Line 6 (type: struct, Line) */ Line getline_6(); private: Line _line_1; Line _line_2; Line _line_3; Line _line_4; Line _line_5; Line _line_6; }; #endif