Wang Lin 201090174

Dependencies:   mbed Gamepad N5110 FXOS8700Q

Revision:
6:d9d05b321b4d
Parent:
4:d349e5d847cf
Child:
10:167d0aa1c9b3
--- a/main.cpp	Fri Feb 16 13:37:49 2018 +0000
+++ b/main.cpp	Wed Feb 21 10:04:46 2018 +0000
@@ -18,21 +18,24 @@
 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
 Gamepad pad;
 PongEngine pong;
+
 ///////////// prototypes ///////////////
 void init();
 void update_game(UserInput input);
 void render();
 void welcome();
+
 ///////////// functions ////////////////
 int main()
 {
     int fps = 8;  // frames per second
 
-    init();
-    welcome();
+    init();     // initialise and then display welcome screen...
+    welcome();  // waiting for the user to start
     
-    render();  // draw initial frame 
-    wait(1.0f/fps);  
+    render();  // first draw the initial frame 
+    wait(1.0f/fps);  // and wait for one frame period
+
 
     // game loop - read input, update the game state and render the display
     while (1) {
@@ -43,17 +46,19 @@
     }
 }
 
+// initialies all classes and libraries
 void init()
 {
     // need to initialise LCD and Gamepad 
     lcd.init();
     pad.init();
      
-    // initialise the game
+    // initialise the game with correct ball and paddle sizes
     pong.init(PADDLE_WIDTH,PADDLE_HEIGHT,BALL_SIZE,BALL_SPEED);
 
 }
 
+// this function draws each frame on the LCD
 void render()
 {
     // clear screen, re-draw and refresh
@@ -62,6 +67,7 @@
     lcd.refresh();
 }
 
+// simple splash screen displayed on start-up
 void welcome() {
     
     lcd.printString("     Pong!    ",0,1);