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-02
- Revision:
- 4:3b3a7f102250
- Parent:
- 3:087b28bf8b96
- Child:
- 5:8a2e96f7fb4d
File content as of revision 4:3b3a7f102250:
/*
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"
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
const int tank_left[6][10] = {
{ 0,0,0,1,1,1,0,0,0,0 },
{ 0,0,1,1,1,1,1,0,0,0 },
{ 0,0,1,1,1,1,1,1,1,0 },
{ 1,1,1,1,1,1,1,1,1,1 },
{ 1,0,1,0,1,0,1,0,1,0 },
{ 0,1,0,1,0,1,0,1,0,0 },
};
const int proj[5][5] = {
{ 0,0,1,0,0 },
{ 0,0,1,0,0 },
{ 1,1,1,1,1 },
{ 0,0,1,0,0 },
{ 0,0,1,0,0 },
};
// Spawning tank and projectile at random position
// with visual feedback to build grid and hitbox system
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()
{
int tank_hb[40];
lcd.init();
// welcome(); // display welcome message
// while(1) { // infinite loop
srand(time(NULL));
char buffer[14];
int t_pos_x = rand() % 77;
int t_pos_y = rand() % 37;
int i = 0;
for (int i0 = 0; i0 < 6; i0++) {
for (int i1 = 1; i1 < 11; i1++) {
tank_hb[i] = (i0 + t_pos_y) * 84 + t_pos_x + i1;
i++;
}
}
int p_pos_x = rand() % 84;
int p_pos_y = rand() % 48;
int proj_hb = p_pos_y * 84 + p_pos_x + 1;
//sprintf(buffer,"t_pos_x = %d ",t_pos_x);
lcd.clear();
lcd.drawSprite(t_pos_x,42 - t_pos_y,6,10,(int *)tank_left);
lcd.drawSprite(p_pos_x - 2 ,44 - p_pos_y,5,5,(int *)proj);
//lcd.printString(buffer,0,1);
lcd.refresh();
wait(1);
// }
}