Use random in the Geometry game?


#1

Hi,

For Random(10) it means 0-9.
1)Does RandomInRange(1,4) means 1,2,3 only?
2)Why must we take RandomInRange(80, 640-80)? Why cant we straight take (80, 560)?

Thanks again!


#2

The random in range has a minimum and a maximum value.

The first number in the brackets is the minimum value and is followed by comma then the maximum value.

You can write it with the subtraction in it, gdevelop would subtract it.


#3
  1. Random(10) means 0-10
  2. RandomInRange(1, 4) means 1,2,3,4
  3. RandomInRange(80, 640-80) means from 80 to 560. you can use RandomInRange(80, 560) instead.

#4

After reading Gem Dev and Gyuszko comments it sounds like you can write it either way, with 560, or by using 640-80.

Now going off that info, my guess is that the person who programmed it had a screen resolution set to 640 width. So they wrote (80, 640-80) to demonstrate that the boundary range is exactly 80 from the left and 80 from the right sides of the screen. So that means if your resolution was different, then you could instead use (80, your game resolution - 80). Say if a game’s resolution is 800 width, then you could use (80, 800 - 80) . Just guessing but I might be wrong.


#5

Thanks a lot for your explanation! Helps me understand more


#6

Thanks a lot for your explanation! :wink:


#7

Thanks for explaining the details :slight_smile: