tb1/tblib.c

69 lines
1.6 KiB
C
Raw Normal View History

1998-03-07 20:37:00 +00:00
#include <sys/time.h>
#include <unistd.h>
#include <stdio.h>
2000-09-16 23:23:00 +00:00
#include <string.h>
#include "svmwgraph/svmwgraph.h"
2000-10-16 03:18:00 +00:00
#include "tb1_state.h"
#include "graphic_tools.h"
2000-09-16 04:49:00 +00:00
void pauseawhile(int howlong) {
struct timeval bob;
struct timezone mree;
long begin_s,begin_u;
vmwClearKeyboardBuffer();
gettimeofday(&bob,&mree);
begin_s=bob.tv_sec; begin_u=bob.tv_usec;
while ((bob.tv_sec-begin_s)<howlong) {
if (vmwGetInput()) return;
usleep(30);
gettimeofday(&bob,&mree);
}
}
1998-03-07 20:37:00 +00:00
/* The collision detection routine. Optimize? */
/* Detects if x1,y1 is within x2,y2 */
2000-09-16 23:23:00 +00:00
int collision(int x1,int y1,int xsize,int ysize,
int x2,int y2,int x2size,int y2size)
1998-03-07 20:37:00 +00:00
{
if (abs((y1+ysize)-(y2+y2size))<(ysize+y2size)){
if (abs((x1+xsize)-(x2+x2size))<(xsize+x2size)) return 1;
}
return 0;
}
2000-10-07 06:39:00 +00:00
/* Now memory-leak friendly */
2000-09-05 03:57:00 +00:00
char *tb1_data_file(char *name,char *path)
2000-10-07 06:39:00 +00:00
{
static int initialized=0;
static char *tempst;
2000-09-05 03:57:00 +00:00
2000-10-07 06:39:00 +00:00
if (!initialized) {
tempst=(char *)calloc(BUFSIZ,sizeof(char));
initialized=1;
}
snprintf(tempst,BUFSIZ,"%s/%s",path,name);
return tempst;
}
2000-10-16 03:18:00 +00:00
int are_you_sure(tb1_state *game_state,
char *warning_1,
char *warning_2,
char *yes_option,
char *no_option) {
2001-06-03 05:14:00 +00:00
return vmwAreYouSure(game_state->graph_state,
game_state->graph_state->default_font,
game_state->virtual_1,
warning_1,
warning_2,
yes_option,
no_option);
2000-10-16 03:18:00 +00:00
2001-06-03 05:14:00 +00:00
2000-10-16 03:18:00 +00:00
}