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:
- 4:713ac9379ac6
- Parent:
- 3:b4de529de482
- Child:
- 5:add0351183be
--- a/main.cpp Mon Apr 24 20:51:27 2017 +0000
+++ b/main.cpp Mon Apr 24 23:22:10 2017 +0000
@@ -3,6 +3,7 @@
#include "N5110.h"
#include "Pokemon.h"
#include "Images.h"
+#include "Bitmap.h"
//rewritten code to implement new/better ideas. part of the code is same as before but lots of changes were needed.
@@ -37,15 +38,15 @@
int main()
{
- init();
- drawStart();
- Gamepage state = START;
+ init(); //initialising screen and gamepad
+ drawStart(); //screen shows startup screen
+ Gamepage state = START; //go to start state
//-----------------------GAME LOOP START-------------------------------
while(1) {
if (state == START) {
state = PARTNER;
- } else if (state == PARTNER) {
+ } else if (state == PARTNER) { //choosing your partner
int partner = drawPartner();
int correct = partnerChoice(partner);
if( correct == 1) {
@@ -56,13 +57,13 @@
state = MENU;
}
- } else if (state == FIGHT) {
+ } else if (state == FIGHT) { //fight with wild pokemon
state = MENU;
- } else if (state == SETTINGS) {
+ } else if (state == SETTINGS) { //settings, screen brightness
state = MENU;
- } else if (state == MENU) {
+ } else if (state == MENU) { // main menu
wait(1.0);
int box = drawMenu();
if (box == 0) {
@@ -82,7 +83,7 @@
wait(2.0);
lcd.clear();
- } else if (state == POKEMON) {
+ } else if (state == POKEMON) { //check partner pokemon stats
state = MENU;
drawPoke();
}
@@ -107,8 +108,8 @@
lcd.printString(" Press Start ",0,4);
lcd.refresh();
- while( pad.check_event(Gamepad::START_PRESSED) == false) {
- pad.led(1,1);
+ while( pad.check_event(Gamepad::START_PRESSED) == false) { // until start is pressed, this loop cycles
+ pad.led(1,1); //cycle through LED's on gamepad
pad.led(6,1);
wait(0.5);
pad.led(2,1);
@@ -128,25 +129,25 @@
wait(1.0);
}
-void select(int x,int y, int L)
+void select(int x,int y, int L) //select box's
{
- lcd.drawRect(x,y,L,L,FILL_TRANSPARENT);
+ lcd.drawRect(x,y,L,L,FILL_TRANSPARENT);
}
-void deselect(int _x,int _y, int _L)
+void deselect(int _x,int _y, int _L) //removing select box's
{
lcd.drawRect(_x,_y,_L,_L, FILL_WHITE);
}
-void balls()
+void balls() //show the pokeballs on the screen for player to choose from
{
sp.ball(11,18);
sp.ball(35,18);
sp.ball(59,18);
lcd.refresh();
}
-
-float drawPartner()
+
+float drawPartner() //choice of pokeball
{
select(9,16,15);
int offset = 0;
@@ -179,39 +180,46 @@
return offset;
}
-float partnerChoice(int choice)
+float partnerChoice(int choice) //shows pokemon inside ball, gives choice to choose that mon
{
lcd.clear();
int _d = pad.get_direction();
+ int end = 0;
if(choice == 0) {
- sp.bulbasaur(16,0);
+ sp.bulbasaur(16,0); //grass starter
} else if(choice == 1) {
- sp.charmander(16,0);
+ sp.charmander(16,0);//fire starter
} else if(choice == 2) {
- sp.squirtle(16,0);
+ sp.squirtle(16,0);//water starter
}
lcd.printString("Are you",0,2);
lcd.printString(" sure??",0,3);
+ lcd.printString("Yes",65,1);
+ lcd.printString("No",65,5);
+ select(62,6,8);
lcd.refresh();
while(pad.check_event(Gamepad::A_PRESSED)== false) {
lcd.printString("Yes",65,1);
lcd.printString("No",65,5);
- select(62,6,8);
lcd.refresh();
+ wait(0.25);
int offset1 = 0;
- if(offset1 == 0 && _d == S) {
+ if(offset1 == 0 && _d == S) { //choose no
deselect(62,6,8);
+ select(62,38,8);
+ end = 0;
+ } else if(offset1 == 1 && _d ==N) {//choose yes
+ deselect(62,38,8);
select(62,6,8);
- } else if(offset1 == 1 && _d ==N) {
- deselect(62,38,8);
- select(62,38,8);
+ end = 1;
}
return offset1;
+
}
-
+ return end;
}
-void choice(int p)
+void choice(int p) //sets up class for your chosen starter
{
lcd.clear();
if (p == 0) {
