#include <unistd.h>
#include <assert.h>
#include <ctype.h>
-#include <time.h>
#include <signal.h>
#include <termios.h>
#include <math.h>
return buf;
}
+double calculate_dtime(struct timespec from, struct timespec to)
+{
+ return (double) (to.tv_sec - from.tv_sec) + (double) (to.tv_nsec - from.tv_nsec) / 1000000000.0;
+}
+
/* Game-related utility functions */
void quit()
while (running) {
clock_gettime(CLOCK_REALTIME, &ts);
- double dtime = (double) (ts.tv_sec - ts_old.tv_sec) + (double) (ts.tv_nsec - ts_old.tv_nsec) / 1000000000.0;
+ double dtime = calculate_dtime(ts_old, ts);
ts_old = ts;
bool dead = player_dead();
#include <stdbool.h>
#include <sys/ioctl.h>
#include <stddef.h>
+#include <time.h>
#define MAP_HEIGHT 1000
#define MAP_WIDTH 1000
#define LIGHT 10
int max(int a, int b);
int min(int a, int b);
void *make_buffer(void *ptr, size_t size);
+double calculate_dtime(struct timespec from, struct timespec to);
void quit();
bool player_dead();