//this version fixed deleting problem /* *Notes might be a bit scattered or maybe wrong to some extent* how to play: #start game in full terminal. it will look funny is u dont #use arrow keys to move #press 'o' to place barrier #to delete barrier piece stand by it ans press w,a,s,d. ex: stand under the barrer u wanna delete and press w #if you get stuck in a barrier and cant move (this is a bug) press 'r' to go to (0,0) #press 'q' to end the game #to save the game u are on, while in the terminal copy all the blue area. now go make a copy of this file here. see that big open space printw? well u need to replace all the stuff it is printing with the screen u copied. then put \n after every 'o' and it should work */ #include //header for all this ncurses stuff #include //used for sleep command int main()//used in every program { //start of gui initscr();//makes the screen start_color();//says we can have color noecho();//keeps from pressing other characters nodelay(stdscr, TRUE);//keeps it from delaying :P keypad(stdscr, TRUE);//lets me use arrow keys init_pair(1, COLOR_RED, COLOR_CYAN);//1 is the name of the pair, white is the text, cyan is the background.kind of like setting a varriable attron(COLOR_PAIR(1));//initiating color pair 1 printw(" o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\n o\nooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\n");//makes it show color background move(0,0);//sets cursor position to here so the next printw will print at this position (not really needed anymore but here) //end of gui //start of arrow keys input (moving person) for( ; ; ) {//loop char wall = inch();//defines wall as something on screen int y, x;//some varriables int ch = getch();//sets varriable ch(input) as getch to be used specially switch (ch) {//changes that getch varriable to the special keys below case KEY_DOWN://special key getyx(stdscr , y, x);//recieves the current curser position move(y+1,x);//moves cursor accordingly based on current position refresh();//refreshes the screen to show that the cursor moved getch();//recieves input or something. needed but not sure exactly what it does } switch (ch) { //the other arrows... case KEY_UP: getyx(stdscr , y, x); move(y-1,x); refresh(); getch(); } switch (ch) { case KEY_LEFT: getyx(stdscr , y, x); move(y,x-1); refresh(); getch(); } switch (ch) { case KEY_RIGHT: getyx(stdscr , y, x); move(y , x+1 ); refresh(); getch(); } //end of arrow keys input (moving person) if(ch=='z') { //THE STUFF I NEED HELP WITH WILL MOST LIKELY GO HERE } //barrier if(ch=='o') {//checks to see if u press o printw("o");//makes a barrier refresh();//shows changes } //deleting barriers (buggy. may not be compatabe with how the barrier are not able to go thru) if(ch=='w') {//checks to see if u press d wall=='b';//sets the barrier to b instead of o for a sec because o is the barrier o it changes b to the barrier getyx(stdscr,y,x); move(y-1,x);// mover cursor up onto the barrier to replace it with space then back one cuz the spaces pushes it forward printw(" ");//prints the space getyx(stdscr,y,x); move(y+1,x-1); refresh();//refreshes the screen to show the changes } if(ch=='a') {//checks to see if u press d wall=='b';//sets the barrier to b instead of o for a sec because o is the barrier o it changes b to the barrier getyx(stdscr,y,x); move(y,x-1);// mover cursor up onto the barrier to replace it with space then back one cuz the spaces pushes it forward printw(" ");//prints the space getyx(stdscr,y,x); move(y,x); refresh();//refreshes the screen to show the changes } if(ch=='s') {//checks to see if u press d wall=='b';//sets the barrier to b instead of o for a sec because o is the barrier o it changes b to the barrier getyx(stdscr,y,x); move(y+1,x);// mover cursor up onto the barrier to replace it with space then back one cuz the spaces pushes it forward printw(" ");//prints the space getyx(stdscr,y,x); move(y-1,x-1); refresh();//refreshes the screen to show the changes } if(ch=='d') {//checks to see if u press d wall=='b';//sets the barrier to b instead of o for a sec because o is the barrier o it changes b to the barrier getyx(stdscr,y,x); move(y,x+1);// mover cursor up onto the barrier to replace it with space then back one cuz the spaces pushes it forward printw(" ");//prints the space getyx(stdscr,y,x); move(y,x-2); refresh();//refreshes the screen to show the changes } //quitting the game if(ch=='q') {//checks to see if u press q endwin();//ends the window. screws up the termnal if u retrn 0 without this return 0;//ends program } //classification of barrier if (wall=='o') {//asking is wall = 'o' (wall is defines as inch earlier in program so it is inside terminal not user input) move(y,x);//moves cursor to its last known coordinates (notice i didnt getxy. this would make it move to the spot on the barrier) refresh();//shows changes getch();//tell that the input has been done (i think) } //in case of glitch this resets the cursor to (0,0) if (ch=='r') {//checks to see if u pressed r move(0,0);//moves u to (0,0) refresh();//shows changes } } }