Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Gamepad N5110 Pokemon mbed
Fork of 2645_Game_Project_2 by
Diff: main.cpp
- Revision:
- 5:add0351183be
- Parent:
- 4:713ac9379ac6
- Child:
- 6:6e9a415436e0
diff -r 713ac9379ac6 -r add0351183be main.cpp
--- a/main.cpp	Mon Apr 24 23:22:10 2017 +0000
+++ b/main.cpp	Mon Apr 24 23:53:53 2017 +0000
@@ -46,7 +46,7 @@
         if (state == START) {
             state = PARTNER;
 
-        } else if (state == PARTNER) { //choosing your partner 
+        } else if (state == PARTNER) { //choosing your partner
             int partner = drawPartner();
             int correct = partnerChoice(partner);
             if( correct == 1) {
@@ -129,14 +129,14 @@
     wait(1.0);
 }
 
-void select(int x,int y, int L) //select box's
+void select(int x,int y, int L, int H) //select box's
 {
-    lcd.drawRect(x,y,L,L,FILL_TRANSPARENT); 
+    lcd.drawRect(x,y,L,H,FILL_TRANSPARENT);
 }
 
-void deselect(int _x,int _y, int _L) //removing select box's
+void deselect(int _x,int _y, int _L, int _H) //removing select box's
 {
-    lcd.drawRect(_x,_y,_L,_L, FILL_WHITE);
+    lcd.drawRect(_x,_y,_L,_H, FILL_WHITE);
 }
 
 void balls() //show the pokeballs on the screen for player to choose from
@@ -146,10 +146,10 @@
     sp.ball(59,18);
     lcd.refresh();
 }
- 
+
 float drawPartner() //choice of pokeball
 {
-    select(9,16,15);
+    select(9,16,15,15);
     int offset = 0;
     int _d = pad.get_direction();
     while(pad.check_event(Gamepad::A_PRESSED) == false) {
@@ -159,19 +159,19 @@
             offset --;
         }
         if(offset == 0) {
-            deselect(57,16,15);
-            deselect(33,16,15);
-            select(9,16,15);
+            deselect(57,16,15,15);
+            deselect(33,16,15,15);
+            select(9,16,15,15);
             balls();
         } else if(offset == 1) {
-            deselect(57,16,15);
-            deselect(9,16,15);
-            select(33,16,15);
+            deselect(57,16,15,15);
+            deselect(9,16,15,15);
+            select(33,16,15,15);
             balls();
         } else if(offset == 2) {
-            deselect(9,16,15);
-            deselect(33,16,15);
-            select(57,16,15);
+            deselect(9,16,15,15);
+            deselect(33,16,15,15);
+            select(57,16,15,15);
             balls();
         }
         lcd.refresh();
@@ -196,7 +196,7 @@
     lcd.printString(" sure??",0,3);
     lcd.printString("Yes",65,1);
     lcd.printString("No",65,5);
-    select(62,6,8);
+    select(62,6,10,10);
     lcd.refresh();
     while(pad.check_event(Gamepad::A_PRESSED)== false) {
         lcd.printString("Yes",65,1);
@@ -205,12 +205,12 @@
         wait(0.25);
         int offset1 = 0;
         if(offset1 == 0 && _d == S) { //choose no
-            deselect(62,6,8);
-            select(62,38,8);
+            deselect(62,6,10,10);
+            select(62,38,10,10);
             end = 0;
         } else if(offset1 == 1 && _d ==N) {//choose yes
-            deselect(62,38,8);
-            select(62,6,8);
+            deselect(62,38,10,10);
+            select(62,6,10,10);
             end = 1;
         }
         return offset1;
@@ -237,20 +237,85 @@
     }
 }
 
+void menu()
+{
+    lcd.clear();
+    lcd.printString("  FIGHT",8,1);
+    lcd.printString(" POKEMON",8,3);
+    lcd.printString(" SETTINGS",8,5);
+}
 
 float drawMenu()
 {
+    menu();
+    int Xo = 19;
+    int Yo = 11;
+    select(Xo, Yo,42,12);
+    lcd.refresh();
+    wait(1.0);
+    int box = 0;
+    while( pad.check_event(Gamepad::A_PRESSED) == false) {
+        int d = pad.get_direction();
+        if (d == S && box >= 1 ) {
+            deselect(Xo, Yo,48,12);
+            Yo = Yo + 16;
+            select(Xo, Yo,48,12);
+            lcd.refresh();
+            box = box + 1;
+            wait(1.0);
+
+        } else if (d == N && box <= 1) {
+            deselect(Xo, Yo,48,12);
+            Yo = Yo - 16;
+            select(Xo, Yo,48,12);
+            lcd.refresh();
+            box = box - 1;
+            wait(1.0);
+
+        }
+    }
+    return box;
 }
+
 void drawFight()
 {
 }
 void drawPoke()
 {
+    lcd.clear();
+    while(pad.check_event(Gamepad::B_PRESSED) == false) {
+        std::string pkn = pk.Name();
+        std::string pkl = pk.Level();
+        std::string pkh = pk.HP();
+        std::string pkt = pk.Type();
+        char a[50];
+        char b[50];
+        char c[50];
+        char d[50];
+        strncpy(a, pkn.c_str(), sizeof(a));
+        strncpy(b, pkl.c_str(), sizeof(b));
+        strncpy(c, pkt.c_str(), sizeof(c));
+        strncpy(d, pkh.c_str(), sizeof(d));
+        lcd.printString("Pokemon:",2,0);
+        lcd.printString(a,2,1);
+        lcd.printString(b,2,2);
+        lcd.printString(c,2,3);
+        lcd.printString(d,2,4);
+        lcd.printString(" B = Back ",24,5);
+        lcd.refresh();
+    }
 }
-void menu()
-{
-}
+
 void settings()
 {
+    lcd.clear();
+    int bright = 1;
+    while(pad.check_event(Gamepad::B_PRESSED) == false) {
+        lcd.printString("SET BRIGHTNESS", 2, 20);
+        lcd.printString("B = BACK", 4, 20);
+        bright = pad.read_pot();
+        float brightness = 0.5*bright;
+        lcd.setBrightness(brightness);
+    }
 }
 
    