Henry Triff / Mbed 2 deprecated ELEC2645_Project_el18ht

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 ()
 Constructor.
 ~Ghost ()
 Destructor.
void SD_init (SDFileSystem &SD, N5110 &LCD)
 Formats the SD card with the correct text files and fills them with temporary data.
void SD_Read (int track, int car, SDFileSystem &SD)
 Copies the ghost data int the txt file associated with the track-car combination to RAM.
void Record (Point_2D position, int race_time)
 Adds the current position of the car to a Ghost_Data array.
void Copy (int race_time, int track, int car, SDFileSystem &SD)
 If the race that was just run was faster than previos races, this copies the data in the Ghost_Data array to the SD card.
Point_2D Play (bool ghost_available, int race_time)
 Returns the position of the ghost for a given race_time.

Detailed Description

Ghost Class.

Records the current position of the player so that it can be played back later during ghost mode. The best race (so far) is copied to the SD card when the race is over. Before each race, the previos best ghost data is read from the SD card to internal memory to allow the game to run faster.

Author:
Henry W Triff
Date:
Mar, 2020

Definition at line 97 of file Ghost.h.


Constructor & Destructor Documentation

Ghost (  )

Constructor.

Definition at line 3 of file Ghost.cpp.

~Ghost (  )

Destructor.

Definition at line 7 of file Ghost.cpp.


Member Function Documentation

void Copy ( int  race_time,
int  track,
int  car,
SDFileSystem SD 
)

If the race that was just run was faster than previos races, this copies the data in the Ghost_Data array to the SD card.

Parameters:
race_timeThe number of frames elapsed during race
trackThe user selected track (int)
carThe user selected car (int)
SDThe object for the SDFileSystem class (object)

Definition at line 22 of file Ghost.cpp.

Point_2D Play ( bool  ghost_available,
int  race_time 
)

Returns the position of the ghost for a given race_time.

Parameters:
ghost_availableIs the game in ghost mode (bool)
race_timeThe current number of frames elapsed during race (int)
Returns:
Current position of the ghost

Definition at line 31 of file Ghost.cpp.

void Record ( Point_2D  position,
int  race_time 
)

Adds the current position of the car to a Ghost_Data array.

Parameters:
positionThe current coordinate position of the players car (Point_2D)
race_timeThe current number of frames elapsed during race

Definition at line 15 of file Ghost.cpp.

void SD_init ( SDFileSystem SD,
N5110 LCD 
)

Formats the SD card with the correct text files and fills them with temporary data.

Parameters:
SDThe object for the SDFileSystem class (object).

Definition at line 46 of file Ghost.cpp.

void SD_Read ( int  track,
int  car,
SDFileSystem SD 
)

Copies the ghost data int the txt file associated with the track-car combination to RAM.

Parameters:
trackThe user selected track (int)
carThe user selected car (int)
SDThe object for the SDFileSystem class (object)

Definition at line 138 of file Ghost.cpp.