00001 #ifndef __USER_CONTROLS_H__ 00002 #define __USER_CONTROLS_H__ 00003 00004 #include "UserAgent.h" 00005 00006 00015 00016 00017 //The control of the user agent is based on the below table 00018 00019 enum GameControls 00020 { 00021 kUp = 1 << 0, 00022 kDown = 1 << 1, 00023 kLeft = 1 << 2, 00024 kRight = 1 << 3, 00025 kShoot = 1 << 4, 00026 00027 kUpLeft = kUp | kLeft, 00028 kUpRight = kUp | kRight, 00029 kDownLeft = kDown | kLeft, 00030 kDownRight = kDown | kRight, 00031 00032 // nonsense controls 00033 kUpDown = kUp | kDown, 00034 kLeftRight = kRight | kLeft 00035 }; 00036 00037 00038 // The structure which decides the off set based on the key pressed 00039 struct UserMotion 00040 { 00041 int OffsetIndex; 00042 }; 00043 00044 00045 class UserAgent; 00046 class Graph; 00047 00048 class UserControls 00049 { 00050 public: 00051 //---------------------------------------------------------------------------------------------------------------------- 00055 //---------------------------------------------------------------------------------------------------------------------- 00056 UserControls(UserAgent* _ugent, Graph *_graph); 00057 //---------------------------------------------------------------------------------------------------------------------- 00059 //---------------------------------------------------------------------------------------------------------------------- 00060 ~UserControls(); 00061 //---------------------------------------------------------------------------------------------------------------------- 00065 //---------------------------------------------------------------------------------------------------------------------- 00066 void processKeyDown(QKeyEvent *_event); 00067 //---------------------------------------------------------------------------------------------------------------------- 00071 //---------------------------------------------------------------------------------------------------------------------- 00072 void processKeyUp (QKeyEvent *_event); 00073 //---------------------------------------------------------------------------------------------------------------------- 00075 //---------------------------------------------------------------------------------------------------------------------- 00076 void ResetPosition(); 00077 //---------------------------------------------------------------------------------------------------------------------- 00079 //---------------------------------------------------------------------------------------------------------------------- 00080 int getIndex(){return m_index;} 00081 //---------------------------------------------------------------------------------------------------------------------- 00083 //---------------------------------------------------------------------------------------------------------------------- 00084 int getNextIndex(){return m_nextIndex;} 00085 //---------------------------------------------------------------------------------------------------------------------- 00087 //---------------------------------------------------------------------------------------------------------------------- 00088 void initializeArray(); 00089 00090 private: 00091 //---------------------------------------------------------------------------------------------------------------------- 00093 //---------------------------------------------------------------------------------------------------------------------- 00094 UserAgent* m_parent; 00095 //---------------------------------------------------------------------------------------------------------------------- 00097 //---------------------------------------------------------------------------------------------------------------------- 00098 int m_precision; 00099 //---------------------------------------------------------------------------------------------------------------------- 00101 //---------------------------------------------------------------------------------------------------------------------- 00102 int m_index; 00103 //---------------------------------------------------------------------------------------------------------------------- 00105 //---------------------------------------------------------------------------------------------------------------------- 00106 int m_nextIndex; 00108 uint8_t m_keysPressed; 00109 //---------------------------------------------------------------------------------------------------------------------- 00111 //---------------------------------------------------------------------------------------------------------------------- 00112 Graph* m_graph; 00113 //---------------------------------------------------------------------------------------------------------------------- 00115 //---------------------------------------------------------------------------------------------------------------------- 00116 UserMotion m_motionTable[32]; 00117 //---------------------------------------------------------------------------------------------------------------------- 00119 //---------------------------------------------------------------------------------------------------------------------- 00120 bool m_key; 00121 00122 }; 00123 00124 #endif