File: assets/js/math/random.js

Recommend this page to a friend!
  Classes of Leonardo Mauro Pereira Moraes   TapAI   assets/js/math/random.js   Download  
File: assets/js/math/random.js
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: TapAI
Study user interactions with a tap on screen game
Author: By
Last change: Update of assets/js/math/random.js
Date: 2 years ago
Size: 733 bytes
 

Contents

Class file image Download
// Closure (function(){ /** * Random floating point number between `min` and `max`. * * @param {number} min - min number * @param {number} max - max number * @return {float} a random floating point number */ function getRandomFloat(min, max) { return ((Math.random() * (max - min)) + min); } /** * Random integer between `min` and `max`. * * @param {number} min - min number * @param {number} max - max number * @return {int} a random integer */ function getRandomInt(min, max) { return Math.floor((Math.random() * (max - min + 1)) + min); } // Random Float if (!Math.randomf) { Math.randomf = getRandomFloat; } // Random Int if (!Math.randomi) { Math.randomi = getRandomInt; } })();