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-10
- Revision:
- 9:fe912235dd71
- Parent:
- 8:d4e419dad90f
- Child:
- 10:d4fb12e9e7cd
File content as of revision 9:fe912235dd71:
/*
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 "TankL.h"
#include "TanksEngine.h"
#include "Projectile.h"
#define PI 3.14159265
#define DEG2PI 0.0174532925 
#ifdef WITH_TESTING
#endif
/////////////// objects ///////////////
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
TankL tankl;
Projectile proj;
TanksEngine engine;
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();
    proj.set_launch_parameters(0, 4, 6, 45, 1.3, 0.02, 0.01);
    //tankl.set_health(1);
   // welcome();  // display welcome message 
    while(1) {  // infinite loop
            
        proj.update_flight();
        lcd.clear();
        proj.draw(lcd);
        lcd.refresh();
        wait_ms(50);
        if (proj.check_boundaries() == true) {break;}   
    }
lcd.clear();
lcd.printString("DONE",0,1);
lcd.refresh();
wait(10);
}    
/*        srand(time(NULL));  
        int t_pos_x = rand() % (84-1-10); // Tank position
        int t_pos_y = rand() % (48-1-6);
        tankl.set_position(t_pos_x, t_pos_y);
        
        int p_pos_x = rand() % (84-1-5);  // projectile position
        int p_pos_y = rand() % (48-1-5);
        proj.set_position(p_pos_x, p_pos_y);
        
        tankl.generate_hitbox();
        proj.generate_hitbox();
        bool hit = engine.collision_pl(tankl, proj);   
        
        lcd.clear();
        tankl.draw(lcd);
        proj.draw(lcd);
        lcd.refresh(); 
        if (hit == true) {
            wait(1.5);
            lcd.clear();
            tankl.lose_health();
            lcd.printString("DONE",0,1);
            lcd.refresh();
            wait(0.5);
        }
        else {wait_ms(50);}
    }
*/