Driver.h

Go to the documentation of this file.
00001 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 5 -*- */
00002 
00003 /*
00004  * Combination of a first person action and a real time strategy battle game.
00005  */
00006 
00007 /*
00008  * Driver.h
00009  * MetalWarriors
00010  * $Revision: 1.10 $
00011  *
00012  * Created by Daniel Aarno on Sun Oct 12 2003.
00013  * Copyright (c) 2003 Daniel Aarno and Erik Ytterberg - All rights reserved.
00014  *
00015  *     This program is free software; you can redistribute it and/or modify
00016  *     it under the terms of the GNU General Public License as published by
00017  *     the Free Software Foundation; either version 2 of the License, or
00018  *     (at your option) any later version.
00019  *
00020  *     This program is distributed in the hope that it will be useful,
00021  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  *     GNU General Public License for more details.
00024  *
00025  *     You should have received a copy of the GNU General Public License
00026  *     along with this program; if not, write to the Free Software
00027  *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
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 /*DRIVER_H*/

Generated on Sun Mar 11 15:33:23 2007 for MetalWarriors by  doxygen 1.4.7