#ifndef CLASSES_H
#define CLASSES_H

#include <allegro.h>
#include <vector>

class character;

struct bullet
{
    bullet(int xx, int yy, int dd) : x(xx), y(yy), dir(dd) {}
    ~bullet(){}

    void move();
    void draw(BITMAP*);
    bool hit(character&);

    int x, y, dir;
};

extern std::vector<bullet> bullets;

struct character
{
    int x, y, dir;
    int health, ammo, mag, mgsz;
    int rtime;
    BITMAP* gfc[4];

    character(int xx, int yy, int dd, int hh, int amm, int mgszz, BITMAP** imgs)
    : x(xx) , y(yy) , dir(dd) , ammo(amm) , health(hh) , mgsz(mgszz), mag(mgszz)
    {
        rtime = 0;
        for (int c = 0; c<4; c++)
        {
            gfc[c] = imgs[c];
        }
    }
    ~character()
    {

    }

    virtual void move()
    {
        //will be overidden
    }
    void shoot();
    void draw(BITMAP*);
    void update()
    {
        rtime--;

        for (int c = 0; c<bullets.size(); c++)
        {
            if (bullets[c].hit(*this))
            {
                bullets.erase(bullets.begin()+c);
                c--;
                health -= 5;
            }
        }
    }

    int X()
    {
        return x;
    }
    int Y()
    {
        return y;
    }
};

class player;

class bot : public character
{
    public:
    bot(int xx, int yy, int dd, int hh, int amm, int mgsz, BITMAP** imgs) : character(xx, yy, dd, hh, amm, mgsz, imgs){}
    void move(player& plr);
};

class player : public character
{
    public:
    player(int xx, int yy, int dd, int hh, int amm, int mgsz, BITMAP** imgs) : character(xx, yy, dd, hh, amm, mgsz, imgs){}
    void move();
};

#endif
