zhangxinyu01text

Dependencies:   mbed

Revision:
12:3952ba0683c7
Parent:
10:167d0aa1c9b3
--- a/main.cpp	Tue Apr 17 08:00:08 2018 +0000
+++ b/main.cpp	Mon May 06 06:09:02 2019 +0000
@@ -2,43 +2,47 @@
 #include "mbed.h"
 #include "Gamepad.h"
 #include "N5110.h"
-#include "PongEngine.h"
+#include "cxkEngine.h"
 
 #ifdef WITH_TESTING
 # include "tests.h"
 #endif
 
-#define PADDLE_WIDTH 2
-#define PADDLE_HEIGHT 8
-#define BALL_SIZE 2
-#define BALL_SPEED 3
+/* ELEC2645 Embeeded System Project 
+School of Elctronic & Electrical Enigneering 
+University of Leeds 
+
+Name : Zhang Xinyu
+Username : Zhang Xin yu
+Student ID number : 201090208
+Date : 2019. 05.6
+
+*/
+
 
 /////////////// structs /////////////////
 struct UserInput {
     Direction d;
-    float mag;
+    float vara; // vara is the magnitude of the joystich
 };
+
 /////////////// objects ///////////////
 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
 Gamepad pad;
-PongEngine pong;
+cxkEngine basketball;
 
-///////////// prototypes ///////////////
+///////////// prototypes define the void ///////////////
 void init();
 void update_game(UserInput input);
-void render();
+void render();// main contain
 void welcome();
+void over();
 
 ///////////// functions ////////////////
 int main()
 {
-#ifdef WITH_TESTING
-    int number_of_failures = run_all_tests();
 
-    if(number_of_failures > 0) return number_of_failures;
-#endif
-
-    int fps = 8;  // frames per second
+    int fps = 8;  // frames 8k per second
 
     init();     // initialise and then display welcome screen...
     welcome();  // waiting for the user to start
@@ -49,8 +53,8 @@
 
     // game loop - read input, update the game state and render the display
     while (1) {
-        pong.read_input(pad);
-        pong.update(pad);
+        basketball.read_input(pad);
+        basketball.update(pad);
         render();
         wait(1.0f/fps);
     }
@@ -64,7 +68,7 @@
     pad.init();
      
     // initialise the game with correct ball and paddle sizes
-    pong.init(PADDLE_WIDTH,PADDLE_HEIGHT,BALL_SIZE,BALL_SPEED);
+    basketball.init(2,8,2,3);
 
 }
 
@@ -73,14 +77,15 @@
 {
     // clear screen, re-draw and refresh
     lcd.clear();  
-    pong.draw(lcd);
+    basketball.draw(lcd);
     lcd.refresh();
 }
 
 // simple splash screen displayed on start-up
 void welcome() {
     
-    lcd.printString("     Pong!    ",0,1);  
+    lcd.printString(" U beautiful",0,1);  
+    lcd.printString("zhang xinyu",0,2);
     lcd.printString("  Press Start ",0,4);
     lcd.refresh();