void recordAnimation() { uchar c, i; struct HiScore* p; struct HiScore tmp; prepareRecordScreen(); if(score < hiScores[8].score) { return; } hiScores[8].score = score; memset(hiScores[8].name, 0, 6); i = 0; drawRecordScreen(8); while(1) { c = getch_(); if(c==13) break; if(c==127) { if(i==0) continue; --i; hiScores[8].name[i] = 0; drawRecordLastLine(); continue; } if(c>=32 && c<127) { if(i==6) continue; hiScores[8].name[i] = c; hiScores[8].name[i+1] = 0; ++i; drawRecordLastLine(); } } c = 8; p = hiScores+8; while(1) { if(p->score >= p[-1].score) break; p--; memcpy(&tmp, p+1, sizeof(tmp)); memcpy(p+1, p, sizeof(tmp)); memcpy(p, &tmp, sizeof(tmp)); c--; drawRecordScreen(c); delay(RECORD_SPEED); if(c==0) { updateTopScore(); break; } } getch_(); }
void information_window(void) { /* * Developer information window. Explains how * to use the developer mode with the game and * what it is useful for. */ WINDOW *vin; initscr(); refresh(); noecho(); int height = 18, width = 65; int starty = (LINES - height) / 2; /* Calculating for a center placement */ int startx = (COLS - width) / 2; /* of the window */ vin=newwin(height,width,starty,startx); wmove(vin,0,0); setdisplay(vin, " Developer information window "); wprintw(vin, " The developer control panel is a very interesting place to go\n" " about doing business with this game. There are a few options \n" " that you can use to change how you interact with the game and\n" " how the game interacts with you. In order to use the game in \n" " ways it is not intended to be used by the general public. To \n" " enable the developer mode (which also enables the developer \n" " control panel and removed the * around it), you must run the \n" " game with developer-mode as the first parameter. This mode is\n" " not enableable from within normal mode or during the game. It\n" " holds the enabled effect when restored from a save but it not\n" " if you restart the game in normal mode. If you rely on a seed\n" " you can specify a seed value from the command line after the \n" " developer mode argument. The developer control panel is risky\n" " and not reccommended for all users. This panel will change by\n" " demand. Press any key to return. " ); wrefresh(vin); getch_(); cldisplay(vin); delwin(vin); endwin(); }
/* Read 1 character with echo */ char getche(void) { return getch_(1); }
/* Read 1 character without echo */ char getch(void) { return getch_(0); }
void main() { uchar c, c1; uchar selAnimationT = 0; uint selAnimationTT = 0, keybTimeout=0; intro(); // Инициализируем экран initGameScreen(); // Запускаем игру startGame(); while(1) { rand(); if(selX!=-1) { selAnimationTT++; if(selAnimationTT==500) { selAnimationTT=0; drawSpriteSel(selX, selY, game[selX][selY], selX==cursorX && selY==cursorY, selAnimationT); selAnimationT++; if(selAnimationT>=4) selAnimationT=0; else if(playSound && selAnimationT==2) soundJumpSel(); } } c1 = bioskey_(); if(keybTimeout) { keybTimeout--; continue; } if(c == c1) continue; c = c1; switch(c) { case KEY_PATH: showPath = !showPath; drawOnOff(0, showPath); break; case KEY_SOUND: playSound = !playSound; drawOnOff(1, playSound); break; case KEY_HELP: showHelp = !showHelp; drawOnOff(2, showHelp); redrawNewBalls2(); break; case KEY_RECORD: prepareRecordScreen(); drawRecordScreen(-1); getch_(); drawCells(); break; case KEY_NEW: startGame(); break; /* case KEY_UP: if(score>=10) score-=10; drawScore1(); break; case KEY_DOWN: score+=10; drawScore1(); break; */ case KEY_UP: clearCursor(); if(cursorY==0) cursorY=8; else cursorY--; drawCursor(); break; case KEY_DOWN: clearCursor(); if(cursorY==8) cursorY=0; else cursorY++; drawCursor(); break; case KEY_LEFT: clearCursor(); if(cursorX==0) cursorX=8; else cursorX--; drawCursor(); break; case KEY_RIGHT: clearCursor(); if(cursorX==8) cursorX=0; else cursorX++; drawCursor(); break; case KEY_SPACE: if(game[cursorX][cursorY]) { if(selX!=-1) drawCell(selX, selY); selX=cursorX, selY=cursorY; break; } if(selX==-1) break; move(); if(gameOver) { recordAnimation(); startGame(); } break; default: continue; } keybTimeout=300; } }
void developer_settings_window(void) { /* * Developer control panel * This is what we will use to control * developer stuff that we make public * to help debug the program like thread * hooks, pointer references, and pauses */ WINDOW *vin; initscr(); refresh(); noecho(); int height = 7, width = 42; int wheight = 11, wwidth = 42; vin = phyrrus9::nwin::wcreatewin(wheight, wwidth); wmove(vin,0,0); char tmpc; //first, before we can allow this to happen we need to display //a warning so the user knows we mean business. setdisplay(vin, " Developer settings"); wprintw(vin, " Warning, this is the developer console\n" " this is not something to play with. so\n" " please be careful. This panel will let\n" " you do things beyond your far dreams, \n" " which makes it dangerous. If you don't\n" " know how to handle this, press Q now, \n" " If you know the risks, and you wish to\n" " proceed, press any other key."); wrefresh(vin); tmpc = getch_(); if (tmpc != 'Q') { while (tmpc != '4') { phyrrus9::nwin::wresizewindow(vin, height, width); setdisplay(vin, " Developer settings"); wprintw(vin, " 1. Game settings\n"); wprintw(vin, " 2. Engine settings\n", env.cheats); wprintw(vin, " 3. Developer mods\n"); wprintw(vin, " 4. Return "); wrefresh(vin); tmpc = getch_(); if (tmpc == '1') { setdisplay(vin, " Game settings"); wprintw(vin, " Enable cheats?\n"); wprintw(vin, " Old: %.1d\n", env.cheats); wprintw(vin, " New: "); wrefresh(vin); tmpc = getch_(); env.cheats = tmpc - 48; wrefresh(vin); setdisplay(vin, " Developer settings"); wprintw(vin, " Enable fog?\n"); wprintw(vin, " Old: %.1d\n", env.showmap); wprintw(vin, " New: "); wrefresh(vin); tmpc = getch_(); env.showmap = tmpc - 48; } if (tmpc == '2') { while (tmpc != 'z') { phyrrus9::nwin::wresizewindow(vin, height + 2, width); setdisplay(vin, " Engine settings"); wprintw(vin, " a. Modify save file location\n"); wprintw(vin, " b. Modify map location\n"); wprintw(vin, " y. Disable developer mode\n"); wprintw(vin, " z. Return to developer menu. "); wrefresh(vin); tmpc = getch_(); werase(vin); wrefresh(vin); wresize(vin, height, width); wrefresh(vin); if (tmpc == 'a') { phyrrus9::nwin::wresizewindow(vin, height + 1, width); char * tempstr = new char[30]; setdisplay(vin, " Engine save file"); wprintw(vin, " Current: %s\n", env.savefile.c_str()); wprintw(vin, " Please enter a new name. You\n"); wprintw(vin, " will not see this until pressing\n"); wprintw(vin, " the enter key. "); wrefresh(vin); scanf("%s", tempstr); env.savefile = tempstr; delete tempstr; werase(vin); wrefresh(vin); wresize(vin, height, width); setdisplay(vin, " Engine save file"); wprintw(vin, " Save file: %s\n", env.savefile.c_str()); wprintw(vin, " Press any key to return\n "); wrefresh(vin); getch_(); werase(vin); wrefresh(vin); wresize(vin, height, width); wrefresh(vin); } if (tmpc == 'b') { setdisplay(vin, " Modify map location"); wprintw(vin, " Please enter the map location\n :"); wrefresh(vin); int _location; cin >> _location; setdisplay(vin, " Modify map location"); wprintw(vin, " Map location: %d\n", _location); wprintw(vin, " Current value: %c\n", env.map[_location]); wprintw(vin, " New value: "); wrefresh(vin); env.map[_location] = getch_(); setdisplay(vin, " Map location modified"); wprintw(vin, " Map position: %d\n", _location); wprintw(vin, " Value: %c\n", env.map[_location]); wprintw(vin, " Press any key to return... "); wrefresh(vin); getch_(); werase(vin); } if (tmpc == 'y') { setdisplay(vin, " Disable developer mode"); wprintw(vin, " Are you sure you want to do this?\n"); wprintw(vin, " Please enter 1 (yes) or 0 (no)\n"); wprintw(vin, " :"); wrefresh(vin); char c = getch_(); if (c == '1') { env.developer_mode = false; env.can_enable_developer_mode = true; } } } werase(vin); } if (tmpc == '3') { int dmheight = 7; int dmwidth = 50; dmheight += env.modcount; phyrrus9::nwin::wresizewindow(vin, dmheight, dmwidth); setdisplay(vin, " Developer mods"); wprintw(vin, " Please select mod to enable.\n"); wprintw(vin, " Enabled mods cannot be disabled (yet)\n"); wprintw(vin, " * denotes an enabled mod\n"); if (env.modcount > 0) { for (int i = 0; i < env.modcount; i++) { wprintw(vin, " %d Name: %s", i + 1, env.modlist[i].name); if (env.modlist[i].enabled == true) { wprintw(vin, "*"); } wprintw(vin, "\n"); } wprintw(vin, " :"); wrefresh(vin); char modnum = 0; do { modnum = getch_(); } while (modnum < '0' && modnum > env.modcount + 48); int mod_number = char_int(modnum) - 1; if (env.modlist[mod_number].enabled == false) { phyrrus9::nwin::wresizewindow(vin, 4 + env.modcount, 35); setdisplay(vin, " Mod enabled"); wprintw(vin, " %s enabled\n", env.modlist[mod_number].name); env.modlist[mod_number].enabled = true; enablemod(mod_number); } else { phyrrus9::nwin::wresizewindow(vin, 4, 35); setdisplay(vin, " Error!"); wprintw(vin, " %s is already enabled\n", env.modlist[mod_number].name); } } wrefresh(vin); getch_(); } } }
char getch (void) { /* Read 1 character without echo */ return getch_ (0); }
char tgetche(int timeout) { return getch_(1, timeout);}
char getche(void) { return getch_(1, NO_TIMEOUT);}
char tgetch (int timeout) { return getch_(0, timeout);}
char getch (void) { return getch_(0, NO_TIMEOUT);}