ELEC2645 (2018/19) / Mbed 2 deprecated el17aj

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Wall Class Reference

Wall Class Reference

Wall Class. More...

#include <Wall.h>

Data Structures

struct  Health
 Health struct. More...

Public Member Functions

void init (int maxHealth)
 Initialises the Wall with a max health.
void draw (N5110 &lcd)
 Draws the wall on the display.
void set_wall_health (int wall_health)
 sets the wall health
int get_wall_health ()
 Returns integer value of wall health.
void take_damage (int damage)
 Does damage to the wall.

Detailed Description

Wall Class.

Author:
Adam Jones, University of Leeds Controls the Cross Hairs in the Wall Defence game
Date:
April 2017
#include "N5110.h"
#include "Wall.h"



int main()
{   
    Wall _wall;
    

    //initialise wall object with 100 life
    _wall.init(100);
    
    //draw wall
    _wall.draw(lcd);
    
    //decrease walls health by 1
    _wall.take_damage(1);
    
    //get wall health
    int wallHealth = _wall.get_wall_health()
}

Definition at line 42 of file Wall.h.


Member Function Documentation

void draw ( N5110 lcd )

Draws the wall on the display.

Parameters:
lcdthe N5110 screen object

Definition at line 34 of file Wall.cpp.

int get_wall_health (  )

Returns integer value of wall health.

Returns:
wall health

an integer value

Definition at line 64 of file Wall.cpp.

void init ( int  maxHealth )

Initialises the Wall with a max health.

Parameters:
maxhealth

integer representing the life of the wall

Definition at line 24 of file Wall.cpp.

void set_wall_health ( int  wall_health )

sets the wall health

Parameters:
healthinteger value

Definition at line 60 of file Wall.cpp.

void take_damage ( int  damage )

Does damage to the wall.

Parameters:
damagean integer representing the amount of damage to the wall health

Definition at line 69 of file Wall.cpp.