summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/SDL2/Xcode-iOS/Demos/src/common.c
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/SDL2/Xcode-iOS/Demos/src/common.c')
-rw-r--r--3rdparty/SDL2/Xcode-iOS/Demos/src/common.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/3rdparty/SDL2/Xcode-iOS/Demos/src/common.c b/3rdparty/SDL2/Xcode-iOS/Demos/src/common.c
new file mode 100644
index 00000000000..b2d96345669
--- /dev/null
+++ b/3rdparty/SDL2/Xcode-iOS/Demos/src/common.c
@@ -0,0 +1,36 @@
+/*
+ * common.c
+ * written by Holmes Futrell
+ * use however you want
+ */
+
+#include "common.h"
+#include "SDL.h"
+#include <stdlib.h>
+
+/*
+ Produces a random int x, min <= x <= max
+ following a uniform distribution
+*/
+int
+randomInt(int min, int max)
+{
+ return min + rand() % (max - min + 1);
+}
+
+/*
+ Produces a random float x, min <= x <= max
+ following a uniform distribution
+ */
+float
+randomFloat(float min, float max)
+{
+ return rand() / (float) RAND_MAX *(max - min) + min;
+}
+
+void
+fatalError(const char *string)
+{
+ printf("%s: %s\n", string, SDL_GetError());
+ exit(1);
+}