Dependencies:   mbed

Revision:
18:5fcb0514fb70
Parent:
17:4c5f25d5c4d5
Child:
25:31761087a83f
--- a/Graphics/Graphics.cpp	Sat Mar 28 12:50:59 2020 +0000
+++ b/Graphics/Graphics.cpp	Sat Mar 28 13:08:30 2020 +0000
@@ -8,12 +8,9 @@
 {
 }
 
-
-
-
-//***********
-//  Sprites
-//***********
+//-----------
+//  SPRITES
+//-----------
 
 int logo[48][84] = {
     {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0},
@@ -259,12 +256,12 @@
     {4,4,4,4,4,0,0,0,0,0,0,4,4,4,4,4},
 };
 
-//**************************
+//--------------------------
 //  MAIN GRAPHICS FUNCTION
-//**************************
-// This is the main function for the graphics. It is a LARGE function but it reduces the clutter in the main function.
-// It is a LARGE function but it reduces the clutter in the main function.
-// This is run once every frame
+//--------------------------
+// This is the main function for the graphics.
+// It is a LARGE function but it reduces the clutter in main.cpp
+// This is run once every frame.
 
 void Graphics::Draw_Map(Point_2D translation, int angle, float squish, Line_2D *Track_Lines, Line_2D *Track_Dotted_Lines, Line_2D *Track_Walls, Point_2D *Track_Flags, Triangle_2D *Track_Boost_Plates, Map_Data map_info, int car_type, Point_2D ghost_position, N5110 &LCD)
 {
@@ -384,9 +381,9 @@
     }
 }
 
-//**************
+//--------------
 //  START LOGO
-//**************
+//--------------
 
 void Graphics::Draw_Logo(N5110 &LCD) //Draw the game logo
 {
@@ -396,19 +393,20 @@
     wait(1);
 }
 
-//*******************
+//-------------------
 //  SCREEN SETTINGS
-//*******************
+//-------------------
 
 void Graphics::Change_Contrast(N5110 &LCD, Gamepad &Device) //Sets the contrast with a greater level of precision
 {
     LCD.setContrast((0.35 + 0.2 * Device.read_pot1()));
 }
 
-//****************
-//  START SCREEN
-//****************
+//---------------------------
+//  RACE START / END SCREEN
+//---------------------------
 
+//START
 void Graphics::Start_Sequence(int state, N5110 &LCD) //Display the countdown numbers before the race starts
 {
     Point_2D count_down_position = {8,8};
@@ -424,15 +422,16 @@
 
 }
 
+//FINISH
 void Graphics::Finish(N5110 &LCD) //When the race is over draw the cup symbol
 {
     Point_2D finish_position = {8,8};
     Graphics_Draw_Sprite(finish_position, 16, 16, (int *) cup, LCD);
 }
 
-//********************
+//--------------------
 //  DRAW LAP COUNTER
-//********************
+//--------------------
 
 void Graphics::Draw_Laps(int laps, N5110 &LCD) //Prints the lab counter in the bottom left corner
 {
@@ -449,6 +448,10 @@
     }
 }
 
+//-------------------
+//  DRAW RACE CLOCK
+//-------------------
+
 void Graphics::Draw_Time(bool finished, Time time, N5110 &LCD) //Displays the lap time
 {
     if(finished == false) { //If the race is over, Print the time in the middle of the screen
@@ -500,9 +503,9 @@
     }
 }
 
-//**************
-//  TRANSFORM
-//**************
+//-------------------
+//  TRANSFORMATIONS
+//-------------------
 
 //ROTATE
 Point_2D Graphics::Rotate_Point(Point_2D point, float angle) //Rotates all points around the origin
@@ -528,10 +531,11 @@
     return {x_squish, y_squish};
 }
 
-//********
+//--------
 //  MATH
-//********
+//--------
 
+//ROUNDING FLOATING POINT NUMBERS
 int Graphics::Round(float number) //Simple function that rounds floating point numbers
 {
     int number_int = (number * 10); //The number is multiplied by 10
@@ -543,6 +547,7 @@
     }
 }
 
+//CALCULATING THE GRADIENT OF A LINE
 float Graphics::Gradient(Point_2D from, Point_2D to) //Calculates the gradient of the line between two points
 {
     float change_in_y = to.y - from.y; //Calculates the change in the y-values of the two points
@@ -555,6 +560,7 @@
     }
 }
 
+//CHECKING IF A GRADIENT IS VERY LARGE
 bool Graphics::Gradient_Check_Infinate(Point_2D from, Point_2D to) //Checks to see if the gradient is vertical
 {
     float change_in_x = to.x - from.x; //Calculates the change in the x-value
@@ -565,9 +571,9 @@
     }
 }
 
-//*************
+//-------------
 //  DRAW LINE
-//*************
+//-------------
 
 void Graphics::Graphics_Draw_Line(Point_2D from, Point_2D to, bool solid, N5110 &LCD) //Draw a line between two points on only the portion of the screen
 {
@@ -663,9 +669,9 @@
     }
 }
 
-//***************
+//---------------
 //  DRAW SPRITE
-//***************
+//---------------
 
 void Graphics::Graphics_Draw_Sprite(Point_2D point, int x_size, int y_size, int *sprite, N5110 &LCD) //Similar to N5110 drawSprite function but mine uses the origin as poin 0,0 and allows for transparent pixels
 {
@@ -683,9 +689,9 @@
     }
 }
 
-//***************
+//-------------
 //  DRAW WALL
-//***************
+//-------------
 
 void Graphics::Graphics_Draw_Wall(Point_2D from, Point_2D to, int height, N5110 &LCD) //Draw a line between two points on only the portion of the screen
 {
@@ -761,9 +767,9 @@
     }
 }
 
-//********************
+//--------------------
 //  DRAW BOOST PLATE
-//********************
+//--------------------
 
 void Graphics::Graphics_Draw_Boost_Plate(Triangle_2D boost_plate, Point_2D translation, int angle, float squish, N5110 &LCD) //Draws a boost plate on the track
 {