#include <stdio.h>
#include <i86.h>
#include <stdlib.h>
#include <conio.h>
#include <time.h>
#include "..\lib1\gug.h" // Load the GUG definitions etc

// Used with the rand() function
#define MAX_X (32768/320)  // Random to 320
#define MAX_Y (32768/200)  // Random to 200
#define MAX_C (32768/215)  // Random to 216 as 0-215 used in 666 palette

void main(void)
{
  int   i,xs,ys,l,x,y;
  int   start,sample,frames,rt;
  float fps;
  char  buf[40];

  GUGInitialize();
  GUGStartKeyboard();

  l = i = 0;
  // gonna use the 18.2ms timer to count FPS
  start  = clock();
  while (start == clock());
  frames = 0;
  do
  {
    // reset the display to color l
    GUGClearDisplay();

    if (++l > 255) l = 0;

    draw_alien_ship(i,80,70);

    draw_player_ship(i,240,130);

    // increment the sprite counter, 0-59 are valid
    i++;
    if (i > 59) i = 0;

    // how much elapsed time
    sample = clock();

    // count the frames and calc the FPS
    frames++;
    rt  = (sample - start); // / CLOCKS_PER_SEC;
    fps	= ((float)frames / (float)rt) * CLOCKS_PER_SEC;
	sprintf((char *)buf,"RT:%d Frms:%d FPS:%5.2f",
	        rt/CLOCKS_PER_SEC,frames,fps);
	GUGPutText(10,185,215,(char *)buf);

    // let em see the sprites we drew
    GUGCopyToDisplay();
  }
  while (!GUGKeyHit());
  GUGGetKey();

  GUGStopKeyboard();
  GUGEnd();
}

