I'm a newcomer to using Javascript in a canvas, and coding with javascript overall.
My primary goal is the following:
- Create numerous fireballs (images) that spawn randomly with each having a fixed y-value and random x-value.
- The fireballs should then fall at various speeds determined by individual variables.
I have managed to implement the random x positions and locked y values. However, I am struggling with finding a way to assign separate speed variables for each new image to control their falling rate. It would be ideal if this could be applied to every single fireball individually like so:
fireBallSpeed = 10;
fireBallTop = 0;
if (randomSpawn == 1){
fireBallTop += fireBallSpeed;
fireBall.style.top = fireBallTop + 'px';
ctx.drawImage(fireBall, randomX, fireBallTop, 50, 50);
}