1 /*************************************************************************** 2 3 file : cardata.h 4 created : Thu Sep 23 12:31:33 CET 2004 5 copyright : (C) 2004 Bernhard Wymann 6 email : berniw@bluewin.ch 7 version : $Id: cardata.h,v 1.1.2.1 2008/05/28 21:34:43 berniw Exp $ 8 9 ***************************************************************************/ 10 11 /*************************************************************************** 12 * * 13 * This program is free software; you can redistribute it and/or modify * 14 * it under the terms of the GNU General Public License as published by * 15 * the Free Software Foundation; either version 2 of the License, or * 16 * (at your option) any later version. * 17 * * 18 ***************************************************************************/ 19 20 /* 21 This class holds global facts about cars, therefore no data relative to 22 each other (for that is the class Opponents/Opponent responsible). 23 */ 24 25 #ifndef _BT_CARDATA_H_ 26 #define _BT_CARDATA_H_ 27 28 #include <stdio.h> 29 #include <math.h> 30 #include <car.h> 31 #include <robottools.h> 32 #include <raceman.h> 33 34 35 36 class SingleCardata { 37 public: init(CarElt * car)38 inline void init(CarElt *car) { this->car = car; /*teammate = false; teammatedamage = 0; */} 39 getSpeedInTrackDirection()40 inline float getSpeedInTrackDirection() { return speed; } getWidthOnTrack()41 inline float getWidthOnTrack() { return width; } getTrackangle()42 inline float getTrackangle() { return trackangle; } getCarAngle()43 inline float getCarAngle() { return angle; } 44 thisCar(tCarElt * car)45 inline bool thisCar(tCarElt *car) { return (car == this->car); } 46 47 void update(); 48 49 protected: 50 static float getSpeed(tCarElt *car, float trackangle); 51 52 float speed; // speed in direction of the track. 53 float width; // the cars needed width on the track. 54 float trackangle; // Track angle at the opponents position. 55 float angle; // The angle of the car relative to the track tangent. 56 57 tCarElt *car; // For identification. 58 }; 59 60 61 // TODO: use singleton pattern. 62 class Cardata { 63 public: 64 Cardata(tSituation *s); 65 ~Cardata(); 66 67 void update(); 68 SingleCardata *findCar(tCarElt *car); 69 70 protected: 71 SingleCardata *data; // Array with car data. 72 int ncars; // # of elements in data. 73 }; 74 75 76 #endif // _BT_CARDATA_H_ 77