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: C12832 MMA7660 mbed
Fork of shot_game by
Revision 3:f8b5d05b3e92, committed 2015-04-16
- Comitter:
- green_hatano
- Date:
- Thu Apr 16 08:56:01 2015 +0000
- Parent:
- 1:880253791d78
- Commit message:
Changed in this revision
| MMA7660.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MMA7660.lib Thu Apr 16 08:56:01 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/green_hatano/code/MMA7660/#084e1f9ab548
--- a/main.cpp Thu Apr 16 06:19:56 2015 +0000
+++ b/main.cpp Thu Apr 16 08:56:01 2015 +0000
@@ -19,6 +19,12 @@
AnalogIn pot2(p20);
Ticker timeInt;
+
+DigitalOut led(LED1);
+DigitalOut led2(LED2);
+
+LocalFileSystem local("local");
+
/*ゲームステータス*/
int racketP1,shot,enemyX=127,enemyY,enemyX2,life=3,lifeLED=3,lvl=2,score=0;
unsigned int randoms=0;
@@ -31,24 +37,37 @@
}
void end(){
+ FILE *fp;
+ int i;
timeInt.detach();
r = g = b = 1;
lcd.cls();
lcd.locate(0, 0);
lcd.printf("SCORE:%d ", score);
- fp = fopen("local/test.txt","r");
- fscanf(fp,"%d",i);
- fclose(fp);
+ fp = fopen("/local/test.txt","r");
+ led = 1;
+ if(!fp){
+ printf("error");
+ exit(1);
+ }
+ else{
+ fscanf(fp,"%d",&i);
+ fclose(fp);
+ }
+ led2 = 1;
+
if(score > i){
- fp = fopen("local/test.txt","w");
+ fp = fopen("/local/test.txt","w");
fprintf(fp,"%d",score);
fclose(fp);
- lcd.printf("NEW RECORD!!\n");
- lcd.printf("HIGH SCORE:%d",score);
+ lcd.locate(0, 10);
+ lcd.printf("NEW RECORD!!\nHIGH SCORE:%d",score);
}
else{
+ lcd.locate(0, 10);
lcd.printf("HIGH SCORE:%d",i);
}
+
wait(2);
speaker = 0;
while(1);
