diff options
author | Reimar <Reimar@Leike.name> | 2014-12-04 13:46:27 +0100 |
---|---|---|
committer | Reimar <Reimar@Leike.name> | 2014-12-04 13:46:27 +0100 |
commit | c20945f800a71a90d99b1822b80fe1c35976bdf0 (patch) | |
tree | 2d65c8f1fdfbba917454cee58b188dbdcd21e462 | |
parent | d7c0925b3d7ffb1a58402c05e664966e2f8a597f (diff) | |
download | SpaceCannon-c20945f800a71a90d99b1822b80fe1c35976bdf0.tar SpaceCannon-c20945f800a71a90d99b1822b80fe1c35976bdf0.tar.gz SpaceCannon-c20945f800a71a90d99b1822b80fe1c35976bdf0.tar.bz2 SpaceCannon-c20945f800a71a90d99b1822b80fe1c35976bdf0.tar.xz SpaceCannon-c20945f800a71a90d99b1822b80fe1c35976bdf0.zip |
Added easy restart
-rw-r--r-- | JnR.cpp | 457 |
1 files changed, 247 insertions, 210 deletions
@@ -179,8 +179,11 @@ void drawCircle(SDL_Surface* screen, double x, double y, double angle, double ra | |||
179 | for(int j = 0; j <= 2*radius; ++j) | 179 | for(int j = 0; j <= 2*radius; ++j) |
180 | if(((i-radius+0.5)*(i-radius+0.5)+(j-radius+0.5)*(j-radius+0.5) <= radius*radius)) | 180 | if(((i-radius+0.5)*(i-radius+0.5)+(j-radius+0.5)*(j-radius+0.5) <= radius*radius)) |
181 | { | 181 | { |
182 | double alt = 0.90+(rand()%10000)/50000.0; | 182 | int texturkonstante = 60; |
183 | drawPixel(preBall, i,j,R*alt,G*alt,B*alt); | 183 | int alt1 = rand()%texturkonstante-texturkonstante/2; |
184 | int alt2 = rand()%texturkonstante-texturkonstante/2; | ||
185 | int alt3 = rand()%texturkonstante-texturkonstante/2; | ||
186 | drawPixel(preBall, i,j,R+alt1,G+alt2,B+alt3); | ||
184 | } | 187 | } |
185 | SDL_Rect drawpos; | 188 | SDL_Rect drawpos; |
186 | SDL_Surface* temp = preBall; | 189 | SDL_Surface* temp = preBall; |
@@ -390,12 +393,8 @@ int main() | |||
390 | difficulty = max(-50,difficulty); | 393 | difficulty = max(-50,difficulty); |
391 | if(difficulty > 100) | 394 | if(difficulty > 100) |
392 | difficulty = 100; | 395 | difficulty = 100; |
393 | //SEED | 396 | bool wantEnd = false; |
394 | srandn(2334508 + difficulty); | ||
395 | srand(2334508 + difficulty); | ||
396 | |||
397 | cout << "difficulty = " << difficulty << endl; | 397 | cout << "difficulty = " << difficulty << endl; |
398 | position_multiplier += difficulty/40.0; | ||
399 | if(SDL_Init(SDL_INIT_VIDEO) == -1) | 398 | if(SDL_Init(SDL_INIT_VIDEO) == -1) |
400 | { | 399 | { |
401 | cout << "Error: Could not initialize SDL" << endl; | 400 | cout << "Error: Could not initialize SDL" << endl; |
@@ -407,250 +406,288 @@ int main() | |||
407 | cout << "could not initialize screen" << endl; | 406 | cout << "could not initialize screen" << endl; |
408 | return 1; | 407 | return 1; |
409 | } | 408 | } |
410 | 409 | ||
411 | if(TTF_Init() == -1) | 410 | if(TTF_Init() == -1) |
412 | { | 411 | { |
413 | cout << "could not initialize True Fonts" << endl; | 412 | cout << "could not initialize True Fonts" << endl; |
414 | return 1; | 413 | return 1; |
415 | } | 414 | } |
416 | SDL_WM_SetCaption("Ballroller - v0.3", NULL); | 415 | SDL_WM_SetCaption("Ballroller - v0.3", NULL); |
417 | 416 | while(!wantEnd) | |
418 | preBall = loadBMP("blank.bmp"); | ||
419 | |||
420 | |||
421 | bool Game_Quit = false; | ||
422 | int down = 0; | ||
423 | int right = 0; | ||
424 | vector<Obstacle> obstacles; | ||
425 | obstacles.push_back(Obstacle(-50,ground_level,10,200)); | ||
426 | vector<Particle> particles; | ||
427 | bool quickquit = false; | ||
428 | for(int i = 0; i < 10*60*5; ++i) | ||
429 | { | ||
430 | Particle p = Particle(rand()%11000 - 300,ground_level + rand()%((int)(yres-ground_level)),3,255,255,255); | ||
431 | p.life = 1000; | ||
432 | p.vy = -5-rand()%30/9.0; | ||
433 | particles.push_back(p); | ||
434 | } | ||
435 | //Longest Jump: 608 | ||
436 | //Highest Jump: 150 | ||
437 | int opos = 200; | ||
438 | while(opos < 10000) | ||
439 | { | ||
440 | int blub = 4+randn()%(192+difficulty/4-4); | ||
441 | obstacles.push_back(Obstacle(opos,ground_level,blub,(196 + difficulty/4)/2-blub/2)); | ||
442 | opos += randn()%(900-4*difficulty); | ||
443 | } | ||
444 | if(hardcore) | ||
445 | for(int i = 1; i < 110; ++i) | ||
446 | { | 417 | { |
447 | Obstacle tempo = Obstacle(i*300,ground_level, 10, 10); | 418 | //SEED |
448 | tempo.vx = -60; | 419 | srandn(2334508 + difficulty); |
449 | obstacles.push_back(tempo); | 420 | srand(2334508 + difficulty); |
450 | } | ||
451 | vector<Particle> deathanimation; | ||
452 | bool lost = false; | ||
453 | long long steps = 0; | ||
454 | SDL_Rect lpos; | ||
455 | lpos.x = 100; | ||
456 | lpos.y = 10; | ||
457 | lpos.w = 300; | ||
458 | lpos.h = 20; | ||
459 | Label scoreLabel = Label("Score: " + lltostr((long long)((1+0.5*hardcore)*(highscore + x_pos*position_multiplier))), lpos); | ||
460 | double maxjumpx = 0; | ||
461 | double maxjumpy = 0; | ||
462 | double lastjumppos = 0; | ||
463 | 421 | ||
464 | while(!Game_Quit) | 422 | highscore = 1000; |
465 | { | 423 | position_multiplier = 3; |
466 | steps++; | 424 | x_pos = 0; |
467 | Uint32 start = SDL_GetTicks(); | 425 | y_pos = 0; |
468 | if(!lost) | 426 | y_vel = 0; |
469 | highscore--; | 427 | x_vel = 0; |
470 | blacken(screen); | 428 | position_multiplier += difficulty/40.0; |
471 | SDL_Event event; | 429 | preBall = loadBMP("blank.bmp"); |
472 | while(SDL_PollEvent(&event)) | 430 | |
431 | bool Game_Quit = false; | ||
432 | int down = 0; | ||
433 | int right = 0; | ||
434 | vector<Obstacle> obstacles; | ||
435 | obstacles.push_back(Obstacle(-50,ground_level,10,200)); | ||
436 | vector<Particle> particles; | ||
437 | bool quickquit = false; | ||
438 | for(int i = 0; i < 10*60*5; ++i) | ||
473 | { | 439 | { |
474 | if(event.type == SDL_QUIT) | 440 | Particle p = Particle(rand()%11000 - 300,ground_level + rand()%((int)(yres-ground_level)),3,255,255,255); |
475 | { | 441 | p.life = 1000; |
476 | Game_Quit = true; | 442 | p.vy = -5-rand()%30/9.0; |
477 | quickquit = true; | 443 | particles.push_back(p); |
478 | break; | ||
479 | } | ||
480 | } | 444 | } |
481 | Uint8 *keyState = SDL_GetKeyState(NULL); | 445 | //Longest Jump: 608 |
482 | 446 | //Highest Jump: 150 | |
483 | down = -keyState[SDLK_UP]+keyState[SDLK_DOWN]; | 447 | int opos = 200; |
484 | 448 | while(opos < 10000) | |
485 | vector<Particle> nparticles; | ||
486 | for(int i = 0; i < (int) particles.size(); ++i) | ||
487 | { | 449 | { |
488 | if(particles[i].step(1/60.0) && particles[i].y > ground_level) | 450 | int blub = 4+randn()%(192+difficulty/4-4); |
489 | { | 451 | obstacles.push_back(Obstacle(opos,ground_level,blub,(196 + difficulty/4)/2-blub/2)); |
490 | particles[i].draw(screen,x_pos-xres/4,0); | 452 | opos += randn()%(900-4*difficulty); |
491 | nparticles.push_back(particles[i]); | ||
492 | } | ||
493 | } | 453 | } |
494 | if(!(steps%300) && hardcore) | 454 | if(hardcore) |
455 | for(int i = 1; i < 110; ++i) | ||
495 | { | 456 | { |
496 | Obstacle tempo = Obstacle(110*100,ground_level, 10, 10); | 457 | Obstacle tempo = Obstacle(i*300,ground_level, 10, 10); |
497 | tempo.vx = -60; | 458 | tempo.vx = -60; |
498 | obstacles.push_back(tempo); | 459 | obstacles.push_back(tempo); |
499 | } | 460 | } |
500 | for(int i = 0; i < (int) obstacles.size(); ++i) | 461 | vector<Particle> deathanimation; |
462 | bool lost = false; | ||
463 | long long steps = 0; | ||
464 | SDL_Rect lpos; | ||
465 | lpos.x = 300; | ||
466 | lpos.y = 10; | ||
467 | lpos.w = 300; | ||
468 | lpos.h = 20; | ||
469 | Label scoreLabel = Label("Score: " + lltostr((long long)((1+0.5*hardcore)*(highscore + x_pos*position_multiplier))), lpos); | ||
470 | double maxjumpx = 0; | ||
471 | double maxjumpy = 0; | ||
472 | double lastjumppos = 0; | ||
473 | |||
474 | while(!Game_Quit) | ||
501 | { | 475 | { |
502 | obstacles[i].step(1/60.0); | 476 | steps++; |
503 | obstacles[i].draw(screen,x_pos-xres/4,0); | 477 | Uint32 start = SDL_GetTicks(); |
504 | if(!lost) | 478 | if(!lost) |
505 | if(obstacles[i].check_death(x_pos,y_pos,ball_rad)) | 479 | highscore--; |
480 | blacken(screen); | ||
481 | SDL_Event event; | ||
482 | while(SDL_PollEvent(&event)) | ||
506 | { | 483 | { |
507 | cout << "Collision: You lost the game" << endl; | 484 | if(event.type == SDL_QUIT) |
508 | cout << "Better luck next time!" << endl; | 485 | { |
509 | highscore = (int)((1+0.5*hardcore)*(highscore + x_pos*position_multiplier)); | 486 | Game_Quit = true; |
510 | scoreLabel.setCaption("Score: " + lltostr(highscore)); | 487 | quickquit = true; |
511 | cout << "Your highscore: " << highscore << endl; | 488 | wantEnd = true; |
512 | lost = true; | 489 | break; |
513 | deathanimation = makeDeathAnimation(x_pos,y_pos,ball_rad,x_vel, y_vel,1); | 490 | } |
491 | } | ||
492 | Uint8 *keyState = SDL_GetKeyState(NULL); | ||
493 | |||
494 | down = -keyState[SDLK_UP]+keyState[SDLK_DOWN]; | ||
495 | |||
496 | vector<Particle> nparticles; | ||
497 | for(int i = 0; i < (int) particles.size(); ++i) | ||
498 | { | ||
499 | if(particles[i].step(1/60.0) && particles[i].y > ground_level) | ||
500 | { | ||
501 | particles[i].draw(screen,x_pos-xres/4,0); | ||
502 | nparticles.push_back(particles[i]); | ||
503 | } | ||
504 | } | ||
505 | if(!(steps%300) && hardcore) | ||
506 | { | ||
507 | Obstacle tempo = Obstacle(110*100,ground_level, 10, 10); | ||
508 | tempo.vx = -60; | ||
509 | obstacles.push_back(tempo); | ||
510 | } | ||
511 | for(int i = 0; i < (int) obstacles.size(); ++i) | ||
512 | { | ||
513 | obstacles[i].step(1/60.0); | ||
514 | obstacles[i].draw(screen,x_pos-xres/4,0); | ||
515 | if(!lost) | ||
516 | if(obstacles[i].check_death(x_pos,y_pos,ball_rad)) | ||
517 | { | ||
518 | cout << "Collision: You lost the game" << endl; | ||
519 | cout << "Better luck next time!" << endl; | ||
520 | highscore = (int)((1+0.5*hardcore)*(highscore + x_pos*position_multiplier)); | ||
521 | scoreLabel.setCaption("Score: " + lltostr(highscore)); | ||
522 | cout << "Your highscore: " << highscore << endl; | ||
523 | lost = true; | ||
524 | deathanimation = makeDeathAnimation(x_pos,y_pos,ball_rad,x_vel, y_vel,1); | ||
525 | } | ||
526 | } | ||
527 | particles = nparticles; | ||
528 | for(int i = 0; i < 1; ++i) | ||
529 | { | ||
530 | Particle p = Particle(-300 + rand()%11001,yres,3,255,255,255); | ||
531 | p.vy = -5-rand()%30/9.0; | ||
532 | p.life = 1000; | ||
533 | particles.push_back(p); | ||
534 | } | ||
535 | if(!lost) | ||
536 | { | ||
537 | x_pos = x_pos + x_vel/60.0; | ||
538 | y_pos = y_pos + y_vel/60.0; | ||
539 | phi = phi + vphi/60.0; | ||
540 | drawCircle(screen, xres/4, fabs(yres-y_pos), phi, ball_rad, playerR, playerG, playerB); | ||
541 | scoreLabel.setCaption("Score: " + lltostr((long long)((1+0.5*hardcore)*(highscore + x_pos*position_multiplier)))); | ||
514 | } | 542 | } |
515 | } | ||
516 | particles = nparticles; | ||
517 | for(int i = 0; i < 1; ++i) | ||
518 | { | ||
519 | Particle p = Particle(-300 + rand()%11001,yres,3,255,255,255); | ||
520 | p.vy = -5-rand()%30/9.0; | ||
521 | p.life = 1000; | ||
522 | particles.push_back(p); | ||
523 | } | ||
524 | if(!lost) | ||
525 | { | ||
526 | x_pos = x_pos + x_vel/60.0; | ||
527 | y_pos = y_pos + y_vel/60.0; | ||
528 | phi = phi + vphi/60.0; | ||
529 | drawCircle(screen, xres/4, fabs(yres-y_pos), phi, ball_rad, playerR, playerG, playerB); | ||
530 | scoreLabel.setCaption("Score: " + lltostr((long long)((1+0.5*hardcore)*(highscore + x_pos*position_multiplier)))); | ||
531 | } | ||
532 | 543 | ||
533 | right = -keyState[SDLK_LEFT]+keyState[SDLK_RIGHT]; | ||
534 | if(!right) | ||
535 | { | ||
536 | right = -keyState[SDLK_LEFT]+keyState[SDLK_RIGHT]; | 544 | right = -keyState[SDLK_LEFT]+keyState[SDLK_RIGHT]; |
537 | } | 545 | if(!right) |
546 | { | ||
547 | right = -keyState[SDLK_LEFT]+keyState[SDLK_RIGHT]; | ||
548 | } | ||
538 | 549 | ||
539 | if(y_pos > ground_level+ball_rad) | 550 | if(y_pos > ground_level+ball_rad) |
540 | { | ||
541 | y_vel = y_vel*(1.0-c_r) - g/60.0; | ||
542 | x_vel = x_vel*(1.0-c_r) + right*80/60.0; | ||
543 | maxjumpy = max(maxjumpy,y_pos); | ||
544 | } | ||
545 | if(y_pos <= ground_level+ball_rad) | ||
546 | { | ||
547 | maxjumpx = max(maxjumpx,x_pos-lastjumppos); | ||
548 | lastjumppos = x_pos; | ||
549 | x_vel = x_vel*(1.0-c_r) + right*140./60.0; | ||
550 | y_pos = ground_level+ball_rad; | ||
551 | y_vel = fabs(y_vel); | ||
552 | if(down == -1) | ||
553 | y_vel += 900; | ||
554 | y_vel *= 0.25; | ||
555 | vphi = -x_vel/ball_rad; | ||
556 | } | ||
557 | if(!lost) | ||
558 | if(highscore+x_pos*position_multiplier <= 0) | ||
559 | { | ||
560 | cout << "TIMEOUT: You lost the game." << endl; | ||
561 | cout << "Better luck next time!" << endl; | ||
562 | quickquit = true; | ||
563 | Game_Quit = true; | ||
564 | deathanimation = makeDeathAnimation(x_pos,y_pos,ball_rad,x_vel, y_vel,0); | ||
565 | } | ||
566 | if(x_pos >= 10000) | ||
567 | { | ||
568 | cout << "You win the game!" << endl; | ||
569 | highscore = (int)((1+0.5*hardcore)*(highscore + x_pos*position_multiplier + win_bonus)); | ||
570 | cout << "Your highscore: " << highscore << endl; | ||
571 | scoreLabel.setCaption("Score: " + lltostr(highscore)); | ||
572 | Game_Quit = true; | ||
573 | } | ||
574 | for(int i = 0; i < xres; ++i) | ||
575 | drawPixel(screen,i,yres-ground_level,255,255,255); | ||
576 | bool animation_term = true; | ||
577 | for(int i = 0; i < (int) deathanimation.size(); ++i) | ||
578 | { | ||
579 | if(deathanimation[i].step(1/60.0)) | ||
580 | { | 551 | { |
581 | animation_term = false; | 552 | y_vel = y_vel*(1.0-c_r) - g/60.0; |
582 | deathanimation[i].draw(screen,x_pos-xres/4,0); | 553 | x_vel = x_vel*(1.0-c_r) + right*80/60.0; |
554 | maxjumpy = max(maxjumpy,y_pos); | ||
583 | } | 555 | } |
556 | if(y_pos <= ground_level+ball_rad) | ||
557 | { | ||
558 | maxjumpx = max(maxjumpx,x_pos-lastjumppos); | ||
559 | lastjumppos = x_pos; | ||
560 | x_vel = x_vel*(1.0-c_r) + right*140./60.0; | ||
561 | y_pos = ground_level+ball_rad; | ||
562 | y_vel = fabs(y_vel); | ||
563 | if(down == -1) | ||
564 | y_vel += 900; | ||
565 | y_vel *= 0.25; | ||
566 | vphi = -x_vel/ball_rad; | ||
567 | } | ||
568 | if(!lost) | ||
569 | if(highscore+x_pos*position_multiplier <= 0) | ||
570 | { | ||
571 | cout << "TIMEOUT: You lost the game." << endl; | ||
572 | cout << "Better luck next time!" << endl; | ||
573 | quickquit = true; | ||
574 | Game_Quit = true; | ||
575 | deathanimation = makeDeathAnimation(x_pos,y_pos,ball_rad,x_vel, y_vel,0); | ||
576 | } | ||
577 | if(x_pos >= 10000) | ||
578 | { | ||
579 | cout << "You win the game!" << endl; | ||
580 | highscore = (int)((1+0.5*hardcore)*(highscore + x_pos*position_multiplier + win_bonus)); | ||
581 | cout << "Your highscore: " << highscore << endl; | ||
582 | scoreLabel.setCaption("Score: " + lltostr(highscore)); | ||
583 | Game_Quit = true; | ||
584 | } | ||
585 | for(int i = 0; i < xres; ++i) | ||
586 | drawPixel(screen,i,yres-ground_level,255,255,255); | ||
587 | bool animation_term = true; | ||
588 | for(int i = 0; i < (int) deathanimation.size(); ++i) | ||
589 | { | ||
590 | if(deathanimation[i].step(1/60.0)) | ||
591 | { | ||
592 | animation_term = false; | ||
593 | deathanimation[i].draw(screen,x_pos-xres/4,0); | ||
594 | } | ||
595 | } | ||
596 | if(animation_term && lost) | ||
597 | Game_Quit = true; | ||
598 | scoreLabel.draw(screen); | ||
599 | SDL_Flip(screen); | ||
600 | Uint32 time = SDL_GetTicks()-start; | ||
601 | if(1000/60.0 - time > 0) | ||
602 | SDL_Delay(1000/60.0 - time); | ||
584 | } | 603 | } |
585 | if(animation_term && lost) | 604 | cout << "Longest Jump: " << maxjumpx << endl; |
586 | Game_Quit = true; | 605 | cout << "Highest Jump: " << maxjumpy << endl; |
587 | scoreLabel.draw(screen); | ||
588 | SDL_Flip(screen); | ||
589 | Uint32 time = SDL_GetTicks()-start; | ||
590 | if(1000/60.0 - time > 0) | ||
591 | SDL_Delay(1000/60.0 - time); | ||
592 | } | ||
593 | cout << "Longest Jump: " << maxjumpx << endl; | ||
594 | cout << "Highest Jump: " << maxjumpy << endl; | ||
595 | 606 | ||
596 | 607 | ||
597 | /*The Game has ended*/ | 608 | /*The Game has ended*/ |
598 | if(!quickquit) | 609 | if(!quickquit) |
599 | { | ||
600 | ifstream ins; | ||
601 | ins.open("highscore.dat"); | ||
602 | vector<pair<int, string> > highlist; | ||
603 | for(int i = 0; i < 10; ++i) | ||
604 | { | 610 | { |
605 | pair<int, string> temp; | 611 | ifstream ins; |
606 | ins >> temp.first; | 612 | ins.open("highscore.dat"); |
607 | if(!ins.good()) | 613 | vector<pair<int, string> > highlist; |
608 | break; | 614 | for(int i = 0; i < 10; ++i) |
609 | ins >> temp.second; | ||
610 | if(ins.good()) | ||
611 | { | 615 | { |
612 | highlist.push_back(temp); | 616 | pair<int, string> temp; |
617 | ins >> temp.first; | ||
618 | if(!ins.good()) | ||
619 | break; | ||
620 | ins >> temp.second; | ||
621 | if(ins.good()) | ||
622 | { | ||
623 | highlist.push_back(temp); | ||
624 | } | ||
625 | else | ||
626 | break; | ||
613 | } | 627 | } |
614 | else | 628 | ins.close(); |
615 | break; | ||
616 | } | ||
617 | ins.close(); | ||
618 | sort(highlist.begin(), highlist.end()); | ||
619 | if(highlist.size() < 10 || highlist[0].first < highscore) | ||
620 | { | ||
621 | cout << "Congratulations! You made a new highscore." << endl; | ||
622 | pair<int, string> youscore; | ||
623 | youscore.first = highscore; | ||
624 | youscore.second = name; | ||
625 | highlist.push_back(youscore); | ||
626 | sort(highlist.begin(), highlist.end()); | 629 | sort(highlist.begin(), highlist.end()); |
627 | ofstream ofs; | 630 | if(highlist.size() < 10 || highlist[0].first < highscore) |
628 | ofs.open("highscore.dat"); | ||
629 | if(highlist.size() == 11) | ||
630 | { | 631 | { |
631 | for(int i = 0; i < 10; ++i) | 632 | cout << "Congratulations! You made a new highscore." << endl; |
633 | pair<int, string> youscore; | ||
634 | youscore.first = highscore; | ||
635 | youscore.second = name; | ||
636 | highlist.push_back(youscore); | ||
637 | sort(highlist.begin(), highlist.end()); | ||
638 | ofstream ofs; | ||
639 | ofs.open("highscore.dat"); | ||
640 | if(highlist.size() == 11) | ||
632 | { | 641 | { |
633 | ofs << highlist[i+1].first << " " << highlist[i+1].second << endl; | 642 | for(int i = 0; i < 10; ++i) |
643 | { | ||
644 | ofs << highlist[i+1].first << " " << highlist[i+1].second << endl; | ||
645 | } | ||
634 | } | 646 | } |
635 | } | 647 | else |
636 | else | ||
637 | { | ||
638 | for(int i = 0; i < (int)highlist.size(); ++i) | ||
639 | { | 648 | { |
640 | ofs << highlist[i].first << " " << highlist[i].second << endl; | 649 | for(int i = 0; i < (int)highlist.size(); ++i) |
650 | { | ||
651 | ofs << highlist[i].first << " " << highlist[i].second << endl; | ||
652 | } | ||
641 | } | 653 | } |
642 | } | ||
643 | 654 | ||
644 | ofs.close(); | 655 | ofs.close(); |
656 | } | ||
657 | cout << "\n**HIGHSCORE**\n"; | ||
658 | for(int i = min(10,(int) highlist.size()-1); i > 0; --i) | ||
659 | { | ||
660 | cout << highlist[i].second << ": " << highlist[i].first << '\n'; | ||
661 | } | ||
662 | if(highlist.size() < 11) | ||
663 | cout << highlist[0].second << ": " << highlist[0].first << '\n'; | ||
664 | cout << endl; | ||
645 | } | 665 | } |
646 | cout << "\n**HIGHSCORE**\n"; | 666 | |
647 | for(int i = min(10,(int) highlist.size()-1); i > 0; --i) | 667 | SDL_Rect mpos; |
668 | mpos.x = 25; | ||
669 | mpos.y = 180; | ||
670 | mpos.w = 300; | ||
671 | mpos.h = 32; | ||
672 | Label message = Label("GAME OVER - Press space to restart", mpos); | ||
673 | message.draw(screen); | ||
674 | SDL_Flip(screen); | ||
675 | while(true) | ||
648 | { | 676 | { |
649 | cout << highlist[i].second << ": " << highlist[i].first << '\n'; | 677 | SDL_Event event; |
678 | SDL_PollEvent(&event); | ||
679 | Uint8 *keyState = SDL_GetKeyState(NULL); | ||
680 | if(event.type == SDL_QUIT || keyState[SDLK_ESCAPE]) | ||
681 | { | ||
682 | Game_Quit = true; | ||
683 | quickquit = true; | ||
684 | wantEnd = true; | ||
685 | break; | ||
686 | } | ||
687 | if(keyState[SDLK_SPACE]) | ||
688 | break; | ||
689 | |||
650 | } | 690 | } |
651 | if(highlist.size() < 11) | ||
652 | cout << highlist[0].second << ": " << highlist[0].first << '\n'; | ||
653 | cout << endl; | ||
654 | } | 691 | } |
655 | SDL_FreeSurface(preBall); | 692 | SDL_FreeSurface(preBall); |
656 | 693 | ||