Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

LengthManager Class Reference

LengthManager Class Reference

LengthManager Class. More...

#include <LengthManager.h>

Public Member Functions

 LengthManager ()
 Constructor.
 ~LengthManager ()
 Destructor.
void init (N5110 *lcd)
 This function sets the initial length parameters and gets pointers of lcd and pad from int main() to be used privately in the entire class.
void MinusLength ()
 This function decrements the length value by 1;.
void PlusLength ()
 This function increments the length by one.
void print_length_on_screen ()
 This function prints the length on top edge of screen.
int _getLength ()
 This sends the current length value when called.
void _setLength (int length)
 This function obtains the length value to be altered for a specific operation.

Detailed Description

LengthManager Class.

This class calculates the length of the snake at every point during the game and can be used to set length values in other classes using _getLength().

Author:
Ahmed N.Adamjee
Date:
8th May 2019

Definition at line 13 of file LengthManager.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 3 of file LengthManager.cpp.

~LengthManager (  )

Destructor.

Definition at line 8 of file LengthManager.cpp.


Member Function Documentation

int _getLength (  )

This sends the current length value when called.

Returns:
_length

This is the length of the snake, which is passed back after any manipulation such as MinusLength() or PlusLength().

        return _length;

Definition at line 38 of file LengthManager.cpp.

void _setLength ( int  length )

This function obtains the length value to be altered for a specific operation.

Parameters:
lengthThis is the length of the snake, which is recieved from the calling function to either initialise this or update this.

        _length = length;

Definition at line 43 of file LengthManager.cpp.

void init ( N5110 lcd )

This function sets the initial length parameters and gets pointers of lcd and pad from int main() to be used privately in the entire class.

Parameters:
N5110*lcd

pointer to the N5110 object in main, address of this pointer is saved to make availability to the entire class, without passing address to each function.

Parameters:
Gamepad*pad

pointer to the gamepad object in main, address of this pointer is saved to make availability to the entire class, without passing address to each function.

        _lcd = lcd;
        _length = 4;

Definition at line 15 of file LengthManager.cpp.

void MinusLength (  )

This function decrements the length value by 1;.

        _length -= 1;

Definition at line 21 of file LengthManager.cpp.

void PlusLength (  )

This function increments the length by one.

        _length += 1;

Definition at line 26 of file LengthManager.cpp.

void print_length_on_screen (  )

This function prints the length on top edge of screen.

        char bufferscore[14];
        sprintf(bufferscore,"%d",_length);
        _lcd->printString(bufferscore,1,0);

Definition at line 31 of file LengthManager.cpp.