submit

Dependencies:   mbed Gamepad N5110

Revision:
22:51fb86b48d9d
Parent:
21:5861b5baf4b0
Child:
23:fd0339ec480c
--- a/main.cpp	Fri May 03 06:01:59 2019 +0000
+++ b/main.cpp	Sun May 05 16:31:55 2019 +0000
@@ -49,25 +49,25 @@
 void run()
 {
     // clear screen, re-draw and refresh
-    lcd.clear();
-    int length = snake.get_length();
-    int direction = engine.get_direction(pad);
-    snake.check_eat(pad);
-    snake.update(direction,length);
-    snake.draw(lcd,length);
-    snake.check_over(lcd);
-    lcd.refresh();
+    lcd.clear(); // lear the lcd
+    int length = snake.get_length(); // get length 
+    int direction = engine.get_direction(pad); // get direction
+    snake.check_eat(pad); // check if eat
+    snake.update(direction,length); // update the position of snake
+    snake.draw(lcd,length); // draw the snake
+    snake.check_over(lcd); // check if the game is over
+    lcd.refresh(); // refresh the lcd
 }
 
 // initialies all classes and libraries
 void init()
 {
     // need to initialise Gamepad, engine, sanke and clear the screen
-    pad.init();    
+    pad.init(); // initialise the Gamepad
     snake.init(2,3); // set the size = 2 and length = 3
-    engine.init();
-    finger.init();
-    lcd.clear();
+    engine.init(); // initialise the engine
+    finger.init(); // initialise the figner game
+    lcd.clear(); // initialise the lcd
 }
 
 //gameover screen
@@ -75,6 +75,6 @@
 {
     int s = snake.get_score(); // get the scores to show at the gameover display
     int hs = snake.hscore; // get the heighest record to show at the gameover display
-    engine.gameover(pad,lcd,s,hs);
+    engine.gameover(pad,lcd,s,hs); // show the gameover display
 
 }
\ No newline at end of file