ELEC2645 (2018/19) / Mbed 2 deprecated el17ntkv

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Charactersprites.cpp Source File

Charactersprites.cpp

00001 #include "Charactersprites.h"
00002 
00003 //Default Charactersprite constructor
00004 Charactersprites::Charactersprites(){
00005 }
00006 
00007 //Default Charactersprite destructor
00008 Charactersprites::~Charactersprites(){
00009 }
00010 
00011 //Mutator method initialised the charactersprite method setting the charactersrpites top left
00012 //coordinates to the value passed in the methods call and setting the type to the value
00013 //passed in the call also setting the values of the subsequent corner coordinates
00014 void Charactersprites::init(int x,int y,int num){
00015     _topl.x = x;
00016     _topl.y = y;
00017     _type = num;
00018 
00019     if(_type == 1) {
00020         _value = 2;
00021     }
00022     if(_type == 2) {
00023         _value = 3;
00024     }
00025 
00026     _rows = 3;
00027     _cols = 3;
00028     _topr.x = _topl.x + _cols ;
00029     _topr.y = _topl.y;
00030     _bottr.x = _topl.x + _cols ;
00031     _bottr.y = _topl.y + _rows;
00032     _bottl.x = _topl.x;
00033     _bottl.y = _topl.y + _rows;
00034 
00035 }
00036 
00037 
00038 //Mutator method takes a reference LCD object as its paramater and subsequently
00039 //displays the respective charactersprite on the Nokia N5110 LCD screen
00040 void Charactersprites::displaySprite(N5110 &lcd) {
00041 
00042     if(_type == 1) {
00043 
00044         int Special[3][3] = {
00045             {1,1,1},
00046             {1,1,1},
00047             {1,1,1},
00048         };
00049         lcd.drawSprite(_topl.x,_topl.y,_rows,_cols,(int*)Special);
00050     }
00051     if(_type == 2) {
00052 
00053 
00054         int  normal[3][3] = {
00055             {1,1,1},
00056             {1,0,1},
00057             {1,1,1},
00058         };
00059 
00060         lcd.drawSprite(_topl.x,_topl.y,_rows,_cols,(int*)normal);
00061     }
00062 
00063 }
00064 
00065 //Accessor method returns the value of the charactersprite object
00066 //denoted by the _value private variable
00067 int Charactersprites::getValue() {
00068     return _value;
00069 }
00070 
00071 //Accessor method returns the top right coordinates of the  charactersprite object
00072 //denoted by the _topr private variable as a vector data type object
00073 Vector2D Charactersprites::getTopr() {
00074     return _topr;
00075 }
00076 
00077 //Accessor method returns the bottom right coordinates of the  charactersprite object
00078 //denoted by the _bottr private variable as a vector data type object
00079 Vector2D Charactersprites::getBottr() {
00080     return _bottr;
00081 }
00082 
00083 //Accessor method returns the bottom left coordinates of the  charactersprite object
00084 //denoted by the _bottl private variable as a vector data type object
00085 Vector2D Charactersprites::getBottl() {
00086     return _bottl;
00087 }
00088 
00089 //Accessor method returns the top left coordinates of the  charactersprite object
00090 //denoted by the _topl private variable as a vector data type object
00091 Vector2D Charactersprites::getTopl() {
00092     return _topl;
00093 }