CodingTrain / CodingTrain/Suggestion-Box

Objects and images 7.8

Open
#1,503 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
570
Forks
85
PR merge metrics
No merged PRs in 30d

Description

In your video you created an array of file names and used CONCATENATE to pass through a link to the image.

I want to use the array [i] to load the image from an array of URL’s, they have no logical file name so I need to reference the array index no. Instead.

I want to click the mouse and a new array index no. Is chosen and the image loaded.

Thanks!

Code:

var urls = [ "https://i.imgflip.com/tau4.jpg", "https://i.imgflip.com/2cp1.jpg", "https://i.imgflip.com/5kdc.jpg", "https://i.imgflip.com/1bgs.jpg", "https://i.imgflip.com/cv1y0.jpg", "https://i.imgflip.com/320xfw.jpg " ];

var bubbles = [];
var memeImg;

function preload() {

vvvvvvvvvvvvv
memeImg = loadImage(urls[3]); **** this loads the urls array index 3 *****
}
^^^^^^^^^^^^^^^ this part needs to random select an index no.

function setup() {
createCanvas(600, 400);


}
function mousePressed(){

var b = new Bubble(mouseX, mouseY, memeImg) ;
bubbles.push(b)
print(bubbles)
}

function draw() {
background(0);
for (var i = 0; i < bubbles.length; i++) {
// bubbles[i].move();
bubbles[i].display();

}
}

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.