summaryrefslogtreecommitdiff
authorimm <imm>2002-09-22 18:30:29 (UTC)
committer imm <imm>2002-09-22 18:30:29 (UTC)
commit4904161b6b043e1397db4affd7930fd999ff742e (patch) (unidiff)
treebb46b289fb71af969cf48810c1795ad023252bf9
parentf8aeb3c2e6b32600329ebbaeb0b4b7a2f371eca2 (diff)
downloadopie-4904161b6b043e1397db4affd7930fd999ff742e.zip
opie-4904161b6b043e1397db4affd7930fd999ff742e.tar.gz
opie-4904161b6b043e1397db4affd7930fd999ff742e.tar.bz2
better ?
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/kpacman/referee.cpp18
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
@@ -537,401 +537,387 @@ void Referee::confMisc(bool defGroup)
537 537
538 if (mapDirectory.left(1) != "/" && mapDirectory.left(1) != "~") 538 if (mapDirectory.left(1) != "/" && mapDirectory.left(1) != "~")
539 mapDirectory.insert(0, "maps/"); 539 mapDirectory.insert(0, "maps/");
540 if (mapDirectory.right(1) != "/") 540 if (mapDirectory.right(1) != "/")
541 mapDirectory.append("/"); 541 mapDirectory.append("/");
542 } 542 }
543 543
544 if (defGroup || cfg->hasKey("MapName")) 544 if (defGroup || cfg->hasKey("MapName"))
545 fillStrList(mapName, cfg->readEntry("MapName", "map"), maxLevel+1); 545 fillStrList(mapName, cfg->readEntry("MapName", "map"), maxLevel+1);
546 546
547 if (defGroup || cfg->hasKey("MonsterIQ")) 547 if (defGroup || cfg->hasKey("MonsterIQ"))
548 fillArray(monsterIQ, cfg->readEntry("MonsterIQ", "0,170,180,170,180,170,180"), maxLevel+1); 548 fillArray(monsterIQ, cfg->readEntry("MonsterIQ", "0,170,180,170,180,170,180"), maxLevel+1);
549 if (defGroup || cfg->hasKey("FruitIQ")) 549 if (defGroup || cfg->hasKey("FruitIQ"))
550 fillArray(fruitIQ, cfg->readEntry("FruitIQ", "0,170,180,170,180,170,180"), maxLevel+1); 550 fillArray(fruitIQ, cfg->readEntry("FruitIQ", "0,170,180,170,180,170,180"), maxLevel+1);
551 if (defGroup || cfg->hasKey("FruitIndex")) 551 if (defGroup || cfg->hasKey("FruitIndex"))
552 fillArray(fruitIndex, cfg->readEntry("FruitIndex", "0"), maxLevel+1); 552 fillArray(fruitIndex, cfg->readEntry("FruitIndex", "0"), maxLevel+1);
553 APP_CONFIG_END( cfg ); 553 APP_CONFIG_END( cfg );
554} 554}
555 555
556void Referee::confTiming(bool defGroup) 556void Referee::confTiming(bool defGroup)
557{ 557{
558 APP_CONFIG_BEGIN( cfg ); 558 APP_CONFIG_BEGIN( cfg );
559 if (defGroup || cfg->hasKey("SpeedMS")) 559 if (defGroup || cfg->hasKey("SpeedMS"))
560 fillArray(speed, cfg->readEntry("SpeedMS", "20"), maxLevel+1); 560 fillArray(speed, cfg->readEntry("SpeedMS", "20"), maxLevel+1);
561 if (defGroup || cfg->hasKey("PacmanTicks")) 561 if (defGroup || cfg->hasKey("PacmanTicks"))
562 fillArray(pacmanTicks,cfg->readEntry("PacmanTicks", "3"), maxLevel+1); 562 fillArray(pacmanTicks,cfg->readEntry("PacmanTicks", "3"), maxLevel+1);
563 if (defGroup || cfg->hasKey("RemTicks")) 563 if (defGroup || cfg->hasKey("RemTicks"))
564 fillArray(remTicks, cfg->readEntry("RemTicks", "1"), maxLevel+1); 564 fillArray(remTicks, cfg->readEntry("RemTicks", "1"), maxLevel+1);
565 if (defGroup || cfg->hasKey("DangerousTicks")) 565 if (defGroup || cfg->hasKey("DangerousTicks"))
566 fillArray(dangerousTicks, cfg->readEntry("DangerousTicks", "3"), maxLevel+1); 566 fillArray(dangerousTicks, cfg->readEntry("DangerousTicks", "3"), maxLevel+1);
567 if (defGroup || cfg->hasKey("HarmlessTicks")) 567 if (defGroup || cfg->hasKey("HarmlessTicks"))
568 fillArray(harmlessTicks, cfg->readEntry("HarmlessTicks", "7,6,,5,,4"), maxLevel+1); 568 fillArray(harmlessTicks, cfg->readEntry("HarmlessTicks", "7,6,,5,,4"), maxLevel+1);
569 if (defGroup || cfg->hasKey("HarmlessDurationTicks")) 569 if (defGroup || cfg->hasKey("HarmlessDurationTicks"))
570 fillArray(harmlessDurTicks, cfg->readEntry("HarmlessDurationTicks", "375,,,300,,250,200,150"), maxLevel+1); 570 fillArray(harmlessDurTicks, cfg->readEntry("HarmlessDurationTicks", "375,,,300,,250,200,150"), maxLevel+1);
571 if (defGroup || cfg->hasKey("HarmlessWarningTicks")) 571 if (defGroup || cfg->hasKey("HarmlessWarningTicks"))
572 fillArray(harmlessWarnTicks, cfg->readEntry("HarmlessWarningTicks", "135"), maxLevel+1); 572 fillArray(harmlessWarnTicks, cfg->readEntry("HarmlessWarningTicks", "135"), maxLevel+1);
573 if (defGroup || cfg->hasKey("ArrestTicks")) 573 if (defGroup || cfg->hasKey("ArrestTicks"))
574 fillArray(arrestTicks, cfg->readEntry("ArrestTicks", "6"), maxLevel+1); 574 fillArray(arrestTicks, cfg->readEntry("ArrestTicks", "6"), maxLevel+1);
575 if (defGroup || cfg->hasKey("ArrestDurationTicks")) 575 if (defGroup || cfg->hasKey("ArrestDurationTicks"))
576 fillArray(arrestDurTicks, cfg->readEntry("ArrestDurationTicks", "200,,,150"), maxLevel+1); 576 fillArray(arrestDurTicks, cfg->readEntry("ArrestDurationTicks", "200,,,150"), maxLevel+1);
577 if (defGroup || cfg->hasKey("FruitTicks")) 577 if (defGroup || cfg->hasKey("FruitTicks"))
578 fillArray(fruitTicks, cfg->readEntry("FruitTicks", "7,6,,5,,4"), maxLevel+1); 578 fillArray(fruitTicks, cfg->readEntry("FruitTicks", "7,6,,5,,4"), maxLevel+1);
579 if (defGroup || cfg->hasKey("FruitAppearsTicks")) 579 if (defGroup || cfg->hasKey("FruitAppearsTicks"))
580 fillArray(fruitAppearsTicks, cfg->readEntry("FruitAppearsTicks", "1000,,1500,2000,2500,3000,3500,4000"), maxLevel+1); 580 fillArray(fruitAppearsTicks, cfg->readEntry("FruitAppearsTicks", "1000,,1500,2000,2500,3000,3500,4000"), maxLevel+1);
581 if (defGroup || cfg->hasKey("FruitDurationTicks")) 581 if (defGroup || cfg->hasKey("FruitDurationTicks"))
582 fillArray(fruitDurTicks, cfg->readEntry("FruitDurationTicks", "500,,,400,350,300,,250,200,150"), maxLevel+1); 582 fillArray(fruitDurTicks, cfg->readEntry("FruitDurationTicks", "500,,,400,350,300,,250,200,150"), maxLevel+1);
583 if (defGroup || cfg->hasKey("FruitScoreDurationTicks")) 583 if (defGroup || cfg->hasKey("FruitScoreDurationTicks"))
584 fillArray(fruitScoreDurTicks, cfg->readEntry("FruitScoreDurationTicks", "150"), maxLevel+1); 584 fillArray(fruitScoreDurTicks, cfg->readEntry("FruitScoreDurationTicks", "150"), maxLevel+1);
585 585
586 if (defGroup || cfg->hasKey("MonsterScoreDurationMS")) 586 if (defGroup || cfg->hasKey("MonsterScoreDurationMS"))
587 monsterScoreDurMS = cfg->readNumEntry("MonsterScoreDurationMS", 1000); 587 monsterScoreDurMS = cfg->readNumEntry("MonsterScoreDurationMS", 1000);
588 if (defGroup || cfg->hasKey("PlayerDurationMS")) 588 if (defGroup || cfg->hasKey("PlayerDurationMS"))
589 playerDurMS = cfg->readNumEntry("PlayerDurationMS", 3000); 589 playerDurMS = cfg->readNumEntry("PlayerDurationMS", 3000);
590 if (defGroup || cfg->hasKey("ReadyDurationMS")) 590 if (defGroup || cfg->hasKey("ReadyDurationMS"))
591 readyDurMS = cfg->readNumEntry("ReadyDurationMS", 2000); 591 readyDurMS = cfg->readNumEntry("ReadyDurationMS", 2000);
592 if (defGroup || cfg->hasKey("GameOverDurationMS")) 592 if (defGroup || cfg->hasKey("GameOverDurationMS"))
593 gameOverDurMS = cfg->readNumEntry("GameOverDurationMS", 3000); 593 gameOverDurMS = cfg->readNumEntry("GameOverDurationMS", 3000);
594 if (defGroup || cfg->hasKey("AfterPauseMS")) 594 if (defGroup || cfg->hasKey("AfterPauseMS"))
595 afterPauseMS = cfg->readNumEntry("AfterPauseMS", 1000); 595 afterPauseMS = cfg->readNumEntry("AfterPauseMS", 1000);
596 if (defGroup || cfg->hasKey("DyingPreAnimationMS")) 596 if (defGroup || cfg->hasKey("DyingPreAnimationMS"))
597 dyingPreAnimationMS = cfg->readNumEntry("DyingPreAnimationMS", 1000); 597 dyingPreAnimationMS = cfg->readNumEntry("DyingPreAnimationMS", 1000);
598 if (defGroup || cfg->hasKey("DyingAnimationMS")) 598 if (defGroup || cfg->hasKey("DyingAnimationMS"))
599 dyingAnimationMS = cfg->readNumEntry("DyingAnimationMS", 100); 599 dyingAnimationMS = cfg->readNumEntry("DyingAnimationMS", 100);
600 if (defGroup || cfg->hasKey("DyingPostAnimationMS")) 600 if (defGroup || cfg->hasKey("DyingPostAnimationMS"))
601 dyingPostAnimationMS = cfg->readNumEntry("DyingPostAnimationMS", 500); 601 dyingPostAnimationMS = cfg->readNumEntry("DyingPostAnimationMS", 500);
602 if (defGroup || cfg->hasKey("IntroAnimationMS")) 602 if (defGroup || cfg->hasKey("IntroAnimationMS"))
603 introAnimationMS = cfg->readNumEntry("IntroAnimationMS", 800); 603 introAnimationMS = cfg->readNumEntry("IntroAnimationMS", 800);
604 if (defGroup || cfg->hasKey("IntroPostAnimationMS")) 604 if (defGroup || cfg->hasKey("IntroPostAnimationMS"))
605 introPostAnimationMS = cfg->readNumEntry("IntroPostAnimationMS", 1000); 605 introPostAnimationMS = cfg->readNumEntry("IntroPostAnimationMS", 1000);
606 if (defGroup || cfg->hasKey("LevelUpPreAnimationMS")) 606 if (defGroup || cfg->hasKey("LevelUpPreAnimationMS"))
607 levelUpPreAnimationMS = cfg->readNumEntry("LevelUpPreAnimationMS", 2000); 607 levelUpPreAnimationMS = cfg->readNumEntry("LevelUpPreAnimationMS", 2000);
608 if (defGroup || cfg->hasKey("LevelUpAnimationMS")) 608 if (defGroup || cfg->hasKey("LevelUpAnimationMS"))
609 levelUpAnimationMS = cfg->readNumEntry("LevelUpAnimationMS", 2000); 609 levelUpAnimationMS = cfg->readNumEntry("LevelUpAnimationMS", 2000);
610 if (defGroup || cfg->hasKey("EnergizerAnimationMS")) 610 if (defGroup || cfg->hasKey("EnergizerAnimationMS"))
611 energizerAnimationMS = cfg->readNumEntry("EnergizerAnimationMS", 200); 611 energizerAnimationMS = cfg->readNumEntry("EnergizerAnimationMS", 200);
612 APP_CONFIG_END( cfg ); 612 APP_CONFIG_END( cfg );
613} 613}
614 614
615void Referee::confScoring(bool defGroup) 615void Referee::confScoring(bool defGroup)
616{ 616{
617 APP_CONFIG_BEGIN( cfg ); 617 APP_CONFIG_BEGIN( cfg );
618 if (defGroup || cfg->hasKey("PointScore")) 618 if (defGroup || cfg->hasKey("PointScore"))
619 pointScore = cfg->readNumEntry("PointScore", 10); 619 pointScore = cfg->readNumEntry("PointScore", 10);
620 if (defGroup || cfg->hasKey("EnergizerScore")) 620 if (defGroup || cfg->hasKey("EnergizerScore"))
621 energizerScore = cfg->readNumEntry("EnergizerScore", 50); 621 energizerScore = cfg->readNumEntry("EnergizerScore", 50);
622 if (defGroup || cfg->hasKey("FruitScore")) 622 if (defGroup || cfg->hasKey("FruitScore"))
623 fillArray(fruitScore, cfg->readEntry("FruitScore", "100,300,500,,700,,1000,,2000,,3000,,5000"), maxLevel+1); 623 fillArray(fruitScore, cfg->readEntry("FruitScore", "100,300,500,,700,,1000,,2000,,3000,,5000"), maxLevel+1);
624 if (defGroup || cfg->hasKey("MonsterScore")) 624 if (defGroup || cfg->hasKey("MonsterScore"))
625 fillArray(monsterScore, cfg->readEntry("MonsterScore", "200,400,800,1600"), 4); 625 fillArray(monsterScore, cfg->readEntry("MonsterScore", "200,400,800,1600"), 4);
626 if (defGroup || cfg->hasKey("ExtraLifeScore")) 626 if (defGroup || cfg->hasKey("ExtraLifeScore"))
627 fillArray(extraLifeScore, cfg->readEntry("ExtraLifeScore", "10000"), -1); 627 fillArray(extraLifeScore, cfg->readEntry("ExtraLifeScore", "10000"), -1);
628 APP_CONFIG_END( cfg ); 628 APP_CONFIG_END( cfg );
629} 629}
630 630
631void Referee::confScheme() 631void Referee::confScheme()
632{ 632{
633 APP_CONFIG_BEGIN( cfg ); 633 APP_CONFIG_BEGIN( cfg );
634 SAVE_CONFIG_GROUP( cfg, oldgroup ); 634 SAVE_CONFIG_GROUP( cfg, oldgroup );
635 QString newgroup; 635 QString newgroup;
636 636
637 // if not set, read mode and scheme from the configfile 637 // if not set, read mode and scheme from the configfile
638 if (mode == -1 && scheme == -1) { 638 if (mode == -1 && scheme == -1) {
639 scheme = cfg->readNumEntry("Scheme", -1); 639 scheme = cfg->readNumEntry("Scheme", -1);
640 mode = cfg->readNumEntry("Mode", -1); 640 mode = cfg->readNumEntry("Mode", -1);
641 641
642 // if mode is not set in the defGroup-group, lookup the scheme group 642 // if mode is not set in the defGroup-group, lookup the scheme group
643 if (scheme != -1 || mode == -1) { 643 if (scheme != -1 || mode == -1) {
644 newgroup.sprintf("Scheme %d", scheme); 644 newgroup.sprintf("Scheme %d", scheme);
645 cfg->setGroup(newgroup); 645 cfg->setGroup(newgroup);
646 646
647 mode = cfg->readNumEntry("Mode", -1); 647 mode = cfg->readNumEntry("Mode", -1);
648 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 648 RESTORE_CONFIG_GROUP( cfg, oldgroup );
649 } 649 }
650 } 650 }
651 651
652 confLevels(); 652 confLevels();
653 653
654 if (mode != -1) { 654 if (mode != -1) {
655 newgroup.sprintf("Mode %d", mode); 655 newgroup.sprintf("Mode %d", mode);
656 cfg->setGroup(newgroup); 656 cfg->setGroup(newgroup);
657 657
658 confLevels(FALSE); 658 confLevels(FALSE);
659 } 659 }
660 660
661 if (scheme != -1) { 661 if (scheme != -1) {
662 newgroup.sprintf("Scheme %d", scheme); 662 newgroup.sprintf("Scheme %d", scheme);
663 cfg->setGroup(newgroup); 663 cfg->setGroup(newgroup);
664 664
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
698void Referee::setScheme(int Scheme, int Mode, Bitfont *font) 698void 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
726void Referee::keyPressEvent( QKeyEvent *k ) 726void 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
775void Referee::score(int p) 761void 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
796void Referee::eaten() 782void 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),
810 pix->rect(pacman->position(), MonsterScorePix, monstersEaten-1))); 796 pix->rect(pacman->position(), MonsterScorePix, monstersEaten-1)));
811 797
812 if (--timerCount > 0) 798 if (--timerCount > 0)
813 QTimer::singleShot( monsterScoreDurMS, this, SLOT(eaten())); 799 QTimer::singleShot( monsterScoreDurMS, this, SLOT(eaten()));
814 else { 800 else {
815 for (Monster *m = monsters->first(); m != 0; m = monsters->next()) 801 for (Monster *m = monsters->first(); m != 0; m = monsters->next())
816 if (m && m->direction() == X && !gameState.testBit(Introducing)) 802 if (m && m->direction() == X && !gameState.testBit(Introducing))
817 m->setDirection(N); 803 m->setDirection(N);
818 if (monstersEaten != 4 || !gameState.testBit(Introducing)) 804 if (monstersEaten != 4 || !gameState.testBit(Introducing))
819 QTimer::singleShot( monsterScoreDurMS, this, SLOT(start())); 805 QTimer::singleShot( monsterScoreDurMS, this, SLOT(start()));
820 } 806 }
821} 807}
822 808
823void Referee::toggleHallOfFame() 809void Referee::toggleHallOfFame()
824{ 810{
825 gameState.toggleBit(HallOfFame); 811 gameState.toggleBit(HallOfFame);
826} 812}
827 813
828void Referee::hallOfFame() 814void Referee::hallOfFame()
829{ 815{
830 if (gameState.testBit(HallOfFame)) // If the HallOfFame is switched on manually, toggle the 816 if (gameState.testBit(HallOfFame)) // If the HallOfFame is switched on manually, toggle the
831 toggleHallOfFame(); // bit twice. 817 toggleHallOfFame(); // bit twice.
832 818
833 emit setLevel(0); // Clear status display for hall of fame 819 emit setLevel(0); // Clear status display for hall of fame
834 emit setScore(level, 0); 820 emit setScore(level, 0);
835 emit forcedHallOfFame(TRUE); 821 emit forcedHallOfFame(TRUE);
836} 822}
837 823
838void Referee::pause() 824void Referee::pause()
839{ 825{
840 static int pausedTimer = 0; 826 static int pausedTimer = 0;
841 827
842 if (!gameState.testBit(Paused)) { 828 if (!gameState.testBit(Paused)) {
843 pausedTimer = gameTimer; 829 pausedTimer = gameTimer;
844 stop(); 830 stop();
845 stopEnergizer(); 831 stopEnergizer();
846 gameState.setBit(Paused); 832 gameState.setBit(Paused);
847 repaint(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, tr("PAUSED")), FALSE); 833 repaint(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, tr("PAUSED")), FALSE);
848 } else { 834 } else {
849 gameState.clearBit(Paused); 835 gameState.clearBit(Paused);
850 repaint(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, tr("PAUSED")), FALSE); 836 repaint(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, tr("PAUSED")), FALSE);
851 if (pausedTimer) { 837 if (pausedTimer) {
852 pausedTimer = 0; 838 pausedTimer = 0;
853 start(); 839 start();
854 } 840 }
855 } 841 }
856 emit togglePaused(); 842 emit togglePaused();
857} 843}
858 844
859void Referee::intro() 845void Referee::intro()
860{ 846{
861 stop(); 847 stop();
862 stopEnergizer(); 848 stopEnergizer();
863 bool paused = gameState.testBit(Paused); 849 bool paused = gameState.testBit(Paused);
864 850
865 gameState.fill(FALSE); 851 gameState.fill(FALSE);
866 gameState.setBit(Introducing); 852 gameState.setBit(Introducing);
867 gameState.setBit(Init); 853 gameState.setBit(Init);
868 854
869 if (paused) 855 if (paused)
870 gameState.setBit(Paused); 856 gameState.setBit(Paused);
871 857
872 level = 0; 858 level = 0;
873 emit setLevel(level); 859 emit setLevel(level);
874 860
875 board->init(Intro); 861 board->init(Intro);
876 pix->setLevel(level); 862 pix->setLevel(level);
877 863
878 initPacman(); 864 initPacman();
879 initFruit(); 865 initFruit();
880 initMonsters(); 866 initMonsters();
881 initEnergizers(); 867 initEnergizers();
882 868
883 repaint(); 869 repaint();
884 870
885 monstersEaten = 0; 871 monstersEaten = 0;
886 timerCount = 0; 872 timerCount = 0;
887 introPlay(); 873 introPlay();
888} 874}
889 875
890void Referee::introMonster(int id) 876void Referee::introMonster(int id)
891{ 877{
892 Monster *m = new Monster(board, id); 878 Monster *m = new Monster(board, id);
893 879
894 m->setPosition((10+id*6)*BoardWidth+10); 880 m->setPosition((10+id*6)*BoardWidth+10);
895 m->setDirection(E); 881 m->setDirection(E);
896 m->setDangerous(dangerousTicks[level], monsterIQ[level]); 882 m->setDangerous(dangerousTicks[level], monsterIQ[level]);
897 m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix)); 883 m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix));
898 884
899 if (m->body() != -1) 885 if (m->body() != -1)
900 pix->draw(m->position(), RoomPix, MonsterPix, m->body()); 886 pix->draw(m->position(), RoomPix, MonsterPix, m->body());
901 if (m->eyes() != -1) 887 if (m->eyes() != -1)
902 pix->draw(m->position(), RoomPix, EyesPix, m->eyes()); 888 pix->draw(m->position(), RoomPix, EyesPix, m->eyes());
903 889
904 repaint(pix->rect(m->position(), MonsterPix), FALSE); 890 repaint(pix->rect(m->position(), MonsterPix), FALSE);
905 m->setPosition(OUT); 891 m->setPosition(OUT);
906} 892}
907 893
908void Referee::introPaint(int t) 894void Referee::introPaint(int t)
909{ 895{
910 QString pts; 896 QString pts;
911 897
912 switch (t) { 898 switch (t) {
913 case 0 : repaint(pix->draw(16, 6, RoomPix, tr("CHARACTER"), WHITE, QColor(), AlignLeft), FALSE); 899 case 0 : repaint(pix->draw(16, 6, RoomPix, tr("CHARACTER"), WHITE, QColor(), AlignLeft), FALSE);
914 repaint(pix->draw(36, 6, RoomPix, tr("/"), WHITE, QColor(), AlignLeft), FALSE); 900 repaint(pix->draw(36, 6, RoomPix, tr("/"), WHITE, QColor(), AlignLeft), FALSE);
915 repaint(pix->draw(40, 6, RoomPix, tr("NICKNAME"), WHITE, QColor(), AlignLeft), FALSE); 901 repaint(pix->draw(40, 6, RoomPix, tr("NICKNAME"), WHITE, QColor(), AlignLeft), FALSE);
916 break; 902 break;
917 case 1 : introMonster(0); 903 case 1 : introMonster(0);
918 break; 904 break;
919 case 2 : repaint(pix->draw(16, 10, RoomPix, tr("-SHADOW"), RED, QColor(), AlignLeft), FALSE); 905 case 2 : repaint(pix->draw(16, 10, RoomPix, tr("-SHADOW"), RED, QColor(), AlignLeft), FALSE);
920 break; 906 break;
921 case 3 : repaint(pix->draw(38, 10, RoomPix, tr("\"BLINKY\""), RED, QColor(), AlignLeft), FALSE); 907 case 3 : repaint(pix->draw(38, 10, RoomPix, tr("\"BLINKY\""), RED, QColor(), AlignLeft), FALSE);
922 break; 908 break;
923 case 4 : introMonster(1); 909 case 4 : introMonster(1);
924 break; 910 break;
925 case 5 : repaint(pix->draw(16, 16, RoomPix, tr("-SPEEDY"), PINK, QColor(), AlignLeft), FALSE); 911 case 5 : repaint(pix->draw(16, 16, RoomPix, tr("-SPEEDY"), PINK, QColor(), AlignLeft), FALSE);
926 break; 912 break;
927 case 6 : repaint(pix->draw(38, 16, RoomPix, tr("\"PINKY\""), PINK, QColor(), AlignLeft), FALSE); 913 case 6 : repaint(pix->draw(38, 16, RoomPix, tr("\"PINKY\""), PINK, QColor(), AlignLeft), FALSE);
928 break; 914 break;
929 case 7 : introMonster(2); 915 case 7 : introMonster(2);
930 break; 916 break;
931 case 8 : repaint(pix->draw(16, 22, RoomPix, tr("-BASHFUL"), CYAN, QColor(), AlignLeft), FALSE); 917 case 8 : repaint(pix->draw(16, 22, RoomPix, tr("-BASHFUL"), CYAN, QColor(), AlignLeft), FALSE);
932 break; 918 break;
933 case 9 : repaint(pix->draw(38, 22, RoomPix, tr("\"INKY\""), CYAN, QColor(), AlignLeft), FALSE); 919 case 9 : repaint(pix->draw(38, 22, RoomPix, tr("\"INKY\""), CYAN, QColor(), AlignLeft), FALSE);
934 break; 920 break;
935 case 10 : introMonster(3); 921 case 10 : introMonster(3);
936 break; 922 break;
937 case 11 : repaint(pix->draw(16, 28, RoomPix, tr("-POKEY"), ORANGE, QColor(), AlignLeft), FALSE); 923 case 11 : repaint(pix->draw(16, 28, RoomPix, tr("-POKEY"), ORANGE, QColor(), AlignLeft), FALSE);