Files used by all demos (random numbers, screen size, etc) gsoc2008_iphone
authorHolmes Futrell <hfutrell@umail.ucsb.edu>
Fri, 18 Jul 2008 20:51:25 +0000
branchgsoc2008_iphone
changeset 2381d3952f445f4d
parent 2380 7fbcfc1574dc
child 2382 36bcf13ccb48
Files used by all demos (random numbers, screen size, etc)
XCodeiPhoneOS/Demos/src/common.c
XCodeiPhoneOS/Demos/src/common.h
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/XCodeiPhoneOS/Demos/src/common.c	Fri Jul 18 20:51:25 2008 +0000
     1.3 @@ -0,0 +1,29 @@
     1.4 +/*
     1.5 + *	common.c
     1.6 + *	written by Holmes Futrell
     1.7 + *	use however you want
     1.8 + */
     1.9 +
    1.10 +#include "common.h"
    1.11 +#include "SDL.h"
    1.12 +#include <stdlib.h>
    1.13 +
    1.14 +/*
    1.15 +	Produces a random int x, min <= x <= max 
    1.16 +	following a uniform distribution
    1.17 +*/
    1.18 +int randomInt(int min, int max) {	
    1.19 +	return min + rand() % (max - min + 1);
    1.20 +}
    1.21 +/*
    1.22 +	Produces a random float x, min <= x <= max 
    1.23 +	following a uniform distribution
    1.24 + */
    1.25 +float randomFloat(float min, float max) {
    1.26 +	return rand() / (float)RAND_MAX * (max - min) + min;
    1.27 +}
    1.28 +
    1.29 +void fatalError(const char *string) {
    1.30 +	printf("%s: %s\n", string, SDL_GetError());
    1.31 +	exit(1);
    1.32 +}
    1.33 \ No newline at end of file
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/XCodeiPhoneOS/Demos/src/common.h	Fri Jul 18 20:51:25 2008 +0000
     2.3 @@ -0,0 +1,12 @@
     2.4 +/*
     2.5 + *	common.h
     2.6 + *	written by Holmes Futrell
     2.7 + *	use however you want
     2.8 + */
     2.9 +
    2.10 +#define SCREEN_WIDTH 320
    2.11 +#define SCREEN_HEIGHT 480
    2.12 +
    2.13 +extern int randomInt(int min, int max);
    2.14 +extern float randomFloat(float min, float max);
    2.15 +extern void fatalError(const char *string);
    2.16 \ No newline at end of file