changeset 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 7fbcfc1574dc
children 36bcf13ccb48
files XCodeiPhoneOS/Demos/src/common.c XCodeiPhoneOS/Demos/src/common.h
diffstat 2 files changed, 41 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XCodeiPhoneOS/Demos/src/common.c	Fri Jul 18 20:51:25 2008 +0000
@@ -0,0 +1,29 @@
+/*
+ *	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);
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XCodeiPhoneOS/Demos/src/common.h	Fri Jul 18 20:51:25 2008 +0000
@@ -0,0 +1,12 @@
+/*
+ *	common.h
+ *	written by Holmes Futrell
+ *	use however you want
+ */
+
+#define SCREEN_WIDTH 320
+#define SCREEN_HEIGHT 480
+
+extern int randomInt(int min, int max);
+extern float randomFloat(float min, float max);
+extern void fatalError(const char *string);
\ No newline at end of file