Ransom Conant / Mbed 2 deprecated MbedPacman

Dependencies:   4DGL-uLCD-SE mbed wave_player

Fork of PacMan_Skeleton_unlock by ECE 2035 TA

Revision:
1:fbda247b843b
Parent:
0:be33a1fad8c0
--- a/pacman.cpp	Fri Feb 24 17:33:27 2017 +0000
+++ b/pacman.cpp	Thu Mar 29 05:05:51 2018 +0000
@@ -26,8 +26,26 @@
 #include "pacman.h"
 
 PLAYER pacman;
-int score;
+
+
+int score, highscore;
 
+void pacman_add_score(int add){
+    score += add;
+}
+int pacman_get_x(void){
+    return pacman.grid_x;
+}
+
+int pacman_get_y(void){
+    return pacman.grid_y;
+}
+
+void pacman_reset_score(void){
+    score = 0;
+    uLCD.locate(0,0);
+    uLCD.printf("score:%d",score);
+}
 void pacman_init(int grid_x, int grid_y){
     pacman.motion = PACMAN_HEADING_RIGHT;
     pacman.status = PACMAN_WAIT_COMMAND;
@@ -35,8 +53,10 @@
     pacman.grid_y = grid_y;
     map_eat_cookie(grid_x,grid_y); //clear the cookie on the grid.
     pacman_draw();
-    score = 0;
+    uLCD.locate(0,0);
     uLCD.printf("score:%d",score);
+    uLCD.locate(9,1);
+    uLCD.printf("best:%d",highscore);
 }
 
 void pacman_draw(void){
@@ -81,10 +101,11 @@
     pacman.status = PACMAN_RUNNING;
 }
 
-void pacman_update_position(void){
+int pacman_update_position(int level){
     GRID next_grid_info;
     int x = pacman.grid_x;
     int y = pacman.grid_y;
+    int value = 0;
     if(pacman.status==PACMAN_RUNNING){
         switch(pacman.motion){
             case PACMAN_HEADING_UP:
@@ -126,12 +147,24 @@
             if(next_grid_info.status>=GRID_COOKIE){
                 map_eat_cookie(x,y);
                 score++;
-                if(next_grid_info.status==GRID_SUPER_COOKIE) //one super cookie worth 5 points
+                if(next_grid_info.status==GRID_SUPER_COOKIE){ //one super cookie worth 5 points
                     score+=4;
+                    
+                    if(level <= 4)
+                        value = (5000-(1000*level));
+                    else
+                        value = 1000;
+                        
+                }
                 uLCD.locate(0,0);
                 uLCD.printf("score:%d",score);
+                if(score > highscore)
+                    highscore = score;
+                uLCD.locate(9,1);
+                uLCD.printf("best:%d",highscore);
+               
             }
         }
     }
-        
+    return value; 
 }
\ No newline at end of file