home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 11 Learning / 04 Mommersteeg / Tennis / Gamer.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-30  |  1.6 KB  |  50 lines

  1. //----------------------------------------------------------------------------------------------
  2. // Sequential Prediction Demo: The positioning pattern
  3. // 
  4. // Author:  Fri Mommersteeg
  5. // Date:    10-09-2001
  6. // File:    Gamer.cpp
  7. //----------------------------------------------------------------------------------------------
  8.  
  9. //----------------------------------------------------------------------------------------------
  10. // Include files
  11. //----------------------------------------------------------------------------------------------
  12.  
  13. #include "stdafx.h"
  14. #include "gamer.h"
  15.  
  16. //----------------------------------------------------------------------------------------------
  17. // HandleUserInput(): forwards commands from the keyboard to the paddle
  18. //----------------------------------------------------------------------------------------------
  19.  
  20. void CGamer::HandleUserInput() {
  21.  
  22.     if KEY_DOWN(VK_LEFT) {
  23.         Left();
  24.     }
  25.     if KEY_DOWN(VK_RIGHT) {
  26.         Right();
  27.     }
  28.     if KEY_DOWN(VK_UP) {
  29.         if (direction==-1) Up(); else Down();
  30.     }
  31.     if KEY_DOWN(VK_DOWN) {
  32.         if (direction==-1) Down(); else Up();
  33.     }
  34.     if KEY_DOWN(VK_Z) {
  35.         Rotate(-(int)NormSpeed(ROTATE_SPEED));
  36.     }
  37.     if KEY_DOWN(VK_X) {
  38.         Rotate((int)NormSpeed(ROTATE_SPEED));
  39.     }
  40. }
  41.  
  42. //----------------------------------------------------------------------------------------------
  43. // Update(): override of CPaddle::Update() to handle user input
  44. //----------------------------------------------------------------------------------------------
  45.  
  46. void CGamer::Update() {
  47.     HandleUserInput();
  48.     CPaddle::Update();
  49. }
  50.