Ask coding questions

← Back to all posts
I can't run this repl that I copy-pasted from Khan Academy
Wilke000 (346)

Please help me! I copy-pasted code from a thing I did in Khan Academy and it is not working!

Answered by Vandesm14 (2217) [earned 5 cycles]
View Answer
Commentshotnewtop
Vandesm14 (2217)

Khan academy uses p5 JS which requires a library to be installed.
Refer to this template to get started with p5 JS.

Wilke000 (346)

But then why when the mouse goes out of the canvas @Vandesm14, the canvas dosn't go all one color

VulcanWM (1741)

Maybe you got to run the function.

Vandesm14 (2217)

@medcho On the script tag of index.html (not the script.js one), change the src to https://cdnjs.cloudflare.com/ajax/libs/processing.js/1.6.6/processing.min.js

Vandesm14 (2217)

@IndyCarter oh wait @medcho is right. Replace the src with the old one and create the functions like this instead:

draw() {
    stroke(249, 252, 251);
    fill(mouseX, mouseY, 0);
    ellipse(mouseX, mouseY, 40, 40);
};
mouseOut() {
    ellipse(300, 300, 100000, 1000000);
    };

Note: you might need a setup function as well so copy that from the template if it still doesn't work.

Wilke000 (346)

Just come in the repl