ELEC2645 (2018/19) / Mbed 2 deprecated el17ntkv

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Ghost Class Reference

Ghost Class Reference

Ghost Class. More...

#include <Ghost.h>

Public Member Functions

 Ghost ()
 Default Ghost object constructor.
 ~Ghost ()
 Default Ghost object destructor.
void init (int size, int x, int y)
 Mutator method initialises the ghost character object setting it's radius and start position in the maze.
void draw (N5110 &lcd)
 Mutator method displays the ghost character on the lcd screen dependent on it's current x and y coordinates and size.
bool collisiondetection (int x, int y, int r)
 Accessor method checks whether the ghost object has collided with the badman character object.
Vector2D getPos ()
 Accessor method gets the current coordinates of the ghost character object.
void update (ScreenArray &screen)
 Mutator method updates the ghost object's movement in the instance that the ghost has collided with a wall.
int checkCollision (ScreenArray &screen)
 Accessor method checks ghost-wall collisions.
void setPos (int x, int y)
 Mutator method gets the current x and y coordinate of the ghost object to the coordinate passed in the function call.
int getSize ()
 Accessor method gets the size of badman character object.

Detailed Description

Ghost Class.

Author:
Mr Nigel TK Vere, University of Leeds Controls and models the ghost character for the badman game
Date:
April 2019 Ghost Class

Controls and models the ghost character for the badman game

Version:
1.0
Author:
Mr Nigel TK Vere
Date:
April 2019

Definition at line 30 of file Ghost.h.


Constructor & Destructor Documentation

Ghost (  )

Default Ghost object constructor.

Definition at line 4 of file Ghost.cpp.

~Ghost (  )

Default Ghost object destructor.

Definition at line 8 of file Ghost.cpp.


Member Function Documentation

int checkCollision ( ScreenArray screen )

Accessor method checks ghost-wall collisions.

Returns:
Returns an integer value notifying the type of object the ghost has collided with as it moves

Definition at line 140 of file Ghost.cpp.

bool collisiondetection ( int  x,
int  y,
int  r 
)

Accessor method checks whether the ghost object has collided with the badman character object.

Parameters:
xInteger value giving the x coordinate of the badman character object
yInteger value giving the y coordinate of the badman character object
rInteger value giving the radius of the badman character object
Returns:
Returns a boolean value notifying whether a ghost-badman collision has occured

Definition at line 54 of file Ghost.cpp.

void draw ( N5110 lcd )

Mutator method displays the ghost character on the lcd screen dependent on it's current x and y coordinates and size.

Parameters:
lcdReference Nokia 5110 LCD screen object

Definition at line 43 of file Ghost.cpp.

Vector2D getPos (  )

Accessor method gets the current coordinates of the ghost character object.

Returns:
Returns the Vector data type holding the current x and y coordinates of the ghost character object's centre

Definition at line 67 of file Ghost.cpp.

int getSize (  )

Accessor method gets the size of badman character object.

Returns:
Returns the size(radius ) of the badman character object
void init ( int  size,
int  x,
int  y 
)

Mutator method initialises the ghost character object setting it's radius and start position in the maze.

Parameters:
sizeInteger value giving the radius of the ghost object
xInteger value giving the x coordinate of the ghost object
yInteger value giving the y coordinate of the ghost object

Definition at line 16 of file Ghost.cpp.

void setPos ( int  x,
int  y 
)

Mutator method gets the current x and y coordinate of the ghost object to the coordinate passed in the function call.

Parameters:
xX coordinate value of the new position the ghost character object is to move to
yY coordinate value of the new position the ghost character object is to move to

Definition at line 75 of file Ghost.cpp.

void update ( ScreenArray screen )

Mutator method updates the ghost object's movement in the instance that the ghost has collided with a wall.

Parameters:
screenReference screen array object for the ghost object collision detection

Definition at line 99 of file Ghost.cpp.