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.
Alien/Alien.h
- Committer:
- evanso
- Date:
- 2020-05-13
- Revision:
- 27:8bb2bd97c319
- Parent:
- 25:70b55f5bfc87
- Child:
- 28:a5958497d5ce
File content as of revision 27:8bb2bd97c319:
#ifndef ALIEN_H
#define ALIEN_H
// Included libraries ----------------------------------------------------------
#include "mbed.h"
#include "N5110.h"
#include "Gamepad.h"
#include "Weapons.h"
#include "Position.h"
/** Alien class
* @brief Draws and moves aliens
* @author Benjamin Evans, University of Leeds
* @date May 2020
*/
class Alien: private Position {
public:
/** Constructor */
Alien();
/** Destructor */
~Alien();
/** Initalises Alien */
void init(Gamepad &pad);
/** Draws the alien
* @param lcd @details N5110 object
* @param spaceship_pos @details xy spaceship position
* @param d_ @details Direction of joystick
* @param map_length_ @details length of map
* @param position_x_map_ @details x position of map
*/
void draw_alien(N5110 &lcd, Vector2D spaceship_pos, Direction d_,
int map_length_, int position_x_map_);
/** Checks if bullet collides with a alien
* @param bullet @details Weapons object
*/
bool check_collision(Weapons bullet);
// Accessors and mutators --------------------------------------------------
/** Gets the xy position of the alien
* @return position_x_alien_
* @return position_x_alien_
*/
Vector2D get_pos();
private:
// Function prototypes -----------------------------------------------------
/** Moves the alien towards the spaceship and around the map
* @param spaceship_pos @details : Position of the spaceship
*/
void move_hunt_mode(Vector2D spaceship_pos);
/** Calulates the aliens movement depeding on spaceship positions and
* joystick input
* @param d_ @details : Direction object of joystick
* @retrun integer @details move alien value for alien draw function
*/
int calc_alien_movement(Direction d_);
/** Generates the random move dirction and length for the alien*/
void set_random_move();
/** Gets the movement direction of the alien */
void move_direction();
/** Changes the x and y positions of the alien depeding on the movement
* direction
* @param x_change @details number to change alien x position by
* @param y_change @detials number to change alien y position by
*/
void set_alien_direction(int x_change,int y_change);
/** Stops the alien from moving off the edge of the map and moves alien
* if the map loops
* @param map_length_@details : length of the map
* @param position_x_map_ @detials : the drawing start posisiton of the
* map
*/
void off_screen_x_y_checker(int map_length_, int position_x_map_);
// Variables ---------------------------------------------------------------
/** Alien movement counter */
int alien_move_counter;
/** Alien randome move counter */
int random_move_counter_;
/** Random direction variable */
int random_direction_;
};
#endif