Last change
on this file since 46fa35a was b07eeac, checked in by dportnoy <dmp1488@…>, 11 years ago |
Players pick up flags when they get close to the flag objects, not the structres. When a flag is picked up, a REMOVE_OBJECT message is sent
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | #include "Common.h"
|
---|
2 |
|
---|
3 | #include <iostream>
|
---|
4 | #include <cmath>
|
---|
5 |
|
---|
6 | #if defined WINDOWS
|
---|
7 | #include <Windows.h>
|
---|
8 | #elif defined LINUX
|
---|
9 | #include <time.h>
|
---|
10 | #endif
|
---|
11 |
|
---|
12 | using namespace std;
|
---|
13 |
|
---|
14 | /*
|
---|
15 | FLOAT_POSITION POSITION::toFloat() {
|
---|
16 | FLOAT_POSITION floatPosition;
|
---|
17 | floatPosition.x = x;
|
---|
18 | floatPosition.y = y;
|
---|
19 |
|
---|
20 | return floatPosition;
|
---|
21 | }
|
---|
22 | */
|
---|
23 |
|
---|
24 | void set_nonblock(int sock)
|
---|
25 | {
|
---|
26 | #if defined WINDOWS
|
---|
27 | unsigned long mode = 1;
|
---|
28 | ioctlsocket(sock, FIONBIO, &mode);
|
---|
29 | #elif defined LINUX
|
---|
30 | int flags;
|
---|
31 | flags = fcntl(sock, F_GETFL,0);
|
---|
32 | assert(flags != -1);
|
---|
33 | fcntl(sock, F_SETFL, flags | O_NONBLOCK);
|
---|
34 | #endif
|
---|
35 | }
|
---|
36 |
|
---|
37 | unsigned long long getCurrentMillis()
|
---|
38 | {
|
---|
39 | unsigned long long numMilliseconds;
|
---|
40 |
|
---|
41 | #if defined WINDOWS
|
---|
42 | numMilliseconds = GetTickCount();
|
---|
43 | #elif defined LINUX
|
---|
44 | timespec curTime;
|
---|
45 | clock_gettime(CLOCK_REALTIME, &curTime);
|
---|
46 |
|
---|
47 | numMilliseconds = curTime.tv_sec*(unsigned long long)1000+curTime.tv_nsec/(unsigned long long)1000000;
|
---|
48 | #endif
|
---|
49 |
|
---|
50 | return numMilliseconds;
|
---|
51 | }
|
---|
52 |
|
---|
53 | float posDistance(FLOAT_POSITION pos1, FLOAT_POSITION pos2) {
|
---|
54 | float xDiff = pos2.x - pos1.x;
|
---|
55 | float yDiff = pos2.y - pos1.y;
|
---|
56 |
|
---|
57 | return sqrt( pow(xDiff,2) + pow(yDiff,2) );
|
---|
58 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.