void main() { int i,j,boxidx; int driver=DETECT, mode=0; randomize(); //registerbgidriver(EGAVGA_driver); initgraph(&driver,&mode,""); xyz: do { menu(); init(); boxidx=random(7); FORCOLOR2=random(7)+1; for(j=0;j<4;j++) for(i=0;i<4;i++) box2[j][i]=BOX[boxidx][j][i]; do { getMessage(); dispatchMessage(); }while(!gameOver()); highscore(); OVER(); getch(); }while(1); }
//function to display gameover screen void gameover() { cls(); //show gameover screen draw_object ("dead.txt", 0x0C); colour(0x0A); highscore(score); cout << endl << "Enter 1 to replay" << endl; cout << "Enter 2 to return to Main Menu" << endl; int inputGO = 0; cin.clear(); cin >> inputGO; //reset the game if (inputGO == 1) { Beep (2000,200); init(); mainLoop(); } if (inputGO == 2) { Beep (1350,150); init(); gameLoop(); } }
int main(void) { t_env env; int ret; if (!power_two(WIN_VALUE)) return (0); signal(SIGINT, sighandler); startwin(&env); while (true) { ret = menu(&env, 0, 0); if (ret == 2) break ; else if (ret == 1) highscore(&env); else if (ret == 0) { init_env_game(&env); game(&env); get_name(&env); get_score(&env, 0); del_env_game(&env); } } return (endwin(), 0); }
void check_top_ten(void) { if (players[10].points> players[9].points) {bubblesort();} save_score(); highscore(); }
void idlescore(void) { static int hscolor=0; switch(hscolor) { case 0: color1=1.0; color2=0.0; color3=0.0; hscolor++; break; case 1: color1=0.5; color2=0.5; color3=0.0; hscolor++; break; case 2: color1=1.0; color2=1.0; color3=0.0; hscolor++; break; case 3: color1=0.0; color2=1.0; color3=0.0; hscolor++; break; case 4: color1=0.0; color2=0.0; color3=1.0; hscolor++; break; case 5: color1=1.0; color2=0.0; color3=1.0; hscolor=0; break; } if (curstate==HIGHSC) highscore(); else if (curstate==VIEWSCORES) showhighscores(); else { printf("Unknown state %d, exiting\n", curstate); exit(1); } glutPostRedisplay(); }
void KJezzball::gameOverNow() { m_state = Idle; QString score; score.setNum( m_game.score ); KMessageBox::information( this, i18n("Game Over! Score: %1").arg(score) ); statusBar()->message( i18n("Game over. Press <Space> for a new game") ); //m_gameWidget->display( i18n("Game over. Press <Space> for a new game!") ); highscore(); }
// This main loop calls functions to get input, update and render the game // at a specific frame rate void game() { int current = 500; createsnake(3); cls(); map(); g_timer.startTimer(); // Start timer to calculate how long it takes to render this frame while (!gameover) // run this loop until user wants to quit { getInput(); // get keyboard input current = update(g_timer.getElapsedTime()); // update the game render(); // render the graphics output to screen g_timer.waitUntil(current/FPS); // Frame rate limiter. Limits each frame to a specified time in ms. } highscore(); gg(); }
void KJezzball::closeGame() { if ( m_state!=Idle ) { int old_state = m_state; if (old_state == Running) pauseGame(); int ret = KMessageBox::questionYesNo( this, i18n("Do you really want to close the running game?"), QString::null, KStdGuiItem::close(), KStdGuiItem::cancel() ); if ( ret==KMessageBox::Yes ) { stopLevel(); m_state = Idle; highscore(); } else if (old_state == Running) { pauseGame(); // Unpause } } }
int play(int scr, int life) { int dmp = 999; //dumping garbage while (life>0) { ct = _getch(); while ((!_kbhit()) && (life>0)) { if (dy == 20) { dy = 0; srand(time(NULL)); dx = rand() % 30 + 20; if (((dx >= bx + lsr) && (dx <= bx +13+ rsr ))) //scan range { switch (dmp) { case 999:scr = scr - 10; break; case 6: life--; scr = scr - 10;printf("\a\a");break; //rat case 7: life++; break;//heart case 8: life--; scr = scr - 10;printf("\a\a");break; //cat } scr = scr + 10; } else { switch (dmp) { case 999:scr = scr + 5; break; case 6:scr = scr + 5; break; //rat case 8:scr = scr + 5; break; //cat } scr = scr - 5; } dmp = rand() % 9; } clrscr(); gotoxy(0, 0); printf("Score : %d\t\t\t\t\t\t\tLife : ", scr, life); for (i = 0; i < life; i++) { if (i<9) cprintf("%c", 3); if (i == 9) life = 9; } gotoxy(dx, dy); gbtypes(dmp, dx, dy); switch (ct) { case'a': {Sleep(0); bx = bx - 2; if (bx < 10) bx = bx + 2; break; } case'd': {Sleep(0); bx = bx + 2; if (bx > 60) bx = bx - 2; break; } case']': {gotoxy(20, 20); printf("Game Pause--Press any key to resume");system("color 6");ct = _getch();system("color 7"); } } gotoxy(bx, 20); _cprintf(" | |"); gotoxy(bx, 21); _cprintf(" | |"); gotoxy(bx, 22); _cprintf(" |____________|"); Sleep(50); dy++; } } clrscr(); clrscr(); printf(" \n\n"); printf("________________________________________________________________________________\n"); printf(" ||||||| |||||| ||| ||| ||'''' ,|||, \\\\ // ||'''' ||||||| \n"); printf(" || ___ ||__|| || \\/ || |||||| || || \\\\ // |||||| ||,,,|| \n"); printf(" ||,,,|| || || || || ||,,,, '|||' \\\\/ ||,,,, || \\\\ \n"); printf("________________________________________________________________________________"); gotoxy(40, 13); printf("GAMEOVER");\ gotoxy(40, 14); printf("Score %d\n\n\t press any key Return to Main Menu", scr); getch(); getch(); highscore(scr); clrscr(); main(); return 0; }
int Game(int port, const char *ApplicationPath) { // Variabeln definieren char Name[20]; // Array für Spielername int Zeichen; // Variable zur Verarbeitung der eingelesenen Zeichen int key; // Variable zum einlesen der Zeichen von der Tastatur int dir = 0; // Variable zum speichern der Richtung int dir_old = 0; // Variable zum speichern der letzten Richtung int score; // Variable für den Score int winner; // Variable für Rückgabewert der Highscorefunktion // Wird 1 wenn Highscore geknackt wurde, sonst 0 int i = 0; // Bildschirm löschen ClearWindow(); // Spielernamen einlesen SelectFont("Arial MS", 15, FONT_NORMAL); DrawTextXY (50, 50, COL_GREEN, "Bitte Namen eingeben:"); while((key = GetKeyPress()) != W_KEY_RETURN ){ Zeichen = key; // Anzahl der Zeichen begrenzen, Leertaste unterdrücken if ((Zeichen >= ' ')&&(i < 19) && (Zeichen != 0x20) ){ Name[i] = Zeichen; Name[i+1] = '\0'; i++; } // Möglichkeit Zeichen zu löschen if( Zeichen == '\b'){ if(i>0){ i--; Name[i]='\0'; DrawFilledRectangle(270, 25, 300, 40, COL_BLACK, 1); } } // Bisherige Eingabe anzeigen DrawTextXY (270, 50, COL_RED, Name); } DrawTextXY (50, 80, COL_GREEN, "Now playing! [ESC] to escape"); if (InitSerialPort(port, Bd9600, P_NONE, 8, 1) == 0) // COM1 { printf("\nPort opened: COM%d", port); do { if(IsKeyPressReady()) // Wenn Taste gedrückt { key = GetKeyPress(); switch(key) { case W_KEY_CURSOR_UP: if(dir_old != 'd') { dir = 'u'; } break; case W_KEY_CURSOR_DOWN: if(dir_old != 'u') { dir = 'd'; } break; case W_KEY_CURSOR_LEFT: if(dir_old != 'r') { dir = 'l'; } break; case W_KEY_CURSOR_RIGHT: if(dir_old != 'l') { dir = 'r'; } break; case W_KEY_ESCAPE: case W_KEY_CLOSE_WINDOW: ShutdownSerialPort(); return 0; break; default: key = NO_VALID_KEY; break; } // Nur wenn Key gültig ist und der Wert geändert hat ein Zeichen ans Carmekit senden if(dir != dir_old) { SendByteToSerialPort(dir); // Alter Wert speichern dir_old = dir; } } score = GetByteFromSerialPort(); } while (score == -1); ShutdownSerialPort(); winner=highscore(Name , score , ApplicationPath); SelectFont("Arial MS", 20, FONT_ITALIC); if(winner == 1) { DrawTextXY (220, 200, COL_GREEN, "Du hast den High Score geknackt!"); } else { DrawTextXY (220, 200, COL_GREEN, "Game over."); } SelectFont("Arial MS", 15, FONT_NORMAL); DrawTextXY (220, 230, COL_GREEN, "Press any key to continue."); while(!IsKeyPressReady()) ; } return 0; }
void gamecreditsscreen(){ if (currscreen!=prevscreen)playpreview(); const int creds=37; static double scroll; static drawtext marmots[creds]; static char marmotscon[creds][256]; static drawtext tyfp; static drawtext dmtscore1; static drawtext g1tscore1; static drawtext g2tscore1; static drawtext dmtscoren; static drawtext g1tscoren; static drawtext g2tscoren; static drawtext dmtscore2; static drawtext g1tscore2; static drawtext g2tscore2; static char dmtscorecon[256]; static char g1tscorecon[256]; static char g2tscorecon[256]; //heh cool. const int parts=75; static double lspeed[parts]; static int parx[parts]; static int pary[parts]; static int color[parts]; static int size[parts]; char avifile[128]; static bool hasavi=false; srand(time(0)); scroll+=.5f*double(steptime)/16.0; if (currscreen!=prevscreen){ for (int a=0;a<parts;a++){ lspeed[a]=double( (double)rand()/(double)(RAND_MAX/2)-1 ); //pary[a]=int( (double)rand()/(double)RAND_MAX *768); pary[a]=a*10; parx[a]=int( (double)pary[a]*lspeed[a] ) + 512; color[a]=int( (double)rand()/(double)RAND_MAX *10); size[a]=int( (double)rand()/(double)RAND_MAX *50)+62; //printf("Particle %i will be drawn at: (%i,%i) with speed (%.2f) and color (%i)\n",a,parx[a],pary[a],lspeed[a],color[a]); } sprintf(dmtscorecon, "Thank You For Playing!"); tyfp.load(dmtscorecon,"grade.ttf",255,255,255,20); sprintf(dmtscorecon, "Drum Player Score:"); dmtscoren.load(dmtscorecon,"grade.ttf",128,128,0,20); sprintf(g1tscorecon, "Guitar Player 1 Score:"); g1tscoren.load(g1tscorecon,"grade.ttf",128,0,0,20); sprintf(g2tscorecon, "Guitar Player 2 Score:"); g2tscoren.load(g2tscorecon,"grade.ttf",0,0,128,20); sprintf(dmtscorecon, "%i", gptscore); dmtscore1.load(dmtscorecon,"grade.ttf",255,255,0,40); dmtscore2.load(dmtscorecon,"grade.ttf",128,128,0,40); sprintf(g1tscorecon, "%i", gpg1tscore); g1tscore1.load(g1tscorecon,"grade.ttf",255,0,0,40); g1tscore2.load(g1tscorecon,"grade.ttf",128,0,0,40); sprintf(g2tscorecon, "%i", gpg2tscore); g2tscore1.load(g2tscorecon,"grade.ttf",0,0,255,40); g2tscore2.load(g2tscorecon,"grade.ttf",0,0,128,40); scroll=-20; sprintf(marmotscon[0], "Lead Developer/Producer/Director/Head Marmot:"); marmots[0].load(marmotscon[0],"font.ttf",128,0,255,20); sprintf(marmotscon[1], "Joe Wall"); marmots[1].load(marmotscon[1],"font.ttf",255,255,255,20); sprintf(marmotscon[2], " "); marmots[2].load(marmotscon[2],"font.ttf",255,255,255,20); sprintf(marmotscon[3], "Assistant Develepor/Sound Engineer (Oswego AL):"); marmots[3].load(marmotscon[3],"font.ttf",255,128,192,20); sprintf(marmotscon[4], "Velex Loutzenhiser"); marmots[4].load(marmotscon[4],"font.ttf",255,255,255,20); sprintf(marmotscon[5], " "); marmots[5].load(marmotscon[5],"font.ttf",255,255,255,20); sprintf(marmotscon[6], "Assistant Graphic Designer:"); marmots[6].load(marmotscon[6],"font.ttf",0,0,192,20); sprintf(marmotscon[7], "Michael Culver"); marmots[7].load(marmotscon[7],"font.ttf",255,255,255,20); sprintf(marmotscon[8], " "); sprintf(marmotscon[9], "DigiBand Named by:"); marmots[9].load(marmotscon[9],"font.ttf",0,0,192,20); sprintf(marmotscon[10], "Dave Britten"); marmots[10].load(marmotscon[10],"font.ttf",255,255,255,20); sprintf(marmotscon[11], " "); marmots[11].load(marmotscon[11],"font.ttf",255,255,255,20); sprintf(marmotscon[12], "Developed with the Following Tools and Libraries:"); marmots[12].load(marmotscon[12],"font.ttf",0,255,0,20); sprintf(marmotscon[13], "Simple Direct-media Layer (SDL)"); marmots[13].load(marmotscon[13],"font.ttf",255,255,255,20); sprintf(marmotscon[14], "Minimum GNU for Windows (Mingw)"); marmots[14].load(marmotscon[14],"font.ttf",255,255,255,20); sprintf(marmotscon[15], " "); marmots[15].load(marmotscon[15],"font.ttf",255,255,255,20); sprintf(marmotscon[16], "Music Credits:"); marmots[16].load(marmotscon[16],"font.ttf",0,255,255,20); sprintf(marmotscon[17], "\"After the Fall\" - Dave De Jong"); marmots[17].load(marmotscon[17],"font.ttf",255,255,255,20); sprintf(marmotscon[18], "\"Blue Matter\" - John Scofield"); marmots[18].load(marmotscon[18],"font.ttf",255,255,255,20); sprintf(marmotscon[19], "\"Blue Train\" - Josef Huber (Orig. by John Coltrane)"); marmots[19].load(marmotscon[19],"font.ttf",255,255,255,20); sprintf(marmotscon[20], "\"Chicago Days\" - Eric M. Vigeland"); marmots[20].load(marmotscon[20],"font.ttf",255,255,255,20); sprintf(marmotscon[21], "\"A Casual Emergency\" - Rob Dewey Trio"); marmots[21].load(marmotscon[21],"font.ttf",255,255,255,20); sprintf(marmotscon[22], "\"Aicha\" - Hot Club de Frank"); marmots[22].load(marmotscon[22],"font.ttf",255,255,255,20); sprintf(marmotscon[23], "Original content can be found at www.digiband.org"); marmots[23].load(marmotscon[23],"font.ttf",255,255,255,20); sprintf(marmotscon[24], " "); marmots[24].load(marmotscon[24],"font.ttf",255,255,255,20); sprintf(marmotscon[25], "Game Testers:"); marmots[25].load(marmotscon[25],"font.ttf",255,0,0,20); sprintf(marmotscon[26], "Ryan Van Alstine"); marmots[26].load(marmotscon[26],"font.ttf",255,255,255,20); sprintf(marmotscon[27], "Chad \"Tanaalethan\" Grutter"); marmots[27].load(marmotscon[27],"font.ttf",255,255,255,20); sprintf(marmotscon[28], "\"BLueSS\""); marmots[28].load(marmotscon[28],"font.ttf",255,255,255,20); sprintf(marmotscon[29], "Susan Mumma"); marmots[29].load(marmotscon[29],"font.ttf",255,255,255,20); sprintf(marmotscon[30], " "); marmots[30].load(marmotscon[30],"font.ttf",255,255,255,20); sprintf(marmotscon[31], "Special Thanks:"); marmots[31].load(marmotscon[31],"font.ttf",255,0,0,20); sprintf(marmotscon[32], "Sam Latinga for Creating SDL"); marmots[32].load(marmotscon[32],"font.ttf",255,255,255,20); sprintf(marmotscon[33], "To the Kuribo Shoe for being able to stomp Spineys"); marmots[33].load(marmotscon[33],"font.ttf",255,255,255,20); sprintf(marmotscon[34], "The Computer Club of WMU - For putting up with me while making this game"); marmots[34].load(marmotscon[34],"font.ttf",255,255,255,20); sprintf(marmotscon[35], " "); marmots[35].load(marmotscon[35],"font.ttf",255,255,255,20); sprintf(marmotscon[36], "And to all of you for supporting our game"); marmots[36].load(marmotscon[36],"font.ttf",255,255,255,20); } for (int a=0;a<parts;a++){ pary[a]+=3; if (pary[a]>800){ pary[a]=0; } parx[a]=int( (double)pary[a]*lspeed[a] ) + 512; if (color[a]==0) draw_quad3(0,parx[a],pary[a],-8000+(a*10),size[a],size[a],255,255,255,255,0,int(scroll*5.0)+20,50); if (color[a]==1) draw_quad3(0,parx[a],pary[a],-8000+(a*10),size[a],size[a],255,0,0,255,0,int(scroll*5.0)+40,50); if (color[a]==2) draw_quad3(0,parx[a],pary[a],-8000+(a*10),size[a],size[a],0,255,0,255,0,int(scroll*5.0)+60,50); if (color[a]==3) draw_quad3(0,parx[a],pary[a],-8000+(a*10),size[a],size[a],0,0,255,255,0,int(scroll*5.0)+80,50); if (color[a]==4) draw_quad3(0,parx[a],pary[a],-8000+(a*10),size[a],size[a],255,255,0,255,0,int(scroll*5.0)+100,50); if (color[a]==5) draw_quad3(0,parx[a],pary[a],-8000+(a*10),size[a],size[a],255,0,255,255,0,int(scroll*5.0)+120,50); if (color[a]==6) draw_quad3(0,parx[a],pary[a],-8000+(a*10),size[a],size[a],0,255,255,255,0,int(scroll*5.0),50); if (color[a]==7) draw_quad3(0,parx[a],pary[a],-8000+(a*10),size[a],size[a],255,255,255,255,0,0-int(scroll*5.0)+20,50); if (color[a]==8) draw_quad3(0,parx[a],pary[a],-8000+(a*10),size[a],size[a],255,255,255,255,0,int(scroll*5.0)+140,50); if (color[a]==9) draw_quad3(0,parx[a],pary[a],-8000+(a*10),size[a],size[a],255,255,255,255,0,0-int(scroll*5.0)+160,50); } for (int a=0;a<creds;a++){ marmots[a].draw(52,-2-(24*a)+int(scroll),-10,255,0,0,0); marmots[a].draw(50,0-(24*a)+int(scroll),0); } draw_quad(0,170,-1014+int(scroll),9000,150,68,255,255,255,255,0,0,72); draw_quad(0,468,-1014+int(scroll),9000,138,75,255,255,255,255,0,0,73); tyfp.draw(733,652,100); if (drummode){ dmtscoren.draw(733,632,100); dmtscore2.draw(733,579,50); dmtscore1.draw(738,584,100); } if (guitar1mode){ g1tscoren.draw(733,432,100); g1tscore2.draw(733,379,50); g1tscore1.draw(738,384,100); } if (guitar2mode){ g2tscoren.draw(733,232,100); g2tscore2.draw(733,179,50); g2tscore1.draw(738,184,100); } //counter if (arcademode){ if (menucountertime>0){ static long timer=0; if (currscreen!=prevscreen) timer=SDL_GetTicks(); int timeleft=int(double(99)-((double(SDL_GetTicks())-double(timer))/1000.0)); char disptime[10]; sprintf(disptime, "%i", timeleft); static drawtext timerdisp; timerdisp.load(disptime,"font.ttf",255,255,255,uivars.timer_s); draw_quad(0,27,743,9800,25,25,255,255,255,255,0,0,66); if (timeleft>5){ timerdisp.draw(uivars.timer_x-(timerdisp.width/2),uivars.timer_y-(timerdisp.height/2),9900,255,255,255,255,false,true); }else{ if (timeleft==5)playsound(17,"timer.wav"); timerdisp.draw(uivars.timer_x-(timerdisp.width/2),uivars.timer_y-(timerdisp.height/2),9900,255,128,128,255,true,true); } if (timeleft==0){ nextscreen=1; screenfaddingout=true; screenchangenow=false; screenfaddingin=false; } } } highscore(); }
void newgame() { char d; short i; running = 1; nbullets = cmax / 2; nbugs = 5; if(getlives()) lives = getlives(); else { int fl = senddiff(); if(fl == 1) lives = 15; else if(fl == 2) lives = 10; else if(fl == 3) lives = 8; } if(lives == 0) lives = 15; // lives = 5;//Kitni baar takraye then game over score = 0; level = 25; levels = 1; /*arrow.r and .c are positions of the gun on teh window rows and colmsms*/ arrow.r = rmax / 2; arrow.c = cmax - 3; arrow.w = 3;//width arrow.h = 7;//height arrow.str = " * \n" " ** \n" "*** \n" " \n" "*** \n" " ** \n" " * \n"; bullets = malloc(nbullets * sizeof(object)); for (i = 0; i < nbullets; i++) { newbullet(&bullets[i], 0, 0); } bugs = malloc(nbugs * sizeof(object)); for (i = 0; i < nbugs; i++) { newbug(&bugs[i]); } drawmessage("SEGFAULT SHOOTER", -3); drawmessage("Stop the SEGFAULTS from getting past you", -1); drawmessage("Arrow keys to move, space to shoot", 0); drawmessage("Q to exit", 1); drawmessage("Anything else to start", 2); d = getch(); if (d == 'q') { return; } /*Enables the keyboard arrow keys*/ pthread_t pth; pthread_create(&pth, NULL, input, "get keys"); game(); pthread_cancel(pth); clear(); /* This is printed on the window when game is over*/ drawmessage("Game Over", -1); char string[10] = {'\0'}; sprintf(string, "%d", score); drawmessage(string, 0); drawmessage("Return to continue", 2); while ((d = getch()) && d != '\n') if (d == 'q') return; clear(); highscore(); clear(); highscores(); while ((d = getch()) && d != '\n') if (d == 'q') return; }