summaryrefslogtreecommitdiff
path: root/door
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2015-01-10 15:11:12 +0900
committerFreeArtMan <dos21h@gmail.com>2015-01-10 15:11:12 +0900
commit0de51355ec0acb63fb05cefc3ad147f4e47166ca (patch)
treea9b53e0dadfa4ff0dd409e77a78f43a4624265ad /door
parentbd040d066dc5ba642c4fadca26ddd4e1963e5231 (diff)
downloadmicrobbs-0de51355ec0acb63fb05cefc3ad147f4e47166ca.tar.gz
microbbs-0de51355ec0acb63fb05cefc3ad147f4e47166ca.zip
epoch game music, guess and type note
Diffstat (limited to 'door')
-rw-r--r--door/music.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/door/music.c b/door/music.c
new file mode 100644
index 0000000..3b52b4e
--- /dev/null
+++ b/door/music.c
@@ -0,0 +1,59 @@
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <stdlib.h>
+
+char cheat;
+
+void print_note(char n) {
+ printf(" %c \n",n=='G'?cheat?n:'o':' ');
+ printf("--%c--\n",n=='F'?cheat?n:'o':'-');
+ printf(" %c \n",n=='E'?cheat?n:'o':' ');
+ printf("--%c--\n",n=='D'?cheat?n:'o':'-');
+ printf(" %c \n",n=='C'?cheat?n:'o':' ');
+ printf("--%c--\n",n=='B'?cheat?n:'o':'-');
+ printf(" %c \n",n=='A'?cheat?n:'o':' ');
+ printf("--%c--\n",n=='g'?cheat?n:'o':'-');
+ printf(" %c \n",n=='f'?cheat?n:'o':' ');
+ printf("--%c--\n",n=='e'?cheat?n:'o':'-');
+ printf(" %c \n",n=='d'?cheat?n:'o':' ');
+ printf(" %c \n",n=='c'?cheat?n:'o':' ');
+ printf(" %c \n",n=='b'?cheat?n:'o':' ');
+ printf(" %c \n",n=='a'?cheat?n:'o':' ');
+}
+
+char notes[]="ABCDEFGabcdefg";
+
+int main(int argc,char *argv[]) {
+ int count;
+ int correct=0;
+ int total=20;
+ char note;
+ cheat=argc > 1;
+ short in;
+ srandom(time(0));
+ total=20;
+ count=total;
+ printf("\x1b[H\x1b[J");
+ time_t end;
+ time_t start=time(0);
+ for(;in != -1 && count;count--) {
+ note=notes[random()%strlen(notes)];
+ print_note(note);
+ in=fgetc(stdin);
+ if(in == note || in == note+' ') {
+ printf("\x1b[H\x1b[J");
+ printf("Yay!\n");
+ correct++;
+ in=fgetc(stdin);//kill the newline
+ } else {
+ printf("\x1b[H\x1b[J");
+ printf("boo!\n");
+ in=fgetc(stdin);//kill the newline
+ }
+ }
+ end=time(0);
+ printf("took you %lld seconds\n",end-start);
+ printf("got %d/%d right.\n",correct,total);
+ return 0;
+}