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:
- 5:8a2e96f7fb4d
- Parent:
- 4:3b3a7f102250
- Child:
- 6:5d57c758c31d
--- a/main.cpp Tue Apr 02 19:00:18 2019 +0000
+++ b/main.cpp Wed Apr 03 12:38:12 2019 +0000
@@ -50,22 +50,37 @@
lcd.init();
// welcome(); // display welcome message
- // while(1) { // infinite loop
+ while(1) { // infinite loop
srand(time(NULL));
char buffer[14];
int t_pos_x = rand() % 77;
int t_pos_y = rand() % 37;
+
+//Takes the tanks x and y position (of its bottom left pixel of sprite) and
+//determines the area it cover in terms of grid values.
int i = 0;
-
- for (int i0 = 0; i0 < 6; i0++) {
+ for (int i0 = 0; i0 < 4; i0++) {
for (int i1 = 1; i1 < 11; i1++) {
tank_hb[i] = (i0 + t_pos_y) * 84 + t_pos_x + i1;
- i++;
+ i++;
}
}
-
+
+ lcd.clear();
+ sprintf(buffer," %d ",tank_hb[0] );
+ lcd.printString(buffer,0,1);
+ lcd.refresh();
+ wait(1.5);
+ lcd.clear();
+ sprintf(buffer," %d ",tank_hb[39] );
+ lcd.printString(buffer,0,1);
+ lcd.refresh();
+ wait(1.5);
+ lcd.clear();
+
+ /*
int p_pos_x = rand() % 84;
int p_pos_y = rand() % 48;
int proj_hb = p_pos_y * 84 + p_pos_x + 1;
@@ -74,8 +89,8 @@
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();
+ lcd.printString(buffer,0,1);
+ lcd.refresh();*/
wait(1);
// }
}