diff --git a/battleship.c b/battleship.c index bdae8bd..bceb7e4 100644 --- a/battleship.c +++ b/battleship.c @@ -523,7 +523,10 @@ void gameplay(bool side){//side is only there to feed header() getch(); erase(); } -int main(void){ +int main(int argc,char** argv){ + if(argc>1){ + printf("This game doesn't take arguments"); + } initscr(); #ifndef NO_MOUSE mousemask(ALL_MOUSE_EVENTS,NULL); diff --git a/circlejump.c b/circlejump.c new file mode 100755 index 0000000..2ca158f --- /dev/null +++ b/circlejump.c @@ -0,0 +1,320 @@ +/* + _ +| '. +| : +|.' ARRT + +Authored by abakh +To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty. + +You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see . +*/ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include "config.h" +#include "common.h" +#define SAVE_TO_NUM 11 +#define LEN 24 +#define HLEN LEN/2 +#define WID 80 +#define HWID WID/2 +#define SHOTS_WHEN_STARTING 10 + +#define randint(a,b) ((a)+(rand()%((b+1)-(a)))) +#ifdef Plan9 +int usleep(long usec) { + int second = usec/1000000; + long nano = usec*1000 - second*1000000; + struct timespec sleepy = {0}; + sleepy.tv_sec = second; + sleepy.tv_nsec = nano; + nanosleep(&sleepy, (struct timespec *) NULL); + return 0; +} +#endif +// 12 lines of water +// 80 columns + +chtype colors[3]={0}; +long score=0; +FILE* scorefile; + +chtype background[LEN][WID]; + +int input; +char msg[150]={0}; +byte msg_show=0; + +bool timed[3]; +byte circlex[3]; +byte circley[3]; +byte loops_left=0; +float shooting_angle=0; +float rotation_angle=0; + +byte digit_count(int num){ + byte ret=0; + do{ + ++ret; + num/=10; + }while(num); + return ret; +} +void filled_rect(byte sy,byte sx,byte ey,byte ex){ + byte y,x; + for(y=sy;y0){ + byte a = (LEN-9)/2; + star_line(1); + star_line(LEN-2); + mvaddstr(1,WID/2-8,"CONGRATULATIONS!!"); + mvprintw(a+1,HWID-10," _____ You bet the"); + mvprintw(a+2,HWID-10," .' | previous"); + mvprintw(a+3,HWID-10," .' | record"); + mvprintw(a+4,HWID-10," | .| | of"); + mvprintw(a+5,HWID-10," |.' | |%11ld",formerscore); + mvprintw(a+6,HWID-10," | | held by"); + mvprintw(a+7,HWID-10," ___| |___%7s!",formername); + mvprintw(a+8,HWID-10," | |"); + mvprintw(a+9,HWID-10," |____________|"); + mvprintw(LEN-3,HWID-11,"Press a key to continue"); + refresh(); + do{ + input=getch(); + }while(input==KEY_UP || input==KEY_DOWN); + filled_rect(0,0,LEN,WID); + red_border(); + } + + } + //scorefile is still open with w+ + char pname[60] = {0}; + long pscore=0; + byte rank=0; + rewind(score_file); + mvaddstr(1,WID/2-4,"HIGH SCORES"); + attron(colors[3]); + while( rank>>"); + printw("%s",pname); + mvprintw(2+2*rank,WID-1-digit_count(pscore),"%d",pscore); + ++rank; + } + refresh(); +} +void help(void){ + nocbreak(); + cbreak(); + attron(colors[3]); + filled_rect(0,0,LEN,WID); + red_border(); + mvprintw(1,HWID-4,"GAME PLAY"); + mvprintw(3,1,"If you hit a letter on keyboard, the letter on the"); + mvprintw(4,1,"screen will soon stop. You have to aim for the"); + mvprintw(5,1,"center of the target using the moving letters."); + attroff(colors[3]); + refresh(); + getch(); + halfdelay(1); +} +void sigint_handler(int x){ + endwin(); + puts("Quit."); + exit(x); +} +int main(void){ + signal(SIGINT,sigint_handler); + initscr(); + noecho(); + cbreak(); + keypad(stdscr,1); + srand(time(NULL)%UINT_MAX); + if(has_colors()){ + start_color(); + init_pair(1,COLOR_RED,COLOR_BLACK); + init_pair(2,COLOR_YELLOW,COLOR_BLACK); + init_pair(3,COLOR_GREEN,COLOR_BLACK); + for(byte b=0;b<3;++b) + colors[b]=COLOR_PAIR(b+1); + } + + make_background(); + Start: + erase(); + halfdelay(1); + curs_set(0); + score=0; + msg_show=0; + aims_to_stop=shots=SHOTS_WHEN_STARTING; + fill_aims(); + while(1){ + draw(); + refresh(); + input=getch(); + + if(input=='?' || input==KEY_F(1)) + help(); + if(input=='Q'){ + strcpy(msg,"Ctrl-C to quit."); + msg_show=50; + } + if(input!=ERR){ + usleep(100000); + flushinp(); + } + if(!aims_to_stop){ + break; + } + for(int i=0;i<26;++i){ + move_aim(aims+i); + } + } + flushinp(); + nocbreak(); + cbreak(); + curs_set(1); + end_scene(); + show_scores(save_score()); + attron(colors[0]|A_STANDOUT); + mvprintw(LEN-1,HWID-11,"Wanna play again? (y/n)"); + attroff(colors[0]|A_STANDOUT); + do{ + input=getch(); + }while(input==KEY_UP || input==KEY_DOWN); + if(input!='q' && input!='n' && input!='N') + goto Start; + endwin(); + return 0; +} diff --git a/darrt.c b/darrt.c index ae32cda..66e3a7b 100644 --- a/darrt.c +++ b/darrt.c @@ -370,7 +370,10 @@ void sigint_handler(int x){ puts("Quit."); exit(x); } -int main(void){ +int main(int argc,char** argv){ + if(argc>1){ + printf("This game doesn't take arguments"); + } signal(SIGINT,sigint_handler); initscr(); noecho(); diff --git a/fisher.c b/fisher.c index d400665..106008e 100644 --- a/fisher.c +++ b/fisher.c @@ -272,7 +272,10 @@ void sigint_handler(int x){ puts("Quit."); exit(x); } -int main(void){ +int main(int argc,char** argv){ + if(argc>1){ + printf("This game doesn't take arguments"); + } signal(SIGINT,sigint_handler); initscr(); noecho(); diff --git a/jewels.c b/jewels.c index 73af389..29303a2 100644 --- a/jewels.c +++ b/jewels.c @@ -244,7 +244,10 @@ void draw(void){ mvaddstr(LINES-2,middle-5,controls); refresh(); } -int main(void){ +int main(int argc,char** argv){ + if(argc>1){ + printf("This game doesn't take arguments"); + } initscr(); cbreak(); halfdelay(DELAY); diff --git a/memoblocks.c b/memoblocks.c index dfb944c..00bb5d9 100644 --- a/memoblocks.c +++ b/memoblocks.c @@ -168,7 +168,10 @@ void gameplay(void){ getch(); erase(); } -int main(void){ +int main(int argc,char** argv){ + if(argc>1){ + printf("This game doesn't take arguments"); + } signal(SIGINT,sigint_handler); srand(time(NULL)%UINT_MAX); initscr(); diff --git a/miketron.c b/miketron.c index 9da00fd..a146dcb 100644 --- a/miketron.c +++ b/miketron.c @@ -309,7 +309,10 @@ void sigint_handler(int x){ puts("Quit."); exit(x); } -int main(void){ +int main(int argc,char** argv){ + if(argc>1){ + printf("This game doesn't take arguments"); + } #ifndef NO_VLA signal(SIGINT,sigint_handler); #endif diff --git a/rabbithole.c b/rabbithole.c index 17ccb37..a1c2d9d 100644 --- a/rabbithole.c +++ b/rabbithole.c @@ -178,7 +178,10 @@ void sigint_handler(int x){ puts("Quit."); exit(x); } -int main(void){ +int main(int argc,char** argv){ + if(argc>1){ + printf("This game doesn't take arguments"); + } signal(SIGINT,sigint_handler); initscr(); #ifndef NO_VLA diff --git a/redsquare.c b/redsquare.c index 62b1a04..6b5233e 100644 --- a/redsquare.c +++ b/redsquare.c @@ -450,7 +450,10 @@ void gameplay(void){ halfdelay(1); erase(); } -int main(void){ +int main(int argc,char** argv){ + if(argc>1){ + printf("This game doesn't take arguments"); + } signal(SIGINT,sigint_handler); srand(time(NULL)%UINT_MAX); initscr();