vendredi 29 mai 2020

How do i make something random in a function?

i have a function with some images in it here

function rain() {
    ctx.drawImage (image1, x, y, 100, 50);
    ctx.drawImage (image2, x, y, 100, 50);
    ctx.drawImage (image3, x, y, 100, 50);
    ctx.drawImage (image4, x, y, 100, 50);
}

How do i make this function randomly choose one of these images when i call it?




Aucun commentaire:

Enregistrer un commentaire