#ifndef _all_in_one_
#define _all_in_one_

#include "hge.h"
#include "hgeSprite.h"
#include "hgeVector.h"
#include "hgeRect.h"
#include "hgeFont.h"
#include "hgecolor.h"

float camx, camy, camz;
float scrWidth, scrHeight;
int score, scorecount;
float scoretimer;

const DWORD shwcolor = ARGB(200,0,0,0);
const DWORD plcolor = ARGB(255,0,200,0);
const float plmaxhealth = 5;
const float plhregen = 10;
const float maxspeed = 400;
const float boataccel = 350;
const float rotatespeed = 7.5;
const float rotdownpercent = 90;
const float plcooldown = 0.2;
const float pltorpedocd = 5;

const float bulletlivetime = 10;
const float bulletmaxspeed = 750;
const float enbulletspeed = 500;
const float torplivetime = 20;
const float torpspeed = 500;

const DWORD enemycolor = ARGB(255,255,0,0);
const float enemy1speed = 200;
const float enemy1accel = 150;
const float enemy1rotate = 3;
const float enemy1rotdown = 95;
const float enemy1cd = 5;
const float enemy1health = 5;

const float enemy2speed = 700;
const float enemy2accel = 150;
const float enemy2fric = 300;
const float enemy2rotate = 3;
const float enemy2rotdown = 95;
const float enemy2cd = 10;
const float enemy2health = 10;
const float enemy2autorot = 1.5;
const float enemy2spawn1 = 20;
const float enemy2spawn2 = 60;

hgeFont *fnt1;
hgeFont *fnt2;
hgeFont *fnt3;

hgeSprite *sprPlayer;
hgeSprite *sprPlShw;
hgeSprite *sprBullet;
hgeSprite *sprTorpedo;
hgeSprite *sprEnemy1;
hgeSprite *sprEnShw1;
hgeSprite *sprEnemy2;
hgeSprite *sprEnShw2;
hgeSprite *sprArrow;
hgeSprite *sprSplashScr;

HEFFECT sndPlayerShoot;
HEFFECT sndPlayerHit;
HEFFECT sndEnemyShoot;
HEFFECT sndEnemyHit;

/***********************
//  functions
***********************/

hgeSprite* loadsprite(const char *filename);
void loadRes();
void bulletupdate(const float dt);
void enspawn(const int type, const bool bSetCoord = false, const float _x = 0, const float _y = 0);
inline void _render(hgeSprite *spr, const float x, const float y, const float rot, const float scale = -1);
void restartgame();

/***********************
//  cSplashScr
***********************/
class cSplashScr{
    public:
    cSplashScr();
    ~cSplashScr();
    void render();
    bool update(const float dt);
    void restart();

    float timer;
    float timerstart;
};

/***********************
//  cGameObj
***********************/
class cGameObj{
    public:
    cGameObj();
    virtual void render();
    virtual void update(const float dt);
    virtual bool dead(){return false;};
    virtual int type(){return 0;};
    virtual bool deathanim(const float dt){return false;}
    ~cGameObj();

    hgeVector coord, direct, speed, accel;
    float deathtimer;
    int health, hit;
};

/***********************
//  cPlayer
***********************/

class cPlayer : public cGameObj{
    public:
        cPlayer();
        ~cPlayer();

        virtual void render();
        virtual void update(const float dt);
        void shoot();
        void torpedoshoot();
        virtual bool dead();
        virtual bool deathanim(const float dt);
        int health;
        float hregen;
        float cdtimer;
        float torpcd;
};

/***********************
//  cBullet
***********************/

class cBullet : public cGameObj{
    public:
        cBullet(){};
        cBullet(const hgeVector pos, const hgeVector dir, DWORD _color);
        ~cBullet();

        virtual void render();
        virtual void update(const float dt);
        virtual bool dead();
        virtual int type();

        float livetime;
        DWORD color;
};

class cTorpedo : public cBullet{
    public:
        cTorpedo(const hgeVector pos, const hgeVector dir, DWORD _color);
        ~cTorpedo();

        virtual void render();
        virtual void update(const float dt);
        virtual bool dead();
        virtual int type();

        float livetime;
        DWORD color;
};


/***********************
//  cEnemy1
***********************/

class cEnemy1 : public cGameObj{
    public:
        cEnemy1();
        ~cEnemy1();

        virtual void render();
        virtual void update(const float dt);
        virtual bool dead();
        virtual int type();
        virtual bool deathanim(const float dt);
        void shoot();
        float cdtimer;

};

/***********************
//  cEnemy2
***********************/

class cEnemy2 : public cGameObj{
    public:
        cEnemy2();
        ~cEnemy2();

        virtual void render();
        virtual void update(const float dt);
        virtual bool dead();
        virtual int type();
        virtual bool deathanim(const float dt);
        void shoot();
        void spawn();
        float cdtimer;
        hgeVector memplcoord;
        int ammo;
        float rot;
        float spawntimer;
        float spawntimer2;
};


#endif //_all_in_one_
