Platform játék
3D-s megjelenítés, véletlenszerű pályagenerálás, jutalmazó játékélmény
auxFunctions.h
Ugrás a fájl dokumentációjához.
1 #ifndef AUXFUNCTIONS_H_INCLUDED
2 #define AUXFUNCTIONS_H_INCLUDED
3 
4  #include "../global.h"
5 
6  inline float randomWithinBorders(float base, float variance) {
7  int intVariance = (int)(1e4 * variance);
8  return (1e4 * base + (rand() % (2 * intVariance + 1) - intVariance)) / 1e4;
9  }
10 
11  inline int randomIntWithinBorders(int base, int variance) {
12  return base + (rand() % (2 * variance + 1) - variance);
13  }
14 
15  inline int randomPlusOrMinus() {
16  return rand() % 2 ? 1 : -1;
17  }
18 
19 
20  inline int larger(int a, int b) {
21  return a > b ? a : b;
22  }
23 
24  inline int smaller(int a, int b) {
25  return a < b ? a : b;
26  }
27 
28  inline float largerF(float a, float b) {
29  return a > b ? a : b;
30  }
31 
32  inline float smallerF(float a, float b) {
33  return a < b ? a : b;
34  }
35 
36 
37  inline void putInsideInterval(int min, int* a, int max) {
38  *a = largerF(min, smallerF(*a, max));
39  }
40 
41  inline void putInsideIntervalF(float min, float* a, float max) {
42  *a = largerF(min, smallerF(*a, max));
43  }
44 
45 
46  inline float dist(int a, int b) {
47  return sqrt(a*a + b*b);
48  }
49 
50  inline float fDist(float a, float b) {
51  return sqrt(a*a + b*b);
52  }
53 
54  inline float square(float a) {
55  return a*a;
56  }
57 
58 #endif // AUXFUNCTIONS_H_INCLUDED
int larger(int a, int b)
Definition: auxFunctions.h:20
float dist(int a, int b)
Definition: auxFunctions.h:46
int randomIntWithinBorders(int base, int variance)
Definition: auxFunctions.h:11
float square(float a)
Definition: auxFunctions.h:54
float randomWithinBorders(float base, float variance)
Definition: auxFunctions.h:6
float largerF(float a, float b)
Definition: auxFunctions.h:28
void putInsideIntervalF(float min, float *a, float max)
Definition: auxFunctions.h:41
int randomPlusOrMinus()
Definition: auxFunctions.h:15
int smaller(int a, int b)
Definition: auxFunctions.h:24
void putInsideInterval(int min, int *a, int max)
Definition: auxFunctions.h:37
float fDist(float a, float b)
Definition: auxFunctions.h:50
float smallerF(float a, float b)
Definition: auxFunctions.h:32