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: mbed
Diff: main.cpp
- Revision:
- 3:dd4678a85a1a
- Parent:
- 2:23b20cbd3330
- Child:
- 4:402c27b212c1
--- a/main.cpp Mon May 01 16:37:53 2017 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,396 +0,0 @@
-#include "mbed.h"
-#include "N5110.h"
-#include "Gamepad.h"
-#include "Treasure.h"
-#include "hole.h"
-#include "human.h"
-#include "interface.h"
-
-
-
-N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
-Gamepad pad;
-Treasure treasure;
-hole Blackhole;
-human person;
-interface Interface;
-
-
-void bool_check();
-void A_bomb();
-void B_bomb();
-void X_bomb();
-void Y_bomb();
-void end();
-void welcome();
-void render();
-
-
-void welcome() {
-
- lcd.printString(" Bomb! ",0,1);
- lcd.printString(" Press Start ",0,4);
- lcd.refresh();
-
- // wait flashing LEDs until start button is pressed
- while ( pad.check_event(Gamepad::START_PRESSED) == false) {
- pad.leds_on();
- wait(0.1);
- pad.leds_off();
- wait(0.1);
- }
-
-}
-
-void render()
-{
- // clear screen, re-draw and refresh
- lcd.clear();
-
- lcd.refresh();
-}
-
-int main()
-{
- double x;
- double y;
-
- lcd.init();
- pad.init();
- lcd.clear();
- lcd.normalMode(); // normal colour mode
- lcd.setBrightness(0.5); // put LED backlight on 50%
-
-
- treasure.treasure_place();
- Blackhole.hole_place();
-
- //printf("First stage\n");
-
- welcome();
-
-
- while (1) {
-//
-
- int four = ((rand())%4)+1;
- printf("%i\n", four);
- x = person.humanX();
- //printf("Pass one ");
- y = person.humanY();
- //printf("Pass two");
- person.print_human();
-
- Blackhole.hole_show();
- lcd.refresh();
- lcd.clear();
-
-
- printf("check 1\n");
- bool check = Blackhole.test(x,y);
- printf("%i\n",four);
- if( pad.check_event(Gamepad::R_PRESSED) == true && check )
- {
-
- switch (four){
-
- case 1 :
- printf ("bomb_A\n");
- A_bomb();
-
- break;
- case 2 : B_bomb();
- printf ("bomb_B");
-
- break;
- case 3 : X_bomb();
- printf ("bomb_X");
-
- break;
- case 4 : Y_bomb();
- printf ("bomb_Y");
-
- break;
- }
-
-
-
- }
- lcd.refresh();
- lcd.clear();
- }
-
-}
-
-void bool_check()
-{
-
-}
-
-void A_bomb()
-{
- bool first = true;
- bool second = true;
- bool third = true;
- bool fourth = true;
-
- bool check1 = false;
- bool check2 = false;
- bool check3 = false;
-
- bool_check();
- while(1)
- {
- if(pad.check_event(Gamepad::B_PRESSED) == true)
- {
- second = false;
- check1 = true;
- }
- else if(pad.check_event(Gamepad::X_PRESSED) == true)
- {
- third = false;
- check2 = true;
- }
- else if(pad.check_event(Gamepad::Y_PRESSED) == true)
- {
- fourth = false;
- check3 = true;
- }
- else if(pad.check_event(Gamepad::A_PRESSED) == true) // bomb A
- {
- end();
- }
- lcd.refresh();
- lcd.clear();
- if(first)
- {
- Interface.A();
- }
- if(second)
- {
- Interface.B();
-
- }
- if(third)
- {
- Interface.X();
-
- }
- if(fourth)
- {
- Interface.Y();
- }
- if(check1 && check2 && check3)
- {
- main();
- }
- Interface.border();
- lcd.refresh();
- lcd.clear();
- } // end of A press
-}
-
-
-void B_bomb()
-{
- bool first = true;
- bool second = true;
- bool third = true;
- bool fourth = true;
-
- bool check1 = false;
- bool check2 = false;
- bool check3 = false;
-
- bool_check();
- while(1)
- {
- if(pad.check_event(Gamepad::A_PRESSED) == true)
- {
- second = false;
- check1 = true;
- }
- else if(pad.check_event(Gamepad::X_PRESSED) == true)
- {
- third = false;
- check2 = true;
- }
- else if(pad.check_event(Gamepad::Y_PRESSED) == true)
- {
- fourth = false;
- check3 = true;
- }
- else if(pad.check_event(Gamepad::B_PRESSED) == true) // bomb B
- {
- end();
- }
- lcd.refresh();
- lcd.clear();
- if(first)
- {
- Interface.B();
- }
- if(second)
- {
- Interface.A();
-
- }
- if(third)
- {
- Interface.X();
-
- }
- if(fourth)
- {
- Interface.Y();
- }
- if(check1 && check2 && check3)
- {
- main();
- }
- Interface.border();
- lcd.refresh();
- lcd.clear();
- } // end of B press
-}
-
-void X_bomb()
-{
- bool first = true;
- bool second = true;
- bool third = true;
- bool fourth = true;
-
- bool check1 = false;
- bool check2 = false;
- bool check3 = false;
-
- bool_check();
- while(1)
- {
- if(pad.check_event(Gamepad::A_PRESSED) == true)
- {
- second = false;
- check1 = true;
- }
- else if(pad.check_event(Gamepad::B_PRESSED) == true)
- {
- third = false;
- check2 = true;
- }
- else if(pad.check_event(Gamepad::Y_PRESSED) == true)
- {
- fourth = false;
- check3 = true;
- }
- else if(pad.check_event(Gamepad::X_PRESSED) == true) // bomb X
- {
- end();
- }
- lcd.refresh();
- lcd.clear();
- if(first)
- {
- Interface.X();
- }
- if(second)
- {
- Interface.A();
-
- }
- if(third)
- {
- Interface.B();
-
- }
- if(fourth)
- {
- Interface.Y();
- }
- if(check1 && check2 && check3)
- {
- main();
- }
- Interface.border();
- lcd.refresh();
- lcd.clear();
- } // end of X press
-}
-
-void Y_bomb()
-{
- bool first = true;
- bool second = true;
- bool third = true;
- bool fourth = true;
-
- bool check1 = false;
- bool check2 = false;
- bool check3 = false;
-
- bool_check();
- while(1)
- {
- if(pad.check_event(Gamepad::A_PRESSED) == true)
- {
- second = false;
- check1 = true;
- }
- else if(pad.check_event(Gamepad::B_PRESSED) == true)
- {
- third = false;
- check2 = true;
- }
- else if(pad.check_event(Gamepad::X_PRESSED) == true)
- {
- fourth = false;
- check3 = true;
- }
- else if(pad.check_event(Gamepad::Y_PRESSED) == true) // bomb Y
- {
- end();
- }
- lcd.refresh();
- lcd.clear();
- if(first)
- {
- Interface.Y();
- }
- if(second)
- {
- Interface.A();
-
- }
- if(third)
- {
- Interface.B();
-
- }
- if(fourth)
- {
- Interface.X();
- }
- if(check1 && check2 && check3)
- {
- main();
- }
- Interface.border();
- lcd.refresh();
- lcd.clear();
- } // end of Y press
-}
-
- void end()
-{
- while (1){
-
- lcd.printString(" Game Over ",0,2);
- lcd.refresh();
- lcd.clear();
- }
-}
-
-
-
-
-
\ No newline at end of file