john@sysint.UUCP (John Abbott) (11/09/88)
The following enhancement provides support for Curses(3)-style cursor key input for movement of your spider! I find this much easier that h-j-k-l. After all, that's what cursor keys are for. Apply these patches using Larry Wall's patch program. Note that you should have applied my 'movement counter' patches already, or you will have to do some hand-editing. *** /tmp/,RCSt1a21825 Tue Nov 8 12:26:33 1988 --- m.c Tue Nov 8 12:25:59 1988 *************** *** 112,117 } initscr(); /* MAIN PROGRAM HERE */ --- 112,118 ----- } initscr(); + keypad(stdscr, TRUE); /* MAIN PROGRAM HERE */ *** /tmp/,RCSt1a21825 Tue Nov 8 12:26:34 1988 --- game.c Fri Nov 4 16:27:48 1988 *************** *** 131,136 { int x,y,nx,ny,deadyet =0, sx = -1,sy = -1,tx = -1,ty = -1,lx = 0,ly = 0,mx = -1,my = -1, bx, by, nbx, nby, newnum, moved, max_score = 250, --- 131,137 ----- { int x,y,nx,ny,deadyet =0, sx = -1,sy = -1,tx = -1,ty = -1,lx = 0,ly = 0,mx = -1,my = -1, + ch, bx, by, nbx, nby, newnum, moved, max_score = 250, *************** *** 136,142 max_score = 250, diamonds = 0, nf = 0,hd ,vd ,xdirection,ydirection; char (*frow)[ROWLEN+1] = screen, - ch, buffer[25]; static char howdead[25]; /* M001 can't use auto var for return value */ direction new_disp; --- 137,142 ----- max_score = 250, diamonds = 0, nf = 0,hd ,vd ,xdirection,ydirection; char (*frow)[ROWLEN+1] = screen, buffer[25]; static char howdead[25]; /* M001 can't use auto var for return value */ direction new_disp; *************** *** 249,255 nx=x; ny=y; ! if(ch == keys[3]) /* move about - but thats obvious */ nx++; if(ch == keys[2]) nx--; --- 249,255 ----- nx=x; ny=y; ! if(ch == keys[3] || ch == KEY_RIGHT) /* move about - but thats obvious */ nx++; if(ch == keys[2] || ch == KEY_LEFT || ch == KEY_BACKSPACE) nx--; *************** *** 251,257 if(ch == keys[3]) /* move about - but thats obvious */ nx++; ! if(ch == keys[2]) nx--; if((ch == keys[1]) && (y<(NOOFROWS-1))) ny++; --- 251,257 ----- if(ch == keys[3] || ch == KEY_RIGHT) /* move about - but thats obvious */ nx++; ! if(ch == keys[2] || ch == KEY_LEFT || ch == KEY_BACKSPACE) nx--; if((ch == keys[1] || ch == KEY_DOWN) && (y<(NOOFROWS-1))) ny++; *************** *** 253,259 nx++; if(ch == keys[2]) nx--; ! if((ch == keys[1]) && (y<(NOOFROWS-1))) ny++; if(ch == keys[0]) ny--; --- 253,259 ----- nx++; if(ch == keys[2] || ch == KEY_LEFT || ch == KEY_BACKSPACE) nx--; ! if((ch == keys[1] || ch == KEY_DOWN) && (y<(NOOFROWS-1))) ny++; if(ch == keys[0] || ch == KEY_UP) ny--; *************** *** 255,261 nx--; if((ch == keys[1]) && (y<(NOOFROWS-1))) ny++; ! if(ch == keys[0]) ny--; moved = (nx != x) || (ny != y); /* remember if we have moved */ if(ch == '1') /* Add or get rid of that awful sound */ --- 255,261 ----- nx--; if((ch == keys[1] || ch == KEY_DOWN) && (y<(NOOFROWS-1))) ny++; ! if(ch == keys[0] || ch == KEY_UP) ny--; moved = (nx != x) || (ny != y); /* remember if we have moved */ if(ch == '1') /* Add or get rid of that awful sound */ -- /\ John Abbott Systems Interface Inc. / \ VOICE: (613) 230-4103 560 Rochester St, 2nd Floor /----\ FAX: (613) 230-6928 Ottawa, Ontario, CANADA K1S 5K2 \__/ \ UUCP: uunet!mnetor!dciem!nrcaer!cognos!sysint!john