-rw-r--r-- | noncore/games/kpacman/referee.cpp | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/noncore/games/kpacman/referee.cpp b/noncore/games/kpacman/referee.cpp index 81f331b..6d8f3fb 100644 --- a/noncore/games/kpacman/referee.cpp +++ b/noncore/games/kpacman/referee.cpp | |||
@@ -665,145 +665,131 @@ void Referee::confScheme() | |||
665 | confLevels(FALSE); | 665 | confLevels(FALSE); |
666 | } | 666 | } |
667 | 667 | ||
668 | RESTORE_CONFIG_GROUP( cfg, oldgroup ); | 668 | RESTORE_CONFIG_GROUP( cfg, oldgroup ); |
669 | 669 | ||
670 | confMisc(); | 670 | confMisc(); |
671 | confTiming(); | 671 | confTiming(); |
672 | confScoring(); | 672 | confScoring(); |
673 | 673 | ||
674 | if (mode != -1) { | 674 | if (mode != -1) { |
675 | newgroup.sprintf("Mode %d", mode); | 675 | newgroup.sprintf("Mode %d", mode); |
676 | cfg->setGroup(newgroup); | 676 | cfg->setGroup(newgroup); |
677 | 677 | ||
678 | confMisc(FALSE); | 678 | confMisc(FALSE); |
679 | confTiming(FALSE); | 679 | confTiming(FALSE); |
680 | confScoring(FALSE); | 680 | confScoring(FALSE); |
681 | } | 681 | } |
682 | 682 | ||
683 | if (scheme != -1) { | 683 | if (scheme != -1) { |
684 | newgroup.sprintf("Scheme %d", scheme); | 684 | newgroup.sprintf("Scheme %d", scheme); |
685 | cfg->setGroup(newgroup); | 685 | cfg->setGroup(newgroup); |
686 | 686 | ||
687 | confMisc(FALSE); | 687 | confMisc(FALSE); |
688 | confTiming(FALSE); | 688 | confTiming(FALSE); |
689 | confScoring(FALSE); | 689 | confScoring(FALSE); |
690 | } | 690 | } |
691 | 691 | ||
692 | fillMapName(); | 692 | fillMapName(); |
693 | 693 | ||
694 | RESTORE_CONFIG_GROUP( cfg, oldgroup ); | 694 | RESTORE_CONFIG_GROUP( cfg, oldgroup ); |
695 | APP_CONFIG_END( cfg ); | 695 | APP_CONFIG_END( cfg ); |
696 | } | 696 | } |
697 | 697 | ||
698 | void Referee::setScheme(int Scheme, int Mode, Bitfont *font) | 698 | void Referee::setScheme(int Scheme, int Mode, Bitfont *font) |
699 | { | 699 | { |
700 | mode = Mode; | 700 | mode = Mode; |
701 | scheme = Scheme; | 701 | scheme = Scheme; |
702 | 702 | ||
703 | confScheme(); | 703 | confScheme(); |
704 | 704 | ||
705 | pix->setScheme(scheme, mode, font); | 705 | pix->setScheme(scheme, mode, font); |
706 | 706 | ||
707 | pacman->setMaxPixmaps(pix->maxPixmaps(PacmanPix)); | 707 | pacman->setMaxPixmaps(pix->maxPixmaps(PacmanPix)); |
708 | fruit->setMaxPixmaps(pix->maxPixmaps(FruitPix)); | 708 | fruit->setMaxPixmaps(pix->maxPixmaps(FruitPix)); |
709 | 709 | ||
710 | for (Monster *m = monsters->first(); m != 0; m = monsters->next()) | 710 | for (Monster *m = monsters->first(); m != 0; m = monsters->next()) |
711 | if (m) | 711 | if (m) |
712 | m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix)); | 712 | m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix)); |
713 | 713 | ||
714 | for (Energizer *e = energizers->first(); e != 0; e = energizers->next()) | 714 | for (Energizer *e = energizers->first(); e != 0; e = energizers->next()) |
715 | if (e) | 715 | if (e) |
716 | e->setMaxPixmaps(pix->maxPixmaps(EnergizerPix)); | 716 | e->setMaxPixmaps(pix->maxPixmaps(EnergizerPix)); |
717 | 717 | ||
718 | if (gameState.testBit(Introducing)) | 718 | if (gameState.testBit(Introducing)) |
719 | for (int i = 0; i < (gameState.testBit(Init) ? timerCount : 15); i++) | 719 | for (int i = 0; i < (gameState.testBit(Init) ? timerCount : 15); i++) |
720 | introPaint(i); | 720 | introPaint(i); |
721 | 721 | ||
722 | setFixedSize(pix->levelPix().size()); | 722 | setFixedSize(pix->levelPix().size()); |
723 | repaint(); | 723 | repaint(); |
724 | } | 724 | } |
725 | 725 | ||
726 | void Referee::keyPressEvent( QKeyEvent *k ) | 726 | void Referee::keyPressEvent( QKeyEvent *k ) |
727 | { | 727 | { |
728 | uint key = k->key(); | 728 | uint key = k->key(); |
729 | #ifdef QWS | 729 | |
730 | // "OK" => new game | 730 | if ( !gameState.testBit(Playing) && ( key == Key_Up || key == Key_Down || key == Key_Left || key == Key_Right ) ) |
731 | if ( key == Key_F33 || key == Key_F2 || key == Key_Enter ) | ||
732 | play(); | ||
733 | else if ( !gameState.testBit(Playing) && | ||
734 | ( key == Key_Up || | ||
735 | key == Key_Down || | ||
736 | key == Key_Right || | ||
737 | key == Key_Left )) | ||
738 | play(); | 731 | play(); |
739 | // "Space" => pause | ||
740 | //else if ( key == Key_Space || key == Key_F3 ) | ||
741 | // pause(); | ||
742 | // "Menu" => hall of fame | ||
743 | //else if ( key == Key_F11 || key == Key_F4 ) | ||
744 | // toggleHallOfFame(); | ||
745 | #endif | ||
746 | 732 | ||
747 | if (gameState.testBit(Paused) || gameState.testBit(HallOfFame) || | 733 | if (gameState.testBit(Paused) || gameState.testBit(HallOfFame) || |
748 | gameState.testBit(Demonstration) || gameState.testBit(Dying) || | 734 | gameState.testBit(Demonstration) || gameState.testBit(Dying) || |
749 | gameState.testBit(Ready) || gameState.testBit(LevelDone) || | 735 | gameState.testBit(Ready) || gameState.testBit(LevelDone) || |
750 | !gameState.testBit(Playing)) | 736 | !gameState.testBit(Playing)) |
751 | return; | 737 | return; |
752 | 738 | ||
753 | if (key == UpKey) | 739 | if (key == UpKey) |
754 | pacman->setDirection(N); | 740 | pacman->setDirection(N); |
755 | else if (key == DownKey) | 741 | else if (key == DownKey) |
756 | pacman->setDirection(S); | 742 | pacman->setDirection(S); |
757 | else if (key == RightKey) | 743 | else if (key == RightKey) |
758 | pacman->setDirection(E); | 744 | pacman->setDirection(E); |
759 | else if (key == LeftKey) | 745 | else if (key == LeftKey) |
760 | pacman->setDirection(W); | 746 | pacman->setDirection(W); |
761 | 747 | ||
762 | #ifdef CHEATS | 748 | #ifdef CHEATS |
763 | else if (key == Key_L) { printf("levelUp()\n"); levelUp(); } | 749 | else if (key == Key_L) { printf("levelUp()\n"); levelUp(); } |
764 | else if (key == Key_F) { printf("fruit->move(TRUE)\n"); fruit->move(TRUE); repaint(FALSE); } | 750 | else if (key == Key_F) { printf("fruit->move(TRUE)\n"); fruit->move(TRUE); repaint(FALSE); } |
765 | else if (key == Key_E) { printf("setLifes(++lifes)\n"); emit setLifes(++lifes); } | 751 | else if (key == Key_E) { printf("setLifes(++lifes)\n"); emit setLifes(++lifes); } |
766 | #endif | 752 | #endif |
767 | 753 | ||
768 | else { | 754 | else { |
769 | k->ignore(); | 755 | k->ignore(); |
770 | return; | 756 | return; |
771 | } | 757 | } |
772 | k->accept(); | 758 | k->accept(); |
773 | } | 759 | } |
774 | 760 | ||
775 | void Referee::score(int p) | 761 | void Referee::score(int p) |
776 | { | 762 | { |
777 | if (!gameState.testBit(Playing)) | 763 | if (!gameState.testBit(Playing)) |
778 | return; | 764 | return; |
779 | 765 | ||
780 | if ((points += p) < 0) | 766 | if ((points += p) < 0) |
781 | points = 0; | 767 | points = 0; |
782 | 768 | ||
783 | emit setPoints(points); | 769 | emit setPoints(points); |
784 | 770 | ||
785 | if (points >= nextExtraLifeScore) { | 771 | if (points >= nextExtraLifeScore) { |
786 | emit setLifes(++lifes); | 772 | emit setLifes(++lifes); |
787 | if (extraLifeScoreIndex < (int) extraLifeScore.size()-1) | 773 | if (extraLifeScoreIndex < (int) extraLifeScore.size()-1) |
788 | extraLifeScoreIndex++; | 774 | extraLifeScoreIndex++; |
789 | if (extraLifeScore[extraLifeScoreIndex] < 0) | 775 | if (extraLifeScore[extraLifeScoreIndex] < 0) |
790 | nextExtraLifeScore = extraLifeScore[extraLifeScoreIndex] * -1; | 776 | nextExtraLifeScore = extraLifeScore[extraLifeScoreIndex] * -1; |
791 | else | 777 | else |
792 | nextExtraLifeScore += extraLifeScore[extraLifeScoreIndex]; | 778 | nextExtraLifeScore += extraLifeScore[extraLifeScoreIndex]; |
793 | } | 779 | } |
794 | } | 780 | } |
795 | 781 | ||
796 | void Referee::eaten() | 782 | void Referee::eaten() |
797 | { | 783 | { |
798 | if (gameState.testBit(Ready)) | 784 | if (gameState.testBit(Ready)) |
799 | return; | 785 | return; |
800 | 786 | ||
801 | stop(); | 787 | stop(); |
802 | 788 | ||
803 | if (monstersEaten < 4) | 789 | if (monstersEaten < 4) |
804 | monstersEaten++; | 790 | monstersEaten++; |
805 | 791 | ||
806 | gameState.setBit(Scoring); | 792 | gameState.setBit(Scoring); |
807 | score(monsterScore[monstersEaten-1]); | 793 | score(monsterScore[monstersEaten-1]); |
808 | 794 | ||
809 | repaint(pix->rect(pix->rect(pacman->position(), MonsterPix), | 795 | repaint(pix->rect(pix->rect(pacman->position(), MonsterPix), |