Mateo Gomez-Randulfe / Mbed 2 deprecated The_Children_of_Cronos

Dependencies:   mbed

Fork of The_Children_of_Cronos_el15mggr by ELEC2645 (2016/17)

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers cerinealib.h Source File

cerinealib.h

00001 #ifndef CERINEALIB_H
00002 #define CERINEALIB_H
00003 
00004 #include "mbed.h"
00005 #include "N5110.h"
00006 #include "Gamepad.h"
00007 
00008 #define width 82
00009 #define height 48
00010 #define size 5
00011 
00012 
00013 
00014 ///////////////////////////////////////////////////////////////////////////////
00015 /* This library if for he stack game.It is the only game that has some bugs 
00016 when playing to it.There is a bouncing problem with the buttons that dont work
00017 well as well as som problems with the logic from the 6th block dropped.
00018 
00019 However,the user can still play this game but no as the original one.I wasnt 
00020 going to put this game into my project because of this minor bugs but, as I
00021 already created the story of the game around the number 5 and as I thought I
00022 would have enough time to solve this issues I put it with the rest.
00023 
00024 Due to unpredicted problems before the deadline I didnt have enough time for
00025 solving the problems. I apologise for this game's bugs. */
00026 
00027 ///////////////////////////////////STRUCTURES///////////////////////////////////
00028 
00029     /** Blocks position */
00030     struct pos {
00031         int x;/**< x pos */
00032         int y;/**< y pos */
00033     } ;
00034     
00035     
00036     
00037 
00038 ////////////////////////////METHODS AND VARIABLES///////////////////////////////
00039 /** cerinealib Class
00040  * @brief Library for the fourth game, Cerinea
00041 * @brief Revision 1.3
00042 * @author Mateo Randulfe
00043 * @date May 2017
00044  */
00045 
00046 class cerinealib
00047 {
00048 public:
00049     /** Constructor */
00050     cerinealib();
00051     /**
00052     * function that switches only the same number of leds on as the same number of lifes
00053     * the player still have left
00054     * @param pad controls leds
00055     */
00056     void leds();
00057     /**
00058     * function that initialises the values for the main positions as well as the borders to 0(this will be
00059     * added later when the block are dropped), the sizes to 0(appart from the main first block) because
00060     * they will be then set in the game,and the x and y position where the blocks to be added will start
00061     *moving
00062     */
00063     void init();
00064     /**
00065     * this function performs two main actuations
00066     * first, it draws the blocks in movent if their bool variable is true(which means that they
00067     * were not dropped yet).
00068     * second, if they are dropped(bool variables with the names or ordinals like first second etc set to false)
00069     * the function will leave only the part over the other block and the rest(the part out of the range)
00070     * will be eliminated.It also sets the size of the next block depending on the size of the block dropped
00071     * it will set also the left block extreme margin as border to have a reference
00072     * @param lcd for printing into the screen
00073     */
00074     void draw(N5110 &lcd);
00075     /**
00076     * depending on if the block is moving (ordinal variables to true) or dropped(ordinal variables to false)
00077     * it will update the movement from one side of the screen to the next one
00078     * or it will set the block to the dropped stayed position and when it reaches to five the block count
00079     * it will start a loop of switching the block x positions to their previous one,letting the game to keep going forever
00080     */
00081     void updatescr();
00082     /**
00083     * if buttons pressed the block will be dropped
00084     * if dropped it will increse the score and let the next block moving variable to true (ordinal variable) as well as setting its to false
00085     * @param b/a/x/y drop block
00086     * @param pad
00087     */
00088     void commands(DigitalOut &b,DigitalOut &a,DigitalOut &x,DigitalOut &y,Gamepad &pad);
00089     /**
00090     * function that displays the game over screen and allows player to restart game
00091     *once restarted,all values set to original ones
00092     * @param lcd for drawing into the screen
00093     * @param start for restarting the game
00094     * @param pad for putting leds off
00095     */
00096     void gameover(N5110 &lcd,DigitalOut &start);
00097     /**
00098     * @returns true if dead
00099     */
00100     bool die ();
00101     /**
00102     * function that sets the velocity of the game and the difficulty level
00103     * the highest the score the faster the game will go and the more difficult
00104     */
00105     void velocities();
00106     /**
00107     * @returns score
00108     */
00109     int score ();
00110     
00111 //for displaying score
00112     char _buffer[20];
00113 
00114 
00115 //sizes of the blocks depending on what is the previous block left
00116     int _size0,_size1,_size2,_size3,_size4,_size5;
00117 //first block positions
00118     int _pos0lft,_pos0rgt,_posy0;
00119     int _k,_count,_score,_lifes;
00120 //left extreme of the blocks as spacial refrerence
00121     int _border1,_border2,_border3,_border4,_border5;
00122 //ordinal variables for knowing if the block was dropped
00123     bool _first,_second,_third,_fourth,_fith;
00124     pos _pos1,_pos2,_pos3,_pos4,_pos5;
00125     bool _dead;
00126 #define NOTE_C6  1047
00127 };
00128 #endif