comparison mytype.c @ 96:0b65ca27f113

compile on Mac OS X 2
author Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
date Thu, 02 Jun 2011 14:56:11 +0900
parents 8edae89a3877
children
comparison
equal deleted inserted replaced
95:b0249b856488 96:0b65ca27f113
1 /* 1 /* mytype.c */
2 * $Id$ 2
3 */
4 #include <time.h> 3 #include <time.h>
5 #include <stdio.h> 4 #include <stdio.h>
6 #include <stdbool.h> 5 #include <stdbool.h>
7 //#include "libps2.h" 6 #include "libps2.h"
8 //#include "ps2util.h" 7 #include "ps2util.h"
9 #include "mytype.h" 8 #include "mytype.h"
10 9
11 static clock_t start; 10 static clock_t start;
12 static clock_t race_start; 11 static clock_t race_start;
13 12
14 void 13 void
15 wait_init() 14 wait_init()
16 { 15 {
17 start = clock(); 16 start = clock();
18 } 17 }
19 18
20 /* 19 /*
21 * wait_init()から 20 * wait_init()から
22 * time秒(マイクロ秒?)すぎたらTRUEを返す 21 * time秒(マイクロ秒?)すぎたらTRUEを返す
23 */ 22 */
24 bool 23 bool
25 wait(double time) 24 wait(double time)
26 { 25 {
27 clock_t t; 26 clock_t t;
28 double a; 27 double a;
29 28
30 t = clock(); 29 t = clock();
31 a = (t-start)/(double)CLOCKS_PER_SEC; 30 a = (t-start)/(double)CLOCKS_PER_SEC;
32 if (a > time) { 31 if (a > time) {
33 return true; 32 return true;
34 } 33 }
35 34
36 return false; 35 return false;
37 } 36 }
38 37
39 void 38 void
40 time_RaceStart() 39 time_RaceStart()
41 { 40 {
42 race_start = clock(); 41 race_start = clock();
43 } 42 }
44 43
45 double 44 double
46 time_RaceTime() 45 time_RaceTime()
47 { 46 {
48 clock_t t; 47 clock_t t;
49 double a; 48 double a;
50 49
51 t = clock(); 50 t = clock();
52 a = (t-race_start)/(double)CLOCKS_PER_SEC; 51 a = (t-race_start)/(double)CLOCKS_PER_SEC;
53 52
54 return a; 53 return a;
55 } 54 }