From 0de51355ec0acb63fb05cefc3ad147f4e47166ca Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Sat, 10 Jan 2015 15:11:12 +0900 Subject: epoch game music, guess and type note --- door/music.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 door/music.c (limited to 'door') 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 +#include +#include +#include + +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; +} -- cgit v1.2.3