SDL  2.0
common.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int randomInt (int min, int max)
 
float randomFloat (float min, float max)
 
void fatalError (const char *string)
 
double updateDeltaTime (void)
 

Function Documentation

◆ fatalError()

void fatalError ( const char *  string)

Definition at line 32 of file common.c.

References NULL, SDL_GetError, SDL_MESSAGEBOX_ERROR, and SDL_ShowSimpleMessageBox.

Referenced by initializeTexture(), initializeTextures(), loadSound(), and main().

33 {
34  printf("%s: %s\n", string, SDL_GetError());
36  exit(1);
37 }
#define SDL_GetError
#define SDL_ShowSimpleMessageBox
#define NULL
Definition: begin_code.h:164

◆ randomFloat()

float randomFloat ( float  min,
float  max 
)

Definition at line 26 of file common.c.

Referenced by explodeEmitter(), initializeHappyFaces(), and spawnTrailFromEmitter().

27 {
28  return rand() / (float) RAND_MAX *(max - min) + min;
29 }

◆ randomInt()

int randomInt ( int  min,
int  max 
)

Definition at line 16 of file common.c.

Referenced by render().

17 {
18  return min + rand() % (max - min + 1);
19 }

◆ updateDeltaTime()

double updateDeltaTime ( void  )

Definition at line 42 of file common.c.

References prevTime, SDL_GetPerformanceCounter, and SDL_GetPerformanceFrequency().

Referenced by main().

43 {
44  Uint64 curTime;
45  double deltaTime;
46 
47  if (prevTime == 0) {
49  }
50 
51  curTime = SDL_GetPerformanceCounter();
52  deltaTime = (double) (curTime - prevTime) / (double) SDL_GetPerformanceFrequency();
53  prevTime = curTime;
54 
55  return deltaTime;
56 }
static Uint64 prevTime
Definition: common.c:39
Uint64 SDL_GetPerformanceFrequency(void)
Get the count per second of the high resolution counter.
uint64_t Uint64
Definition: SDL_stdinc.h:216
#define SDL_GetPerformanceCounter