Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Frogger/Frogger.h
- Committer:
- el19tb
- Date:
- 2020-05-26
- Revision:
- 57:a6eb3a0e92bc
- Parent:
- 56:2797166656e0
- Child:
- 58:35560ce5eca3
File content as of revision 57:a6eb3a0e92bc:
#ifndef FROGGER_H #define FROGGER_H #include "mbed.h" #include "N5110.h" #include "Gamepad.h" #include "Frog.h" #include "GraphicEngine.h" #include "WaterSprites.h" #include "Vehicle.h" #include "Background.h" #include "IntroScreen.h" #include <vector> #include <stdio.h> #include <cstddef> #include <vector> /** Frogger Class * * @brief Frogger class that runs the entire game, in charge of lcd calls * @brief moving objects, checking for collision etc. * @author Tarek Bessalah * @date May, 2020 */ class Frogger { public: /** @param frog object that frogger class keeps track of */ Frog *frog; // one frog object /** Constructor */ Frogger(); /** Constructor * @brief This constructor is the main engine of the frogger class * @param frog - actual frog object that user controls * @param w - the size of the lcd width * @param h - the size of the lcd height */ Frogger(Frog *frog, int grid, int w, int h); // constructor public: /** @param current level of the game (starts from 1) */ int current_level; /** @param current state of the frog, used to draw the animation of the frog */ int state_frog; /** @param if the frog is in the water level, it can die now if it is * not on the log */ bool frogDie; /** @param store the x position of the goal post */ int goal_post_xpos; /** @param user is playing the game right now */ bool play_game; /** @param user is currently in the main menu */ bool introScreen; /** @param user is currently reading the tutorial manual */ bool tutorial; /** @param user is currently reading the settings */ bool settings; /** @param if this on, then there exists an end post */ bool end_post; /** @param frog is successful in current level */ bool nextLevel; /** @param informs if the frog reached end post */ bool next_goal; /** @param this means that bonus round is screen is on */ bool bonus_round; /** @param y coord (in rows) value of the water level */ float water_level; /** @param if the frog collides with log object and is above second * safety lane, it is attached to the object (going same speed) */ bool frogOnLog; /** @param current state of the turtles, this is used to draw the animation * of the turtle in level 2 */ int turtle_state; public: /** @param local hardware object, used for sounds, LED, and button controls etc. */ Gamepad gamepad; /** @param class object that keeps track of the current pointer position, current page */ IntroScreen intro; /** @param size of the game grid */ int grid; // size of one game unit int row_number; int grid_width; // screen width in grid units int lcd_w; int lcd_h; public: // Level One Car objects Object car_row_one_one[3]; Object car_row_two_one[2]; Object car_row_three_one[3]; Object car_row_four_one[4]; // Level One Log objects Object row_one_log[3]; // large sized Object row_two_log[2]; // medium sized Object row_three_log[3]; // large sized // Level two Car Objects Object car_row_one_two[4]; Object car_row_two_two[3]; Object car_row_three_two[4]; Object car_row_four_two[3]; // level two log objects Object level_row_one[2]; Object level_row_two[2]; Object level_row_three[3]; //BONUS ROUND Object bonus_row_one[4]; Object bonus_row_two[3]; Object bonus_row_three[4]; Object bonus_row_four[3]; Object bonus_row_six[2]; Object bonus_row_seven[2]; Object bonus_row_eight[3]; public: void run(); void run_bonus(); void actOnFrogBonus(); void checkBonusProgress(); void updateTurtleState(); void actOnFrogPos(); void home(); void determineSelection(); void gotoPage(); void selectOption(); void checkLevelProgression(); int randEndPost(); void checkFrogOnWater(); void drownedFrog(); void checkFrogAction(Object log); void setupLevelTwoRows(); void runBonusRound(); void setupBonusRows(); void setupBonusXpos(); void setupBonusTwoDir(); void setupBonusSprites(); void moveBonusObjects(); void moveFrogWithLog(Object log); void checkTurtleDrown(); void drawBackGround(); void generateLevelOneGoalPost(); void setUpGoalPost(); void levelOneCollision(); void levelTwoCollision(); void checkCollison(Object object); void setupRowDistance(Object *objects, int dis, int array_size); void setDistance(Object *object, int dis); void setRowObjects(Object *objecs, int row, int array_size); void createRow(Object *object, int row); void setSpriteObjects(Object *objects, char c, int array_size); void setSprite(Object *object, char c); void setDirObjects(Object *objecs, int dir, int array_size); void setDir(Object *objecs, int dir); //void moveLogLevelTwo(); void moveLogsLevelOne(); void checkFrogReachedRiver(); void gotoNextTutorialSlide(); void displayTutorial(); void goalReached(); void checkProgression(); void moveLogsLevelTwo(); void drawFrogStates(); void speedSlow(); void speedMedium(); void speedFast(); // BONUS ROUND void setupBonusRound(); // LEVEL ONE FUNCTIONS void setupLevelOne(); // set up vehicles void setupLevelOneRow(); void setupLevelOneXPos(); void setupLevelOneSprites(); void setupLevelOneDir(); // set up logs void setupLogsLevelOne(); void setLogLevelOneXPos(); void setLogLevelOneRow(); void setLogLevelOneDir(); void setLogLevelOneSprites(); // LEVEL TWO FUNCTIONS void setupLevelTwo(); int randCars(); // setup vehicles void setupLevelTwoXPos(); void setupLevelTwoSprites(); void setupLevelTwoDir(); //log objects void setupLogLevelTwo(); void setLogLevelTwoXPos(); void setLogLevelTwoRow(); void setLogLevelTwoSprite(); void setLogLevelTwoDir(); void initializeLevelTwo(); void displayObject(Object &temp_object); public: void start(); void input(); void process_input(); void clear(); void runLevelOne(); void runLevelTwo(); void moveVehiclesLevelOne(); void moveVehiclesLevelTwo(); void moveVehicle(Object *row, char c, int array_size); void moveIndividualObject(Object *vehicle, char c); void checkOutOfBounds(Object *vehicle); void displayLevelIntro(); void runCurrentLevel(); void initializeParams(int w, int h, int grid); void initializeEmbeddedSystem(); void checkCurrentLevelCollision(); void checkIfFrogIsInWater(); void moveFrog(int xWay, int yWay); void game(); void refresh(); void createWaterLane(); void createMultipleLanesWater(); void drawRoadObjects(); void createRoadLane(); void createMultipleRoadLane(); void drawSafety(); void createSafetyObject(); void createMultipleSafetyLane(); void drawEndPost(); void drawWater(); void loopWater(); void moveWater(); void checkFrogInDeathZone(); void move(); void checkFrogOutOfBounds(); void displayIntro(); void setup(); void createGoalPost(); }; #endif