
#define NUMGAMELEVELS 2
#define MAXGAMELEVELS 50
#define MAXUSERS 20

int menumode;
int textboxblinkstate;

bool buttonpressed;
int selectedsoldier;
typedef struct labelbox labelbox;
typedef struct button button;
labelbox *selectedlabel;
//button *selectedbutton;

#define MAXMENUWINDOWS 5
#define MAXBUTTONS 30

#define MAXATOMLINKS 16

#define MAXBOXATOMS 200


#define MAXSTRUCTX 100
#define MAXSTRUCTY 100
#define MAXSTRUCTURES 50


#define MOD

#ifndef MOD
#define REPULSESTRENGTH .25
#define DELTAT 1
#define LINKSTRENGTH .31
#define FLUIDFRICTION 0.9995
#define FRICTION 0.0005
#define GRAVITY .008
#endif

#ifndef NORMAL
#define REPULSESTRENGTH .45
#define DELTAT 0.5
#define LINKSTRENGTH .55
#define FLUIDFRICTION 0.9995
#define FRICTION 0.0005
#define GRAVITY .008
#endif

#define MAXBOXX 304
#define MAXBOXY 64
#define MAXATOMS 10000
#define MAXLINKS 80000
#define MAXPOLYS 10000
#define MAXOBJECTS 200
#define MAXRIGIDBODIES 10
#define MAXRATOMS 600
#define MAXDEBRIS 5000
#define MAXLEVELS 30
#define BPMULT 1.04
#define PIXW 10



#define LEFT 0
#define RIGHT 1
#define MAXBULLETS 100
#define MAXBOMBS 10
#define MAXSOLDIERS 50
#define MAXCOMPSOLDIERS 50
#define MAXANIMATIONS 1000
#define MAXTRAILANIMS 300
#define MAXAAGUNS 10
#define MAXJEEPS 10
#define MAXPLANES 10
#define MAXHELIS 10
#define MAXTANKS 10
#define ENEMY 1
#define FRIEND 0
#define BOMB 0
#define MISSILE 1
#define PLAYMODE_LOOP 1
#define pi 3.1415926535
#define MAXGUIBARS 4

#define DRAWING 1
#define WINDOWED 0

typedef struct soldier soldier;
typedef struct bullet bullet;
typedef struct bomb bomb;
typedef struct atom atom;
typedef struct movieframe movieframe;
typedef struct MIDI MIDI;
typedef struct SAMPLE SAMPLE;
typedef struct movie movie;
typedef struct color color;
typedef struct blueprint blueprint;

//atom *interacted[100][2];
//int numinteracted;

//atom *menuatom;


void settmplevels();
void cleartmplevels();
void setupmass(float amass[100][100]);
void setupgrid(float aposx[100][100], float aposy[100][100]);
bullet *addbullet(float, float, float, float, int, int, float, int, color, bool);
bomb *addbomb(float x, float y, float ix, float iy, bool comp, ABITMAP *bmp, int bombtype);
float getpixelalpha(ABITMAP *bmp, int x, int y);
void gldrawsprite(float x, float y, ABITMAP *bmp);
void gldrawspritehflip(float x, float y, ABITMAP *bmp);
void addparticletrailanim(atom *a, int mod, int modoff, int life, float dy, int rand, int type);
//void createtexture(ABITMAP *tex);
void createexplosion(float x, float y);
void loadblueprint(char *fn, blueprint *b);

void updatebuttons();
void drawbuttons();
void msdownbuttons();
void msupbuttons();

void initlevel();

int menux, menuy;

ABITMAP *bolt;

