Mercurial > sdl-ios-xcode
comparison XCodeiPhoneOS/Demos/src/common.c @ 2381:d3952f445f4d gsoc2008_iphone
Files used by all demos (random numbers, screen size, etc)
author | Holmes Futrell <hfutrell@umail.ucsb.edu> |
---|---|
date | Fri, 18 Jul 2008 20:51:25 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2380:7fbcfc1574dc | 2381:d3952f445f4d |
---|---|
1 /* | |
2 * common.c | |
3 * written by Holmes Futrell | |
4 * use however you want | |
5 */ | |
6 | |
7 #include "common.h" | |
8 #include "SDL.h" | |
9 #include <stdlib.h> | |
10 | |
11 /* | |
12 Produces a random int x, min <= x <= max | |
13 following a uniform distribution | |
14 */ | |
15 int randomInt(int min, int max) { | |
16 return min + rand() % (max - min + 1); | |
17 } | |
18 /* | |
19 Produces a random float x, min <= x <= max | |
20 following a uniform distribution | |
21 */ | |
22 float randomFloat(float min, float max) { | |
23 return rand() / (float)RAND_MAX * (max - min) + min; | |
24 } | |
25 | |
26 void fatalError(const char *string) { | |
27 printf("%s: %s\n", string, SDL_GetError()); | |
28 exit(1); | |
29 } |