#ifndef player_h
#define player_h

#include "vector2d.h"
#include "math.h"
#include "2linecol.h"
#include "line2d.h"
#include "physpoint.h"

#include "glness.h"
#include "SDL/SDL.h"

using namespace std;
class player {
public:

    player() {
        jump = 65;
        petrol = 0, maxpetrol = 0;


        dirangle = 0;

        drag = 0;
        steerspeed = 0;
        grip = 0;
        jumpingvel = 0;

        //input
        up = 0,dn = 0,lt = 0,rt = 0;
        shoot = 0,change = 0;
        jump = 0;

        //the rest
        speed = 0;
        accel = 0;

        r = 0,g = 0,b = 0;
        plytexid = 0;

        nopaintimer = 0;

        jumpingvel = 0;

        jumppower = 0.08;

        gravity = 0.003;

        minzvel = -0.02;

        onground = 0;

    }
    ;
    ~player() {}
    ;

    float petrol, maxpetrol;

    physpoint pos;

    float dirangle;
    vector2d dirvec;

    float drag;
    float steerspeed;
    float grip;
    float jumpingvel, gravity;
    float jumppower;
    float minzvel;

    bool onground;

    //input
    int up,dn,lt,rt;
    int shoot,change;
    int jump;
    Uint8* key;

    //the rest
    float speed;
    float accel;

    float r,g,b;
    int plytexid;

    int nopaintimer;


    void setdirkeys(int uu,int dd,int ll,int rr);
    void setotherkeys(int jumpkey, int shootkey, int changekey);
    void checkbounds();
    void setrgb(float rr,float gg,float bb);

    void init(float x, float y, float z);

    int pnpoly(int npol, vector2d *poly, float x, float y);

    void dophys(float timestep = 1);
    void update();
    void applyforces(Uint8* key, float divstep);

    void fixcollision();
    void playercol(player& otherplayer);

    void draw();

};

#endif