ABITMAP *buf;
ABITMAP *bg;
ABITMAP *sky;
ABITMAP *ground;
ABITMAP *mousebmp;
ABITMAP *scorch;
ABITMAP *explosionanim[16];
ABITMAP *explosionsmallanim[24];
ABITMAP *smokeanim[24];
ABITMAP *redanim[24];
ABITMAP *yellowanim[24];
ABITMAP *whiteanim[24];
ABITMAP *splashanim[6];
ABITMAP *misstrailanim[9];
ABITMAP *tankbarrelanim[10];
ABITMAP *exptemp;
ABITMAP *bombbmp;
ABITMAP *missilebmp;
ABITMAP *shell;
ABITMAP *debrisr[4];
ABITMAP *debrisrm[4];
ABITMAP *debrisra[4];
ABITMAP *debris1;
ABITMAP *debris1a;
ABITMAP *debriso1;
ABITMAP *grounddebris1;

ABITMAP *particlebmp;

ABITMAP *tankbase;
ABITMAP *tankbasee;
ABITMAP *tankd;
ABITMAP *tankde;

ABITMAP *planeunoc;
ABITMAP *planeocc;
ABITMAP *planefiring;
ABITMAP *planeexp;
ABITMAP *planedamaged;
ABITMAP *planedamagedo;
ABITMAP *planedamagedf;

ABITMAP *planeunoce;
ABITMAP *planeocce;
ABITMAP *planefiringe;
ABITMAP *planeexpe;
ABITMAP *planedamagede;
ABITMAP *planedamagedoe;
ABITMAP *planedamagedfe;

ABITMAP *heliunoc;
ABITMAP *heliocc;
ABITMAP *helifiring;
ABITMAP *heliexp;
ABITMAP *helidamaged;
ABITMAP *helidamagedo;
ABITMAP *helidamagedf;

ABITMAP *heliunoce;
ABITMAP *heliocce;
ABITMAP *helifiringe;
ABITMAP *heliexpe;
ABITMAP *helidamagede;
ABITMAP *helidamagedoe;
ABITMAP *helidamagedfe;

ABITMAP *soldierbody[8];
ABITMAP *soldierbodye[8];
ABITMAP *soldierarm;
ABITMAP *soldierarme;
ABITMAP *soldierhead;
ABITMAP *soldierheade;

movie *script;

long tmpkeys;
bool recording;

MIDI *music;
SAMPLE *mgun;
SAMPLE *explode;
SAMPLE *explodesmall;
SAMPLE *engine;
SAMPLE *prop;
SAMPLE *enginestart;
SAMPLE *propstart;
SAMPLE *death1;
SAMPLE *bombdrop;
SAMPLE *aagunfire;
SAMPLE *tankfire;
SAMPLE *gurgle;
SAMPLE *splash;

atom *center;

const float convk3 = 1.40625;
const float convk4 = 57.295;

int path[4000];
int debrislev[4000];

int mx, my, slx;
int omouse_x, omouse_y;
int nmouse_x, nmouse_y;

extern color green, black, white, magenta, gray, yellow, nullcolor;

float convk;
float convk2;
int lx, rx;
int numsplashes;

extern int COMPFRAMES;

extern atom *atomstructure[100][100];

bool tmplevels[MAXLEVELS];

int level;
int frame;
int drawframe;
int waterlevel;

bool dispframe;

int screencenterx;			//Center of window / screen
int pan;
int vol;

extern int mouse_x;
extern int mouse_y;
extern int mouse_z;

bool lmb, rmb;


HDC hDC=NULL;											// Private GDI Device Context
HGLRC hRC=NULL;											// Permanent Rendering Context
HWND hWnd=NULL;											// Holds Our Window Handle
HINSTANCE hInstance;									// Holds The Instance Of The Application

FILE *debug;
ABITMAP *screen;

bool	keys[256];										// Array Used For The Keyboard Routine

ABITMAP *guibars[MAXGUIBARS];
//ABITMAP *guibarsbuf[10];
float guibarposx[MAXGUIBARS];
float guibarposy[MAXGUIBARS];
bool guibaron[MAXGUIBARS];
ABITMAP *guitemp;
ABITMAP *digits[10];
ABITMAP *inf;
bool updateguibars[MAXGUIBARS];
int numguibars;
