Ask coding questions

← Back to all posts
My Number Generator needs to be better so my code works (phaser.js)

In this small snip of code, I want to make it so each time, the random number it generates is different. For some reason, when I run the game, whenever a golden egg appears, it keeps appearing in the same spot. Say 1 golden egg appears in the first round. It will keep appearing in the same spot on every round after it as well. The number of golden eggs won't change and neither will the location. I want to fix it so that the number of golden eggs appearing are different each time and the location of the golden egg so its purely random each round.

(This is PHASER.JS code)


Can someone please help me?