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 MotionSensor
Entity/Mobs/Headless/Headless.h
- Committer:
- el17sm
- Date:
- 2019-05-09
- Revision:
- 59:fd4669864b67
- Parent:
- 58:c8d90bb7404a
File content as of revision 59:fd4669864b67:
#ifndef HEADLESS_H
#define HEADLESS_H
#include "Entity.h"
/**Headless Class
*@author Steven Mahasin
*@brief Creates a Headless which inherits the Entity class, this is one of the mobs that spawns in the normal rooms.
*@date May 2019
*/
class Headless : public Entity
{
public:
/** Constructor
* @brief creates a headless at positions pos_x and pos_y
* @param pos_x @details initialise _position.x
* @param pos_y @details initialise _position.y
*/
Headless(float pos_x, float pos_y);
// Functions
/**
* @brief function moves the headless towards the player
* @param x_value - player x-position
* @param y_value - player y-position
* @param map - the 2d map array that dictates where there are walls or empty space
* @param doorways - an array that dictates which side of the wall has a doorway
*/
virtual void move(float player_x, float player_y, char * map, bool * doorways);
/**
* @brief reduce _hp by damage
* @param damage @details the amount of damage to be taken
*/
virtual void take_damage(int damage);
/**
* @brief a virtual function of drawing the headless onto the screen
* @param lcd @details the screen where the headless is drawn on
*/
virtual void draw(N5110 &lcd);
private:
// Methods
/**
* @brief gets the sprite array
* @return char pointer array of the corresponding snake sprite frame
*/
char * get_frame();
/**
* @brief increase _frame.count which increases _frame.number to animate snake
*/
void increment_frame();
};
const char sprite_headless[4][4][9][6] = { // Player [Face][SpriteAnimationFrame][Size_Y][Size_X]
{
// Up
{
{0,0,0,0,0,0,},
{1,0,0,0,0,0,},
{0,1,1,1,1,0,},
{1,0,1,1,0,1,},
{0,0,1,1,0,0,},
{0,0,1,1,0,0,},
{0,1,0,0,1,0,},
{0,1,0,0,1,0,},
{0,1,0,0,1,0,}
},
{
{0,0,0,0,0,0,},
{0,0,0,1,0,0,},
{0,1,1,1,1,0,},
{1,0,1,1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