Simple Games using ncurses
Menu
//"Ghost //W.Perez //[email protected] #include <string> #include <ncurses.h> #include <stdlib.h> #include <time.h> #include <iostream> using namespace std; int main() { home: bool quit = false; int life=75; int points=0; int x=12; int y=5; int food_x=15+rand()%8; int food_y=3+rand()%5; int ghost_x=10; int ghost_y=2+rand()%5; int ghost_direct=0; int player_direct=0; int clock=0; int clock_1=0; int clock_2=0; int clock_3=0; int ch; srand(time(NULL)); initscr(); noecho(); curs_set(0); keypad(stdscr, TRUE); timeout(175); //initiate color function start_color(); bkgd(COLOR_PAIR(1)); init_pair(1,COLOR_WHITE, COLOR_BLACK); init_pair(2, COLOR_RED, COLOR_BLACK); init_pair(3, COLOR_WHITE, COLOR_BLUE); init_pair(4, COLOR_GREEN, COLOR_BLACK); init_pair(5, COLOR_CYAN, COLOR_BLACK); while (!quit) { ch = getch(); switch (ch) { case 'q': player_direct = 1; break; case 'w': player_direct = 1; break; case 'a': player_direct = 1; break; case 's': player_direct = 1; break; case 'z': player_direct = 1; break; case 'x': player_direct = 1; break; case 'o': player_direct = 2; break; case 'k': player_direct = 2; break; case 'l': player_direct = 2; break; case 'n': player_direct = 2; break; case 'm': player_direct = 2; break; case 'r': player_direct = 3; break; case 't': player_direct = 3; break; case 'y': player_direct = 3; break; case 'u': player_direct = 3; break; case 'c': player_direct = 4; break; case 'v': player_direct = 4; break; case 'b': player_direct = 4; break; case ' ': player_direct = 4; break; //Pause game case '0': timeout(555555); break; //unpause (resume game) case 'p': timeout(200); break;} attron(A_BOLD); clock++; clock_1++; clock_2++; clock_3++; erase(); bool collision=false; bool collision_2=false; bool chased=false; bool star=false; if (clock_3>=10+rand()%5 && clock_3 <=20+rand()%10) star=1; if (clock_3>=21) clock_3=0-rand()%5; if (x==food_x && y==food_y) collision_2=true; if (x==ghost_x && y==ghost_y || y==1 || y==9 && star== false ){ collision=true; life--; } if (clock_1>=10 ) { chased=true; } if (clock_1>=21){ clock_1=rand()%5; chased=false; ghost_direct=0;} attrset(COLOR_PAIR(1)); if (collision) { mvprintw(0,12,":-("); mvprintw(y-1,x,"x"); mvprintw(y+1,x,"x"); mvprintw(y,x-1,"x"); mvprintw(y,x+1,"x");} if (collision_2) { mvprintw(0,12,":-)"); mvprintw(y-1,x,"o"); mvprintw(y+1,x,"o"); mvprintw(y,x-1,"o"); mvprintw(y,x+1,"o");} if (x==food_x && y==food_y){ collision_2=true; life=life+10; food_x=1+rand()%28; food_y=2+rand()%7; points=points+25; } switch (player_direct){ case 1: x--; break; case 2: x++; break; case 3: y--; break; case 4: y++; break; } switch (ghost_direct){ case 1: ghost_x--; break; case 2: ghost_x++; break; case 3: ghost_y--; break; case 4: ghost_y++; break;} //this code makes bird more likely to hit player if (clock>=25) { food_x=1+rand()%25; food_y=2+rand()%7; clock=rand()%7; life=life-15; } if (x<0) x=25; if (x>25) x=0; if (y<2) player_direct=4; if (y>8) player_direct=3; if (chased==1){ if (ghost_x>x) ghost_direct=1; if (ghost_x<x ) ghost_direct=2; if (ghost_y>y ) ghost_direct=3; if (ghost_y<y ) ghost_direct=4; } if (ghost_x<1) ghost_x=25; if (ghost_x>25) ghost_x=0; if (ghost_y<2) ghost_y=9; if (ghost_y>9) ghost_y=2; //game over if (life<=0) quit=true; attrset(COLOR_PAIR(3)); mvprintw(1, 0, "@@@@@@@@@@@@@@@@@@@@@@@@@@"); mvprintw(9,0,"@@@@@@@@@@@@@@@@@@@@@@@@@@"); attrset(COLOR_PAIR(5)); if (life<50) mvprintw(y,x,"o"); if (life>=51) mvprintw(y,x,"O"); if (star== true ) mvprintw(y, x, "="); attrset(COLOR_PAIR(2)); mvprintw(food_y,food_x,"e"); attrset(COLOR_PAIR(1)); if (chased==1) mvprintw(ghost_y,ghost_x,"&"); if (chased==0) mvprintw(ghost_y,ghost_x,"_"); attrset(COLOR_PAIR(1)); mvprintw(0,1,"life:"); mvprintw(0,6,"%i", life); mvprintw(0,22,"$"); mvprintw(0,23,"%i", points); }//while !quit closing brace timeout(-1); attrset(COLOR_PAIR(5)); mvprintw(4, 8, "GAME OVER"); mvprintw(6,8,"SCORE: $"); mvprintw(6,15,"%i", points); mvprintw(8, 4, "[email protected]"); refresh(); getch(); endwin(); goto home; }
0 Comments
//"Ghost
//W.Perez //[email protected] #include <string> #include <ncurses.h> #include <stdlib.h> #include <time.h> #include <iostream> using namespace std; int main() { home: bool quit = false; int life=50; int points=0; int x=7; int y=4; int food_x=15+rand()%8; int food_y=3+rand()%5; int ghost_x=18; int ghost_y=2+rand()%3; int ghost_direct=0; int player_direct=0; int clock=0; int clock_1=0; int clock_2=0; int clock_3=0; int ch; srand(time(NULL)); initscr(); noecho(); curs_set(0); keypad(stdscr, TRUE); timeout(175); //initiate color function start_color(); bkgd(COLOR_PAIR(1)); init_pair(1,COLOR_WHITE, COLOR_BLACK); init_pair(2, COLOR_GREEN, COLOR_BLACK); init_pair(3, COLOR_RED, COLOR_BLACK); init_pair(4, COLOR_GREEN, COLOR_BLACK); init_pair(5, COLOR_CYAN, COLOR_BLACK); init_pair(6, COLOR_WHITE, COLOR_BLUE); while (!quit) { ch = getch(); switch (ch) { case 'q': player_direct = 1; break; case 'w': player_direct = 1; break; case 'a': player_direct = 1; break; case 's': player_direct = 1; break; case 'z': player_direct = 1; break; case 'x': player_direct = 1; break; case 'o': player_direct = 2; break; case 'k': player_direct = 2; break; case 'l': player_direct = 2; break; case 'n': player_direct = 2; break; case 'm': player_direct = 2; break; case 'r': player_direct = 3; break; case 't': player_direct = 3; break; case 'y': player_direct = 3; break; case 'u': player_direct = 3; break; case 'c': player_direct = 4; break; case 'v': player_direct = 4; break; case 'b': player_direct = 4; break; case ' ': player_direct = 4; break; //Pause game case '0': timeout(555555); break; //unpause (resume game) case 'p': timeout(200); break;} attron(A_BOLD); clock++; clock_1++; clock_2++; clock_3++; erase(); bool collision=false; bool collision_2=false; bool chased=false; bool star=false; if (clock_3>=10+rand()%5 && clock_3 <=20+rand()%10) star=1; if (clock_3>=21) clock_3=0-rand()%5; if (x==food_x && y==food_y) collision_2=true; if (x==ghost_x && y==ghost_y && star==false || y==1 && star==false || y==11 && star==false){ collision=true; life--; } if (clock_1>=10 ) { chased=true; } if (clock_1>=21){ clock_1=rand()%5; chased=false; ghost_direct=0;} attrset(COLOR_PAIR(1)); if (collision) { mvprintw(0,12,":-("); mvprintw(y-1,x,"x"); mvprintw(y+1,x,"x"); mvprintw(y,x-1,"x"); mvprintw(y,x+1,"x");} if (collision_2) { mvprintw(0,10,"ENERGY!"); mvprintw(y-1,x,"o"); mvprintw(y+1,x,"o"); mvprintw(y,x-1,"o"); mvprintw(y,x+1,"o");} if (x==food_x && y==food_y){ collision_2=true; life=life+10; food_x=1+rand()%28; food_y=2+rand()%7; points=points+1; } switch (player_direct){ case 1: x--; break; case 2: x++; break; case 3: y--; break; case 4: y++; break; } switch (ghost_direct){ case 1: ghost_x--; break; case 2: ghost_x++; break; case 3: ghost_y--; break; case 4: ghost_y++; break;} //this code makes bird more likely to hit player if (clock>=25) { food_x=1+rand()%25; food_y=2+rand()%7; clock=rand()%7; life=life-5; } if (x<0) x=26; if (x>26) x=0; if (y<2) player_direct=4; if (y>10) player_direct=3; if (chased==1){ if (ghost_x>x) ghost_direct=1; if (ghost_x<x ) ghost_direct=2; if (ghost_y>y ) ghost_direct=3; if (ghost_y<y ) ghost_direct=4; } if (ghost_x<1) ghost_x=25; if (ghost_x>25) ghost_x=0; if (ghost_y<2) ghost_y=9; if (ghost_y>9) ghost_y=2; //game over if (life<=0) quit=true; attrset(COLOR_PAIR(1)); mvprintw(1, 0, "=========================="); mvprintw(11,0,"=========================="); attrset(COLOR_PAIR(1)); int r; int c; attrset(COLOR_PAIR(4)); for (r=2; r<11; r++) { //mvprintw(r, 0,"o"); for (c=0; c<27; c++){ mvprintw(r, c, ":"); } } attrset(COLOR_PAIR(5)); mvprintw(y,x,"0"); if (star== true && player_direct==1) mvprintw(y, x, "<"); if (star== true && player_direct==2 ) mvprintw(y, x, ">"); attrset(COLOR_PAIR(3)); mvprintw(food_y,food_x,"@"); attrset(COLOR_PAIR(1)); if (chased==1) mvprintw(ghost_y,ghost_x,"&"); if (chased==0) mvprintw(ghost_y,ghost_x,"."); attrset(COLOR_PAIR(1)); mvprintw(0,1,"life:"); mvprintw(0,6,"%i", life); mvprintw(0,21,"@:"); mvprintw(0,23,"%i", points); }//while !quit closing brace timeout(-1); attrset(COLOR_PAIR(5)); mvprintw(4, 8, "GAME OVER"); mvprintw(6,8,"SCORE: $"); mvprintw(6,15,"%i", points*25); mvprintw(8, 4, "[email protected]"); refresh(); getch(); endwin(); goto home; } //"Ghost
//W.Perez //[email protected] #include <string> #include <ncurses.h> #include <stdlib.h> #include <time.h> #include <iostream> using namespace std; int main() { home: bool quit = false; int life=50; int points=0; int x=7; int y=4; int food_x=15+rand()%8; int food_y=3+rand()%5; int ghost_x=18; int ghost_y=2+rand()%3; int ghost_direct=0; int player_direct=0; int clock=0; int clock_1=0; int clock_2=0; int clock_3=0; int ch; srand(time(NULL)); initscr(); noecho(); curs_set(0); keypad(stdscr, TRUE); timeout(175); //initiate color function start_color(); bkgd(COLOR_PAIR(1)); init_pair(1,COLOR_WHITE, COLOR_BLACK); init_pair(2, COLOR_GREEN, COLOR_BLACK); init_pair(3, COLOR_RED, COLOR_BLACK); init_pair(4, COLOR_GREEN, COLOR_BLACK); init_pair(5, COLOR_CYAN, COLOR_BLACK); while (!quit) { ch = getch(); switch (ch) { case 'q': player_direct = 1; break; case 'w': player_direct = 1; break; case 'a': player_direct = 1; break; case 's': player_direct = 1; break; case 'z': player_direct = 1; break; case 'x': player_direct = 1; break; case 'o': player_direct = 2; break; case 'k': player_direct = 2; break; case 'l': player_direct = 2; break; case 'n': player_direct = 2; break; case 'm': player_direct = 2; break; case 'r': player_direct = 3; break; case 't': player_direct = 3; break; case 'y': player_direct = 3; break; case 'u': player_direct = 3; break; case 'c': player_direct = 4; break; case 'v': player_direct = 4; break; case 'b': player_direct = 4; break; case ' ': player_direct = 4; break; //Pause game case '0': timeout(555555); break; //unpause (resume game) case 'p': timeout(200); break;} attron(A_BOLD); clock++; clock_1++; clock_2++; clock_3++; erase(); bool collision=false; bool collision_2=false; bool chased=false; bool star=false; if (clock_3>=10+rand()%5 && clock_3 <=20+rand()%10) star=1; if (clock_3>=21) clock_3=0-rand()%5; if (x==food_x && y==food_y) collision_2=true; if (x==ghost_x && y==ghost_y && star==false || y==1 && star==false || y==9 && star==false){ collision=true; life--; } if (clock_1>=10 ) { chased=true; } if (clock_1>=21){ clock_1=rand()%5; chased=false; ghost_direct=0;} attrset(COLOR_PAIR(1)); if (collision) { mvprintw(0,12,":-("); mvprintw(y-1,x,"x"); mvprintw(y+1,x,"x"); mvprintw(y,x-1,"x"); mvprintw(y,x+1,"x");} if (collision_2) { mvprintw(0,12,":-)"); mvprintw(y-1,x,"o"); mvprintw(y+1,x,"o"); mvprintw(y,x-1,"o"); mvprintw(y,x+1,"o");} if (x==food_x && y==food_y){ collision_2=true; life=life+10; food_x=1+rand()%28; food_y=2+rand()%7; points=points+1; } switch (player_direct){ case 1: x--; break; case 2: x++; break; case 3: y--; break; case 4: y++; break; } switch (ghost_direct){ case 1: ghost_x--; break; case 2: ghost_x++; break; case 3: ghost_y--; break; case 4: ghost_y++; break;} //this code makes bird more likely to hit player if (clock>=25) { food_x=1+rand()%25; food_y=2+rand()%7; clock=rand()%7; life=life-5; } if (x<0) x=25; if (x>25) x=0; if (y<2) player_direct=4; if (y>8) player_direct=3; if (chased==1){ if (ghost_x>x) ghost_direct=1; if (ghost_x<x ) ghost_direct=2; if (ghost_y>y ) ghost_direct=3; if (ghost_y<y ) ghost_direct=4; } if (ghost_x<1) ghost_x=25; if (ghost_x>25) ghost_x=0; if (ghost_y<2) ghost_y=9; if (ghost_y>9) ghost_y=2; //game over if (life<=0) quit=true; attrset(COLOR_PAIR(3)); mvprintw(1, 0, "=========================="); mvprintw(9,0,"=========================="); attrset(COLOR_PAIR(5)); if (life<50) mvprintw(y,x,"o"); if (life>=51) mvprintw(y,x,"0"); if (star== true && player_direct==1) mvprintw(y, x, "("); if (star== true && player_direct==2 ) mvprintw(y, x, ")"); attrset(COLOR_PAIR(2)); mvprintw(food_y,food_x,"@"); attrset(COLOR_PAIR(1)); if (chased==1) mvprintw(ghost_y,ghost_x,"&"); if (chased==0) mvprintw(ghost_y,ghost_x,"_"); attrset(COLOR_PAIR(1)); mvprintw(0,1,"life:"); mvprintw(0,6,"%i", life); mvprintw(0,21,"@:"); mvprintw(0,23,"%i", points); }//while !quit closing brace timeout(-1); attrset(COLOR_PAIR(5)); mvprintw(4, 8, "GAME OVER"); mvprintw(6,8,"SCORE: $"); mvprintw(6,15,"%i", points*25); mvprintw(8, 4, "[email protected]"); refresh(); getch(); endwin(); goto home; } //"Ghost
//W.Perez //[email protected] #include <string> #include <ncurses.h> #include <stdlib.h> #include <time.h> #include <iostream> using namespace std; int main() { home: bool quit = false; int life=75; int points=0; int x=7; int y=4; int food_x=15+rand()%8; int food_y=3+rand()%5; int ghost_x=18; int ghost_y=2+rand()%3; int ghost_direct=0; int player_direct=0; int clock=0; int clock_1=0; int clock_2=0; int clock_3=0; int ch; srand(time(NULL)); initscr(); noecho(); curs_set(0); keypad(stdscr, TRUE); timeout(175); //initiate color function start_color(); bkgd(COLOR_PAIR(1)); init_pair(1,COLOR_WHITE, COLOR_BLACK); init_pair(2, COLOR_GREEN, COLOR_BLACK); init_pair(3, COLOR_WHITE, COLOR_BLUE); init_pair(4, COLOR_GREEN, COLOR_BLACK); init_pair(5, COLOR_CYAN, COLOR_BLACK); while (!quit) { ch = getch(); switch (ch) { case 'q': player_direct = 1; break; case 'w': player_direct = 1; break; case 'a': player_direct = 1; break; case 's': player_direct = 1; break; case 'z': player_direct = 1; break; case 'x': player_direct = 1; break; case 'o': player_direct = 2; break; case 'k': player_direct = 2; break; case 'l': player_direct = 2; break; case 'n': player_direct = 2; break; case 'm': player_direct = 2; break; case 'r': player_direct = 3; break; case 't': player_direct = 3; break; case 'y': player_direct = 3; break; case 'u': player_direct = 3; break; case 'c': player_direct = 4; break; case 'v': player_direct = 4; break; case 'b': player_direct = 4; break; case ' ': player_direct = 4; break; //Pause game case '0': timeout(555555); break; //unpause (resume game) case 'p': timeout(200); break;} attron(A_BOLD); clock++; clock_1++; clock_2++; clock_3++; erase(); bool collision=false; bool collision_2=false; bool chased=false; bool star=false; if (clock_3>=10+rand()%5 && clock_3 <=20+rand()%10) star=1; if (clock_3>=21) clock_3=0-rand()%5; if (x==food_x && y==food_y) collision_2=true; if (x==ghost_x && y==ghost_y && star==false || y==1 && star==false || y==9 && star==false){ collision=true; life--; } if (clock_1>=10 ) { chased=true; } if (clock_1>=21){ clock_1=rand()%5; chased=false; ghost_direct=0;} attrset(COLOR_PAIR(1)); if (collision) { mvprintw(0,12,":-("); mvprintw(y-1,x,"x"); mvprintw(y+1,x,"x"); mvprintw(y,x-1,"x"); mvprintw(y,x+1,"x");} if (collision_2) { mvprintw(0,12,":-)"); mvprintw(y-1,x,"o"); mvprintw(y+1,x,"o"); mvprintw(y,x-1,"o"); mvprintw(y,x+1,"o");} if (x==food_x && y==food_y){ collision_2=true; life=life+10; food_x=1+rand()%28; food_y=2+rand()%7; points=points+25; } switch (player_direct){ case 1: x--; break; case 2: x++; break; case 3: y--; break; case 4: y++; break; } switch (ghost_direct){ case 1: ghost_x--; break; case 2: ghost_x++; break; case 3: ghost_y--; break; case 4: ghost_y++; break;} //this code makes bird more likely to hit player if (clock>=25) { food_x=1+rand()%25; food_y=2+rand()%7; clock=rand()%7; life=life-5; } if (x<0) x=25; if (x>25) x=0; if (y<2) player_direct=4; if (y>8) player_direct=3; if (chased==1){ if (ghost_x>x) ghost_direct=1; if (ghost_x<x ) ghost_direct=2; if (ghost_y>y ) ghost_direct=3; if (ghost_y<y ) ghost_direct=4; } if (ghost_x<1) ghost_x=25; if (ghost_x>25) ghost_x=0; if (ghost_y<2) ghost_y=9; if (ghost_y>9) ghost_y=2; //game over if (life<=0) quit=true; attrset(COLOR_PAIR(3)); mvprintw(1, 0, "((((((((((((()))))))))))))"); mvprintw(9,0,"((((((((((((()))))))))))))"); attrset(COLOR_PAIR(5)); if (life<50) mvprintw(y,x,"o"); if (life>=51) mvprintw(y,x,"0"); if (star== true ) mvprintw(y, x, "="); attrset(COLOR_PAIR(2)); mvprintw(food_y,food_x,"$"); attrset(COLOR_PAIR(1)); if (chased==1) mvprintw(ghost_y,ghost_x,"&"); if (chased==0) mvprintw(ghost_y,ghost_x,"_"); attrset(COLOR_PAIR(1)); mvprintw(0,1,"life:"); mvprintw(0,6,"%i", life); mvprintw(0,22,"$"); mvprintw(0,23,"%i", points); }//while !quit closing brace timeout(-1); attrset(COLOR_PAIR(5)); mvprintw(4, 8, "GAME OVER"); mvprintw(6,8,"SCORE: $"); mvprintw(6,15,"%i", points); mvprintw(8, 4, "[email protected]"); refresh(); getch(); endwin(); goto home; } //"Ghost
//W.Perez //[email protected] #include <string> #include <ncurses.h> #include <stdlib.h> #include <time.h> #include <iostream> using namespace std; int main() { home: bool quit = false; int life=75; int points=0; int x=12; int y=5; int food_x=15+rand()%8; int food_y=3+rand()%5; int ghost_x=10; int ghost_y=2+rand()%5; int ghost_direct=0; int player_direct=0; int clock=0; int clock_1=0; int clock_2=0; int clock_3=0; int ch; srand(time(NULL)); initscr(); noecho(); curs_set(0); keypad(stdscr, TRUE); timeout(175); //initiate color function start_color(); bkgd(COLOR_PAIR(1)); init_pair(1,COLOR_WHITE, COLOR_BLACK); init_pair(2, COLOR_RED, COLOR_BLACK); init_pair(3, COLOR_WHITE, COLOR_BLUE); init_pair(4, COLOR_GREEN, COLOR_BLACK); init_pair(5, COLOR_CYAN, COLOR_BLACK); while (!quit) { ch = getch(); switch (ch) { case 'q': player_direct = 1; break; case 'w': player_direct = 1; break; case 'a': player_direct = 1; break; case 's': player_direct = 1; break; case 'z': player_direct = 1; break; case 'x': player_direct = 1; break; case 'o': player_direct = 2; break; case 'k': player_direct = 2; break; case 'l': player_direct = 2; break; case 'n': player_direct = 2; break; case 'm': player_direct = 2; break; case 'r': player_direct = 3; break; case 't': player_direct = 3; break; case 'y': player_direct = 3; break; case 'u': player_direct = 3; break; case 'c': player_direct = 4; break; case 'v': player_direct = 4; break; case 'b': player_direct = 4; break; case ' ': player_direct = 4; break; //Pause game case '0': timeout(555555); break; //unpause (resume game) case 'p': timeout(200); break;} attron(A_BOLD); clock++; clock_1++; clock_2++; clock_3++; erase(); bool collision=false; bool collision_2=false; bool chased=false; bool star=false; if (clock_3>=10+rand()%5 && clock_3 <=20+rand()%10) star=1; if (clock_3>=21) clock_3=0-rand()%5; if (x==food_x && y==food_y) collision_2=true; if (x==ghost_x && y==ghost_y || y==1 || y==9 && star== false ){ collision=true; life--; } if (clock_1>=10 ) { chased=true; } if (clock_1>=21){ clock_1=rand()%5; chased=false; ghost_direct=0;} attrset(COLOR_PAIR(1)); if (collision) { mvprintw(0,12,":-("); mvprintw(y-1,x,"x"); mvprintw(y+1,x,"x"); mvprintw(y,x-1,"x"); mvprintw(y,x+1,"x");} if (collision_2) { mvprintw(0,12,":-)"); mvprintw(y-1,x,"o"); mvprintw(y+1,x,"o"); mvprintw(y,x-1,"o"); mvprintw(y,x+1,"o");} if (x==food_x && y==food_y){ collision_2=true; life=life+10; food_x=1+rand()%28; food_y=2+rand()%7; points=points+25; } switch (player_direct){ case 1: x--; break; case 2: x++; break; case 3: y--; break; case 4: y++; break; } switch (ghost_direct){ case 1: ghost_x--; break; case 2: ghost_x++; break; case 3: ghost_y--; break; case 4: ghost_y++; break;} //this code makes bird more likely to hit player if (clock>=25) { food_x=1+rand()%25; food_y=2+rand()%7; clock=rand()%7; life=life-15; } if (x<0) x=25; if (x>25) x=0; if (y<2) player_direct=4; if (y>8) player_direct=3; if (chased==1){ if (ghost_x>x) ghost_direct=1; if (ghost_x<x ) ghost_direct=2; if (ghost_y>y ) ghost_direct=3; if (ghost_y<y ) ghost_direct=4; } if (ghost_x<1) ghost_x=25; if (ghost_x>25) ghost_x=0; if (ghost_y<2) ghost_y=9; if (ghost_y>9) ghost_y=2; //game over if (life<=0) quit=true; attrset(COLOR_PAIR(3)); mvprintw(1, 0, "@@@@@@@@@@@@@@@@@@@@@@@@@@"); mvprintw(9,0,"@@@@@@@@@@@@@@@@@@@@@@@@@@"); attrset(COLOR_PAIR(5)); if (life<50) mvprintw(y,x,"o"); if (life>=51) mvprintw(y,x,"O"); if (star== true ) mvprintw(y, x, "="); attrset(COLOR_PAIR(2)); mvprintw(food_y,food_x,"e"); attrset(COLOR_PAIR(1)); if (chased==1) mvprintw(ghost_y,ghost_x,"&"); if (chased==0) mvprintw(ghost_y,ghost_x,"_"); attrset(COLOR_PAIR(1)); mvprintw(0,1,"life:"); mvprintw(0,6,"%i", life); mvprintw(0,22,"$"); mvprintw(0,23,"%i", points); }//while !quit closing brace timeout(-1); attrset(COLOR_PAIR(5)); mvprintw(4, 8, "GAME OVER"); mvprintw(6,8,"SCORE: $"); mvprintw(6,15,"%i", points); mvprintw(8, 4, "[email protected]"); refresh(); getch(); endwin(); goto home; } |
Archives
March 2016
Categories |