It's important that our enemies have a random chance of selecting various attacks, otherwise, our game would be quite dull with Draggle activating "Tackle" 24/7. Here we'll learn a quick technique for randomizing the attacks available to an enemy.
Get 50% off all memberships! Black Friday offer ends Dec. 6 @11:59pm EST. View Pricing
Premium Features
Published 3 years ago
It's important that our enemies have a random chance of selecting various attacks, otherwise, our game would be quite dull with Draggle activating "Tackle" 24/7. Here we'll learn a quick technique for randomizing the attacks available to an enemy.
Comments
Want to participate?
Create a free Chris Courses account to begin
Hi ! How could I randomize damages ? I tried this :
function getRandomArbitrary(min, max) { return Math.random() * (max - min) + min; }
Waterball : { name: 'Waterball', damage: Math.floor(getRandomArbitrary(10, 45)), type: 'water', },
But it is only randomizing once