Mbed project for a FRDM-K64F microcontroller. Game made out of five sub-games including flappy birds, snake, stack, trivia and space invaders.
Fork of The_Children_of_Cronos_el15mggr by
aurigaslib.h
00001 #ifndef AURIGASLIB_H 00002 #define AURIGASLIB_H 00003 00004 #include "mbed.h" 00005 #include "N5110.h" 00006 #include "Gamepad.h" 00007 00008 #define widthC 82 00009 #define heightC 48 00010 #define sizeC 4 00011 #define NOTE_DS5 622 00012 00013 //////////////////////////////////STRUCTURES/////////////////////////////////// 00014 00015 /** structure for pipes height */ 00016 struct pipes { 00017 int top;/**< top rectangle position */ 00018 int bottom;/**< bottom rectangle position */ 00019 }; 00020 00021 /** structure for bird position */ 00022 struct bird { 00023 int x;/**< x position */ 00024 int y;/**< y position */ 00025 }; 00026 00027 //////////////////////////////////METHODS AND VARIABLES///////////////////////// 00028 00029 /** aurigaslib Class 00030 * @brief Library for the third game, Aurigas 00031 * @brief Revision 1.3 00032 * @author Mateo Randulfe 00033 * @date May 2017 00034 */ 00035 class aurigaslib 00036 { 00037 public: 00038 /** Constructor */ 00039 aurigaslib(); 00040 /** 00041 *sets positions and values to initial ones and generates new pipe random heights 00042 */ 00043 void init(); 00044 /* 00045 * if the game starts(start pressed), set pipes velocity (k=1) and gravity to their proper values 00046 * generates random pipes heights if they get out of the screen (smaller their x pos than 0) 00047 * @param pad set leds() function 00048 * @param start for starting moving all the game 00049 */ 00050 void pipegenerator(Gamepad &pad,DigitalOut &start); 00051 /** 00052 * function that allows user to jump whithin the screen 00053 * moves the pipes 00054 * when the pipes get out of the screen in the left they restart in the right 00055 * @param a/b/x/y jump 00056 */ 00057 void updatescr(DigitalOut &a,DigitalOut &b,DigitalOut &x,DigitalOut &y,Gamepad &pad); 00058 /** 00059 * draws all the components and clears some pixels of the bird for improving its looking 00060 * @param lcd for printing in the screen 00061 */ 00062 void draw(N5110 &lcd); 00063 /** 00064 * check if any bird pixel hitted any pipe 00065 * @returns true if the player hits the pipes 00066 * @returns false if he doesnt 00067 */ 00068 bool touch(); 00069 /** 00070 * function that displays the game over screen and allows player to restart game 00071 * once restarted,all values set to original ones 00072 * @param lcd for drawing into the screen 00073 * @param l/r for restarting the game 00074 * @param pad for putting leds off 00075 */ 00076 void gameover(N5110 &lcd,Gamepad &pad,DigitalOut &l,DigitalOut &r); 00077 /** 00078 * function that switches only the same number of leds on as the same number of lifes 00079 * the player still have left 00080 * @param pad controls leds 00081 */ 00082 00083 void leds(Gamepad &pad); 00084 /** 00085 * @returns score 00086 */ 00087 00088 int score (); 00089 //for printing the score 00090 char _buffer[20]; 00091 00092 00093 int _force; 00094 //physics variables 00095 float _vel , _gravity, _velpipe; 00096 int _score,_lifes; 00097 //x pipes position 00098 int _pospipe0,_pospipe1; 00099 int _pospipe2,_pospipe3; 00100 //checks if game start was pressed and game didnt started yet 00101 int _k; 00102 bool _check; 00103 pipes _pipe0,_pipe1,_pipe2,_pipe3; 00104 bird _posbird; 00105 00106 }; 00107 #endif
Generated on Wed Jul 13 2022 07:38:17 by
1.7.2
