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:
- el17mcd
- Date:
- 2019-04-17
- Revision:
- 13:feadff02d3f7
- Parent:
- 12:9e6d5d0a0c82
- Child:
- 14:fe2e16cdf219
File content as of revision 13:feadff02d3f7:
/*
ELEC2645 Embedded Systems Project
School of Electronic & Electrical Engineering
University of Leeds
Name: Maxim C. Delacoe
Username: EL 17 MCD
Student ID Number: 2011 58344
Date: 19/03/2019
*/
///////// pre-processor directives ////////
#include "mbed.h"
#include "Gamepad.h"
#include "N5110.h"
#include "Bitmap.h"
#include "Tank.h"
#include "TanksEngine.h"
#include "Projectile.h"
#include "Graphics.h"
#define PI 3.14159265
#define DEG2PI 0.0174532925 
#include <cmath>
#ifdef WITH_TESTING
#endif
/////////////// objects ///////////////
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
TanksEngine engine;
Gamepad pad;
Graphics graphics;
void welcome()
{
    lcd.clear();
    lcd.printString("  ELEC 2645",0,0);
    lcd.printString("  Game  ",0,1);
    lcd.printString("   Project",0,2);
    lcd.printString("Max C. Delacoe",0,4);
    lcd.printString(" 2011 58344",0,5);
    lcd.refresh();
    wait(0.2);
}
int main()
{
    lcd.init();
    pad.init();
    engine.initgame();
    int fps = 60;
    float frame_period_ms = 1000/fps;
    pad.led(3,1) ;
    pad.led(4,0.5) ;
    pad.led(5,0.25) ;
    
   // welcome();  // display welcome message 
    while(1) {  // infinite loop
    
        lcd.clear();  
        engine.read_input(pad); 
        graphics.draw_parkinson_map(lcd);       
        if (engine.get_turn() == 1) {
            engine.left_tank_turn(graphics, pad);
        } else if (engine.get_turn() == 2 || engine.get_turn() == 4) {
            engine.projectile_phase(lcd);
        } else if (engine.get_turn() == 3) {
            engine.right_tank_turn(graphics, pad); }
        engine.end();
        if (engine.get_turn() == 5) {
            while (1) {
                lcd.clear();
                engine.render(graphics, lcd);
                lcd.refresh();
            }
        }
        engine.render(graphics, lcd);
        lcd.refresh();
        wait_ms(frame_period_ms);      
    }
    /*
lcd.clear();
lcd.printString("DONE",0,1);
lcd.refresh();
wait(10);*/
}