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 N5110 ShiftReg PinDetect
Global.cpp
00001 #include "Global.h" 00002 00003 /// @file Global.cpp 00004 00005 namespace Global 00006 { 00007 int score = 0; 00008 00009 Highscore highscores[3] = {{"AAA", 0}, {"AAA", 0}, {"AAA", 0}}; 00010 00011 void clearHighscoreList() 00012 { 00013 // Clear high score list 00014 for (int i = 0; i < 3; ++i) 00015 { 00016 highscores[i].initials = "---"; 00017 highscores[i].score = 0; 00018 } 00019 00020 // Overwrite file 00021 FILE *fp = fopen("/local/highscores.txt", "w"); 00022 00023 for (int i = 0; i < 3; ++i) 00024 fprintf(fp, "%s %d ", Global::highscores[i].initials, Global::highscores[i].score); 00025 00026 fclose(fp); 00027 } 00028 } 00029 00030 /// Setup the enemy based on type 00031 void Enemy::setup() 00032 { 00033 switch (type) 00034 { 00035 case SIMPLE: 00036 width = 5; 00037 height = 5; 00038 vx = 1; 00039 difficulty = 1; 00040 jumpRate = 3; 00041 break; 00042 00043 case JUMPER: 00044 width = 3; 00045 height = 4; 00046 vx = 1; 00047 difficulty = 3; 00048 jumpRate = 50; 00049 break; 00050 00051 case RUNNER: 00052 width = 6; 00053 height = 5; 00054 vx = 2; 00055 difficulty = 5; 00056 jumpRate = 0; 00057 break; 00058 00059 default: // error, should not be possible 00060 width = height = vx = vy = 0; 00061 } 00062 00063 if (facingLeft) 00064 vx *= -1; 00065 }
Generated on Tue Jul 12 2022 21:30:55 by
