This repository has been archived by the owner on Feb 11, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Files used by all demos (random numbers, screen size, etc)
- Loading branch information
Holmes Futrell
committed
Jul 18, 2008
1 parent
64fad7a
commit 8434cfc
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |