//////////////////////////////////////////////////////////// // car.h // // Header file for car related classes for EDrive, a multiplatform driving // simulator. Those classes are: // wheel - one wheel of the car // car - the whole car (currently just 4 wheels and a sound) // // Copyright 2004 by Evan Alexander Weaver // // Despite the copyright, this is free software. See edrive.cpp for details. // // Date last modified: 31 May 2004 #ifndef _edrive_car_h_ #define _edrive_car_h_ #include "graphics.h" #include "terrain.h" #include "sound.h" // A wheel // class wheel:public thing { float angle; // spin angle float orientation; // turning orientation float lean; // terrain following lean float x; // X coord float y; // Y coord float z; // Z coord vector leandir; // direction around which lean occurs bool moved; // has it moved since last redraw void addpie(float a, float z); // add a pie slice to the underlying thing public: wheel(); wheel(const wheel &); // intentionally omitted... wheel &operator=(const wheel &); // ...to prevent copies // construct wheel with texture bool create(graphics &g, const char *bmp); // spin the wheel void spin(float rad); // move the wheel to a new location void moveto(float x1, float y1, float z1); void moveto(const vector &v); // turn the wheel to a new direction void turnto(float rad); // tilt the wheel to a given angle around a vector void tiltto(float rad, const vector &v); // draw the wheel void draw(graphics &g); }; // A car, which is current just four wheels and an engine sound // class car { wheel leftf, leftr, // the wheels rightf, rightr; sound engine; // the engine sound vector direction, // location up, rightdir, location; float speed, // current speed oldspeed; // previous speed unsigned int freq; // current engine frquency int pov; // point of view - 0: none, 1: close, 2: far, 3: right 4:overhead char infostr[201]; // interesting data about car right now public: car(); car(const car &); // intentionally omitted... car &operator=(const car &); // ...to prevent copies ~car(); // free all consumed resources void destroy(); // free graphics resources void destroygraphics(); // create a car with a given orientation from image and sound files bool create(graphics &g, const char *wheelbmp, const char *enginewav, const vector &initdir, const vector &initloc, int initpov); // load graphics resources bool loadgraphics(graphics &g, const char *wheelbmp); // move the car over terrain "t", given user inputs void move(unsigned int delta, float accel, float brake, float turn, terrain &t, graphics &g); // draw the car void draw(graphics &g); // change the camera void camera(int newcam); // stop making the noise void hush(); // (re)start making the noise void saywhat(); // return some interesting information const char *info(); }; #endif