00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef DRIVER_H
00031 #define DRIVER_H
00032
00033 #include <queue>
00034 #include "Model.h"
00035 #include "Target.h"
00036
00037 class Driver
00038 {
00039 protected:
00040 class VehicleSprite *vehicle;
00041
00042 public:
00043 virtual ~Driver() {}
00044
00045 Driver(void): vehicle(NULL) {}
00046 int connect(class VehicleSprite *to);
00047 void disconnect(void);
00048
00049 };
00050
00051 class KeyDriver : public Driver
00052 {
00053 public:
00054 virtual void handleEvent(int key, int x, int y, bool special, bool down, unsigned int modifiers);
00055 protected:
00056 virtual bool handleTypeSpecific(int key, int x, int y, bool special, bool down, unsigned int modifiers) {return false;}
00057 };
00058
00059
00060 class TankDriver : public KeyDriver
00061 {
00062 protected:
00063 bool isAiming;
00064
00065 virtual bool handleTypeSpecific(int key, int x, int y, bool special, bool down, unsigned int modifiers);
00066
00067 public:
00068 TankDriver(): isAiming(false) {}
00069 virtual ~TankDriver() {}
00070 };
00071
00072
00073 typedef float *waypoint_t;
00074
00075 class AutoDriver : public Driver
00076 {
00077 protected:
00078 waypoint_t current_waypoint;
00079 std::queue<waypoint_t> waypoints;
00080 bool wp_lock;
00081
00082 protected:
00083 waypoint_t getNextWaypoint();
00084
00085 public:
00086 AutoDriver() : Driver(), current_waypoint(NULL), wp_lock(false) {}
00087 void addWaypoint(waypoint_t waypoint);
00088 int wayPoints(void);
00089 void lockCurrentWaypoint(void) {wp_lock = true;}
00090 void unlockCurrentWaypoint(void) {wp_lock = false;}
00091 void clearWaypoints(void);
00092 std::queue<waypoint_t> peekWaypoints(void);
00093 void calculateAction(void);
00094
00095 };
00096
00097 #define SQUARED_TARGET_THRESHOLD 25.0
00098
00099 class AutoGunner
00100 {
00101 protected:
00102 class VehicleSprite *vehicle;
00103 GroundTarget *current_target;
00104 bool doAim;
00105 bool hasAimed;
00106
00107 protected:
00108 void calcAim(Target *target);
00109
00110 public:
00111 AutoGunner(void): vehicle(NULL), current_target(NULL) {}
00112 int init(class VehicleSprite *target);
00113 int connect(class VehicleSprite *to);
00114 void disconnect(void) {vehicle = NULL;}
00115 bool fire(void);
00116 void setTarget(Target *new_target);
00117 void dropTarget(void);
00118 bool getGunnerState(void) {return false;}
00119 void update(void);
00120
00121 };
00122
00123 #endif