/* . . _ |\/| |_) | |EMORY|_)LOCKS 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 "common.h" typedef unsigned char ubyte; #define size 8 #define size2 16 byte py,px; byte fy,fx; //the first tile chtype colors[6]={0}; void rectangle(byte sy,byte sx){ for(byte y=0;y<=size+1;++y){ mvaddch(sy+y,sx,ACS_VLINE); mvaddch(sy+y,sx+size2+1,ACS_VLINE); } for(byte x=0;x<=size2+1;++x){ mvaddch(sy,sx+x,ACS_HLINE); mvaddch(sy+size+1,sx+x,ACS_HLINE); } mvaddch(sy,sx,ACS_ULCORNER); mvaddch(sy+size+1,sx,ACS_LLCORNER); mvaddch(sy,sx+size2+1,ACS_URCORNER); mvaddch(sy+size+1,sx+size2+1,ACS_LRCORNER); } void logo(byte sy,byte sx){ mvaddstr(sy,sx, ". . _"); mvaddstr(sy+1,sx,"|\\/| |_)"); mvaddstr(sy+2,sx,"| |EMORY|_)LOCKS"); } //convert integer to representing sign char int2sgn(byte num){ if(0< num && num <= 9) return num+'0'; else if(10<=num && num <=35) return num-10+'a'; else if(36<=num && num <=51) return num-36+'A'; else if(52<=num && num<=64) return num-52+'!'; return 0; } //display void draw(byte sy,byte sx,chtype board[size][size2],bool show[size][size2]){ rectangle(sy,sx); byte y,x; chtype prnt; for(y=0;y1){ printf("This game doesn't take arguments"); } signal(SIGINT,sigint_handler); srand(time(NULL)%UINT_MAX); initscr(); #ifndef NO_MOUSE mousemask(ALL_MOUSE_EVENTS,NULL); #endif noecho(); cbreak(); keypad(stdscr,1); if(has_colors()){ start_color(); use_default_colors(); if( has_colors() ){ start_color(); use_default_colors(); init_pair(1,COLOR_YELLOW,-1); init_pair(2,COLOR_GREEN,-1); init_pair(3,COLOR_BLUE,-1); init_pair(4,COLOR_CYAN,-1); init_pair(5,COLOR_MAGENTA,-1); init_pair(6,COLOR_RED,-1); for(byte b=0;b<6;++b){ colors[b]=COLOR_PAIR(b+1); } } } chtype board[size][size2]; bool show[size][size2]; int input; time_t tstart,now; Start: tstart=time(NULL); py=px=0; fy=fx=-1; curs_set(0); memset(show,0,size*size2); fill(board); shuffle(board); while(1){ erase(); logo(0,0); draw(3,0,board,show); refresh(); if(issolved(show)) break; input = getch(); if( input==KEY_F(1) || input=='?' ) help(); if( (input==KEY_F(2)||input=='!') ) gameplay(); if( input==KEY_MOUSE ) mouseinput(); if( (input=='k' || (input==KEY_UP||input=='w')) && py>0) --py; if( (input=='j' || (input==KEY_DOWN||input=='s')) && py0) --px; if( (input=='l' || (input==KEY_RIGHT||input=='d')) && px