Quad Pang
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Controllers.h
Go to the documentation of this file.
00001 #ifndef _CONTROLLERS_H
00002 #define _CONTROLLERS_H
00003 
00004 #include "Event.h"
00005 #include "Engine.h"
00006 
00007 // Forward declarations
00008 class XRes;
00009 class XCongo;
00010 class MenuDisplay;
00011 
00020 class Controller
00021 {
00022 public:
00023     virtual ~Controller() {}
00024 
00026     virtual bool Init(XRes* resource, XCongo *xcongo)  { return true; }
00046     virtual bool ProcessKey(int key, Engine::KeyEvent type, int x, int y) = 0;
00047     
00052     
00078     virtual bool ProcessMousePress(int button, int state, int x, int y) { return false; }
00093     virtual bool ProcessMouseMove(int x, int y) { return false; }
00094     
00096 
00097 
00098 };
00099 
00100 
00102 class MenuController: public Controller
00103 {
00104 public:
00105     MenuController(MenuDisplay* menu);
00106 
00107     bool ProcessKey(int key, Engine::KeyEvent type, int x, int y);
00108 private:
00109     MenuDisplay* mpMenu;
00110 };
00111 
00114 class ShortcutController: public Controller
00115 {
00116 public:
00117     ShortcutController(Engine* parent) : mpParent(parent), mbPaused(false) {}
00118 
00119     bool ProcessKey(int key, Engine::KeyEvent type, int x, int y);
00120 private:
00121     Engine* mpParent;
00122     bool mbPaused;
00123 };
00124 
00126 class BongoOrthoMover : public Controller
00127 {
00128 public:
00129     BongoOrthoMover(Engine* parent, Bongo* pquad);
00130     bool Init(XRes* resource, XCongo *xcongo);
00131 
00132     bool ProcessKey(int key, Engine::KeyEvent type, int x, int y);
00133 private:
00134     Engine* mpParent;
00135     Bongo*  mpBongo;
00136     double  mPower;
00137 
00147     double m_k;
00148     double m_lz;
00150 
00152     int     mnMoving;
00164     double  mDirectionLU[3];
00165     double  mDirectionRD[3];
00167 };
00168 
00176 class BongoRealMover : public Controller
00177 {
00178 public:
00179     BongoRealMover(Engine* parent, Bongo* pquad);
00180 
00181     bool Init(XRes* resource, XCongo *xcongo);
00182 
00183     bool ProcessKey(int key, Engine::KeyEvent type, int x, int y);
00184 private:
00185     Engine* mpParent;
00186     Bongo*  mpBongo;
00187     double  mPower;
00188     double  mDirection[3];
00189     bool    mbMoving;
00190 };
00191 
00192 
00197 class ViewController : public Controller, public EventListener
00198 {
00199 public:
00200     ViewController(Engine* parent);
00201     bool Init(XRes* resource, XCongo *xcongo);
00202     
00211     bool Handle(EventType etype);
00212 
00213     bool ProcessKey(int key, Engine::KeyEvent type, int x, int y);
00214 
00215 private:
00216     Engine* mpParent;
00226     bool   mbKeyInProcessing;
00227     int    mLastKey;
00229 
00230     double mDeltaAngle;
00231     double mDeltaDis;
00232 };
00233 
00234 
00246 class ViewBongoFollower : public QuadListener
00247 {
00248 public:
00249     ViewBongoFollower(Engine* parent, Bongo *bongo);
00250     void QuadEvent();
00251     bool Move();
00252    
00253 private:
00254     Engine* mpParent;
00255     Bongo*  mpBongo;
00256 
00257     double mDirection[3];
00258     double mPower;
00259     double mDistance;
00260     double mOldCenter[3];
00261 };
00262 
00263 #endif // _CONTROLLERS_H