Using the mapping function can help you write less code;)
public static float map(float value, float smallestValue, float largestValue, float smallestReturn, float largestReturn) {
return smallestReturn + (largestReturn - smallestReturn) * ((value - smallestValue) / (largestValue - smallestValue));
}
→ 0 1 .
, value = 0, value = 1
: 1 16.
(int) map( randomGeneratedNumber , 0 , 1 , 1 , 16 );
, !