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.
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