home *** CD-ROM | disk | FTP | other *** search
/ C++ Games Programming / CPPGAMES.ISO / thx / demos / shootout / build / pointer.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-06  |  625 b   |  43 lines

  1. // ---------- pointer.cpp
  2.  
  3. #include "pointer.h"
  4.  
  5. CUELIST(Pointer)
  6.     KEYSTROKE(UP, on_up)
  7.     KEYSTROKE(DN, on_down)
  8. ENDCUELIST
  9.  
  10. Pointer::Pointer(int s1, int s2, int s3, int s4, int s5)
  11.             : Player("pointer.gfx")
  12. {
  13.     selection = 0;
  14.     sels = 2;
  15.     ys[0] = s1;
  16.     ys[1] = s2;
  17.     ys[2] = s3;
  18.     ys[3] = s4;
  19.     ys[4] = s5;
  20.     if (s3)
  21.         sels++;
  22.     if (s4)
  23.         sels++;
  24.     if (s5)
  25.         sels++;
  26.     set_imageno(1);
  27. }
  28. void Pointer::update_position()
  29. {
  30.     setxy(8, ys[selection]);
  31. }
  32.  
  33. void Pointer::on_up()
  34. {
  35.     if (selection-- == 0)
  36.         selection = sels-1;
  37. }
  38. void Pointer::on_down()
  39. {
  40.     if (++selection == sels)
  41.         selection = 0;
  42. }
  43.