

#include <stdio.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>


#include "slugmass.h"
#include "main.h"
#include "kbd_event.h"
#include "rend_event.h"

#define TICK_TIME 200000
#define TICKS_PER_SECOND 5

inline int ticknum();

int main()
{
	long tick, ltick;
	int flags = 0;
	ggi_visual_t *vis;
	
	vis = render_init();
	
	do
	{
		tick = ticknum();
		
		if( tick != ltick )
		{
			/* Do tick based stuff */
			
		}
		
		
		render_main();
		flags = kbd_main(vis);
		
		ltick = tick;
	} while (flags != 1);
	
	ggiClose(&vis);
	ggiExit();
	
	exit(0);
}


inline int ticknum()
{
	struct timeval tv;
	
	gettimeofday(&tv, NULL);
	
	return (tv.tv_sec * TICKS_PER_SECOND + 
			  tv.tv_usec/(1000000/TICKS_PER_SECOND));
}


