home *** CD-ROM | disk | FTP | other *** search
/ C++ Games Programming / CPPGAMES.ISO / thx / demos / shootout / build / options.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-05  |  1.7 KB  |  107 lines

  1. // --------- options.cpp
  2.  
  3. #include "options.h"
  4.  
  5. CUELIST(Options)
  6.     KEYSTROKE('\r', on_escape)
  7.     KEYSTROKE(ESC,  on_escape)
  8.     KEYSTROKE('+',  OnPlus)
  9.     KEYSTROKE('-',  OnMinus)
  10. ENDCUELIST
  11.  
  12.  
  13. Options::Options() : SceneDirector("options.pcx", NoTransition)
  14. {
  15.     fletchers = new Digit(1);
  16.     aim = new Digit(1);
  17.     resurrections = new Digit(6);
  18.     pointer = new Pointer(37, 96, 154);
  19.     buttons = new Buttons;
  20. }
  21.  
  22. Options::~Options()
  23. {
  24.     delete buttons;
  25.     delete pointer;
  26.     delete resurrections;
  27.     delete aim;
  28.     delete fletchers;
  29. }
  30.  
  31. void Options::display()
  32. {
  33.     SceneDirector::display();
  34.     fletchers->setxy(85,46);
  35.     fletchers->appear();
  36.     aim->setxy(85,105);
  37.     aim->appear();
  38.     resurrections->setxy(85,162);
  39.     resurrections->appear();
  40.     buttons->setxy(55,1);
  41.     pointer->appear();
  42. }
  43. Digit *Options::currdigit(int& lo, int &hi)
  44. {
  45.     switch (pointer->getselection())    {
  46.         case 0:
  47.             lo = 1;
  48.             hi = 3;
  49.             return fletchers;
  50.         case 1:
  51.             lo = 0;
  52.             hi = 5;
  53.             return aim;
  54.         case 2:
  55.             lo = 1;
  56.             hi = 6;
  57.             return resurrections;
  58.         default:
  59.             break;
  60.     }
  61.     return 0;
  62. }
  63. void Options::OnPlus()
  64. {
  65.     buttons->mode = Buttons::plus;
  66.     buttons->appear();
  67.     int hi, lo;
  68.     Digit *dp = currdigit(lo, hi);
  69.     if (dp->getnum() == hi)
  70.         dp->setnum(lo);
  71.     else
  72.         (*dp)++;
  73. }
  74. void Options::OnMinus()
  75. {
  76.     buttons->mode = Buttons::minus;
  77.     buttons->appear();
  78.     int hi, lo;
  79.     Digit *dp = currdigit(lo, hi);
  80.     if (dp->getnum() == lo)
  81.         dp->setnum(hi);
  82.     else
  83.         --(*dp);
  84. }
  85. void Buttons::update_position()
  86. {
  87.     switch (mode)    {
  88.         case up:
  89.             disappear();
  90.             break;
  91.         case minus:
  92.             set_imageno(1);
  93.             mode = wait;
  94.             break;
  95.         case plus:
  96.             set_imageno(2);
  97.             mode = wait;
  98.             break;
  99.         case wait:
  100.             mode = up;
  101.             break;
  102.         default:
  103.             break;
  104.     }
  105. }
  106.  
  107.