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
main.cpp
- Committer:
- shahidsajid
- Date:
- 2019-04-27
- Revision:
- 17:b2b651acffae
- Parent:
- 14:122eaa3b7a50
File content as of revision 17:b2b651acffae:
/*
ELEC2645 Embedded Systems Project
School of Electronic & Electrical Engineering
University of Leeds
Name: Shahid Zubin Sajid
Username: el17szs   
Student ID Number: 201197609
Date: 21/03/2019
*/
#include "mbed.h"
#include "Gamepad.h"
#include "N5110.h"
#include "Ball.h"
#include "Bat.h"
#include "Cricket.h"
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Gamepad pad;
Cricket cricket;
Bat bat;
void init();
//void welcome();
void draw();
void ball_test();
int main(){
    int fps=10;
    init();
    //bat.first_menu(lcd);
   // welcome();
    //draw();
    //float f; 
    //int status=0;
    
    while(1){
        //Direction dir=pad.get_direction();
        cricket.game(lcd,pad);
        draw();
        wait(1.0f/fps);                
    }
    
    /*
    while(1){
        ball.reset();
        field.set_field(lcd);
        draw();
        while (status!=1){
            f= pad1.get_mag();
            int lol=bat.get_hitBall();  
            ball.start(lcd,lol,pad.get_direction());
            draw();
            wait(1.0f/fps);
       }
    }
    */
}
void init(){
    lcd.init();
    pad.init();
    //ball1.init(2,4);
    cricket.init();
    //bat1.init();
    lcd.setContrast(0.4);
    lcd.normalMode();      // normal colour mode
    lcd.setBrightness(0.5);
    lcd.clear();
    
}
void welcome() {
    lcd.printString("     CRICKET GAME    ",0,1);  
    lcd.printString(" SHAHID SAJID",0,2); 
    lcd.printString("     el17szs    ",0,3);
    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 draw(){
    lcd.clear();
    cricket.draw(lcd);
    lcd.refresh();
}
/*void ball_test(){
    Vector2D ball_pos = ball.get_pos();
    Vector2D ball_velocity = ball.get_velocity();
    ball.update();  
    ball.set_velocity(ball_velocity);
    ball.set_pos(ball_pos);
    ball.update(); 
}
*/