aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/core.c b/src/core.c
index 7261aaaf..920f34a3 100644
--- a/src/core.c
+++ b/src/core.c
@@ -344,7 +344,14 @@ int GetHexValue(Color color)
// Returns a random value between min and max (both included)
int GetRandomValue(int min, int max)
{
- return (rand()%(abs(max-min)+1) - abs(min));
+ if (min > max)
+ {
+ int tmp = max;
+ max = min;
+ min = tmp;
+ }
+
+ return (rand()%(abs(max-min)+1) + min);
}
//----------------------------------------------------------------------------------