ELEC2645 (2018/19) / Mbed 2 deprecated el17ntkv

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ScreenArray.cpp Source File

ScreenArray.cpp

00001 #include "ScreenArray.h"
00002 
00003 //Default screenarray object constructor
00004 ScreenArray::ScreenArray() {}
00005 
00006 //Default screenarray object destructor
00007 ScreenArray::~ScreenArray() {}
00008 
00009 
00010 //Mutator method initialises the screenarray object by filling the integer
00011 //array with zeros
00012 void ScreenArray::init(){
00013     screen_x =48;
00014     screen_y = 84;
00015 
00016     for(int i = 0; i < screen_x; i++) {
00017         for(int t = 0; t < screen_y; t++) {
00018             Screen[t][i] = 0;
00019         }
00020     }
00021 }
00022 
00023 //Accessor method returns the value of the element at the array poisiton denoted
00024 //by the x and y coordinates(columns and rows value) passed as the method parameter
00025 int ScreenArray::get(int x,int y) {
00026     return Screen[y][x];
00027 }
00028 
00029 //Mutator method sets the array element at the position denoted by the x and y
00030 //coordinates(columns and rows value) to the type(integer value) passed as the
00031 //method's parameters
00032 void ScreenArray::set(int x,int y,int type){
00033     Screen[y][x] = type;
00034 }
00035 
00036 
00037 //Mutator method sets all the elements within the region of elements within the
00038 //screen array to the type passed as the method parameter call
00039 void ScreenArray::setRange(int x,int y,int width,int height,int type) {
00040 
00041     for(int a = x; a < (x + width); a++) {
00042         for(int b = y ; b < (y + height); b++) {
00043             Screen[b][a] = type;
00044         }
00045     }
00046 }
00047