Premium Features

Download Video

Randomize Attacks

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

Login
b
beyondnaxos posted 3 years ago

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

0

Providing the lift to launch your development career

© 2026 Chris Courses. All rights reserved.