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
Revision 22:cded0cd8e1c9, committed 2020-05-22
- Comitter:
- el19zf
- Date:
- Fri May 22 16:07:02 2020 +0000
- Parent:
- 21:e3866e4fe5fb
- Commit message:
- Final Submission. I have read and agreed with Statement of Academic Integrity.
Changed in this revision
--- a/Collision/Collision.cpp Fri May 22 04:49:26 2020 +0000
+++ b/Collision/Collision.cpp Fri May 22 16:07:02 2020 +0000
@@ -63,7 +63,8 @@
_check_des_index = 0;
if(lcd.getPixel(82,24)||lcd.getPixel(82,25)||lcd.getPixel(82,26)||
lcd.getPixel(82,27)||lcd.getPixel(82,23)||lcd.getPixel(82,22)||
- lcd.getPixel(82,21)||lcd.getPixel(82,20)||lcd.getPixel(82,28))
+ lcd.getPixel(82,21)||lcd.getPixel(82,20)||lcd.getPixel(82,28)||
+ lcd.getPixel(81,24)||lcd.getPixel(81,25)||lcd.getPixel(81,23))
{
_check_des_index = 1;
//printf("reach des\n");
@@ -92,7 +93,6 @@
{
lcd.clear();
draw_basic(lcd);
- lcd.drawRect(10,10,(get_health()+1)*2,3,FILL_BLACK);
for(int i =0; i <get_health()+1;i++)
lcd.drawSprite(18*i+20,24,7,9,(int*)heart_sprite);
lcd.refresh();
@@ -100,7 +100,6 @@
lcd.clear();
draw_basic(lcd);
- lcd.drawRect(10,10,get_health()*2,3,FILL_BLACK);
for(int i =0; i <get_health();i++)
lcd.drawSprite(18*i+20,24,7,9,(int*)heart_sprite);
lcd.refresh();
--- a/Interface/Interface.cpp Fri May 22 04:49:26 2020 +0000
+++ b/Interface/Interface.cpp Fri May 22 16:07:02 2020 +0000
@@ -38,6 +38,9 @@
void Interface::Welcome(N5110 &lcd,Gamepad &pad)
{
+ // initialise record
+ _record.x = 0;
+ _record.y = 0;
// start game after pressing the start botton
while (!pad.start_pressed())
{
@@ -67,7 +70,7 @@
lcd.printString(" Start(Hell)",0,2);
lcd.printString(" user-defined",0,3);
lcd.printString(" Instruction",0,4);
- lcd.printString(" Exit",0,5);
+ lcd.printString(" Record",0,5);
_d = pad.get_direction();
// in order to easily control Joystick, pointer move upward in a large angle
if(_d == N||_d ==NE||_d==NW){
@@ -186,15 +189,28 @@
_count_down--;
}
-void Interface::exit(N5110 &lcd,Gamepad &pad)
+void Interface::update_record(float increment,int max)
+{
+ if(increment > _record.x||(int(increment)==int(_record.x)&& max > _record.y)){
+ _record.x = increment;
+ _record.y = max;
+ }
+}
+
+void Interface::record(N5110 &lcd,Gamepad &pad)
{
lcd.clear();
pad.init();
pad.tone(10,0.05);
pad.set_bpm(0);
+ sprintf(_buffer1," %.1f shots/s",_record.x*6);
+ sprintf(_buffer2," with Max.%.0f ",_record.y);
while(!pad.B_pressed()){
- lcd.printString(" Press B back ",0,2);
- lcd.printString(" to menu ",0,3);
+ lcd.printString("Record",23,0);
+ lcd.printString(_buffer1,0,1);
+ lcd.printString(_buffer2,0,2);
+ lcd.printString(" Press B back ",0,4);
+ lcd.printString(" to menu ",0,5);
lcd.refresh();
wait(0.1);
}
--- a/Interface/Interface.h Fri May 22 04:49:26 2020 +0000
+++ b/Interface/Interface.h Fri May 22 16:07:02 2020 +0000
@@ -51,8 +51,11 @@
/** count down and draw in lcd*/
void count_down(N5110 &lcd);
- /** Exit interface*/
- void exit(N5110 &lcd,Gamepad &pad);
+ /** update record*/
+ void update_record(float increment,int max);
+
+ /** Record interface*/
+ void record(N5110 &lcd,Gamepad &pad);
/** Victory interface*/
void victory(N5110 &lcd,Gamepad &pad);
@@ -92,7 +95,8 @@
int _count_down;
int _victory_flag;
char _buffer1[14];
- char _buffer2[14];
+ char _buffer2[14];
+ Vector2D _record;
};
#endif
\ No newline at end of file
--- a/main.cpp Fri May 22 04:49:26 2020 +0000
+++ b/main.cpp Fri May 22 16:07:02 2020 +0000
@@ -82,7 +82,7 @@
instruction.draw(lcd,pad);
break;
case 4:
- interface.exit(lcd,pad);
+ interface.record(lcd,pad);
break;
}
#ifdef DEBUG
@@ -176,6 +176,7 @@
//check destination
if(collision.check_des(lcd)){
interface.victory(lcd,pad);
+ interface.update_record(increment,max);
lcd.clear();
}
}
@@ -220,6 +221,6 @@
// 0 1 2 3 4 flag
// 0.3 0.4 0.5 0.6 0.7 shots/frame
// 15 20 25 30 35 Maximum shots
- main_game(0.1*(interface.get_rate_flag() + 3),5*(interface.get_rate_flag()+ 3));
+ main_game(0.1*(interface.get_rate_flag() + 3),5*(interface.get_max_flag()+ 3));
}
\ No newline at end of file