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.
Map/Map.h
- Committer:
- evanso
- Date:
- 2020-04-23
- Revision:
- 11:ab578a151f67
- Parent:
- 9:1ddb8dc93e48
- Child:
- 12:1c0b6796aaca
File content as of revision 11:ab578a151f67:
#ifndef MAP_H
#define MAP_H
/////////////// Include libraries ///////////////
#include "mbed.h"
#include "N5110.h"
#include "Gamepad.h"
/** Map class
@brief Draws
@author Benjamin Evans, University of Leeds
@date April 2020
*/
class Map {
public:
/** Constructor */
Map();
/** Destructor */
~Map();
/** Initalises Spaceship */
void init(AnalogIn &adc);
/** Draws map out of combination of random hight traingle and random length lines so map is differnt each new game and loops roudn at ends
* @param LCD object, move_map variable
*/
void draw_map(N5110 &lcd, int move_map);
/////////////// accessors and mutators ///////////////
/** Gets x postion of the map
* @return maps x postion
*/
int get_position_x_map();
private:
/////////////// Functions ///////////////
/** Gets 11 random integers for random lengths and hights arrays
* and stores in array so same random ma is drawn each frame
* @param RandGen object
*/
void get_random_arrays(AnalogIn &adc);
/** Draws a triangle from position with specified hight wich represents a mountain of the map
* @param LCD object, Hight of trangle
*/
void draw_triangle(N5110 &lcd, int triangle_hight);
/** Draws a horizontal line with specified length to represent flat land on map
* @param LCD object, Length of line
*/
void draw_line(N5110 &lcd, int line_length);
/** Duplicates the first part of the map to fill the gap when the map loops round
* @ param LCD object
*/
void check_duplicates_map_forward(N5110 &lcd);
/** Duplicates the last part of the map to fill the gap when the map loops round
* @ param LCD object
*/
void check_duplicates_map_backwards(N5110 &lcd);
/////////////// Variables ///////////////
int position_x_map_;
int position_y_map_;
float rand_seed_;
int map_length_;
// Arrays to hold random heights of triangles and lengths of lines
int rand_heights_[12];
int rand_lengths_[12];
// To store the final element used in the random array befor the break in draw map
int final_random_element_used_;
//Required to reset the map to it's origonal postion at end of each frame, as draw line and triangle functions change position_x_map_
int reset_position_x_map_to_origonal_;
};
#endif