Hi, i’m newbie to p5.js, and I just want to reproduce this simple code : https://www.youtube.com/watch?v=17WoOqgXsRM
I’ve set up my p5 environment on Atom editor with local server to see my results on browser.
So I have my main class sketch.js and an outer class Star and I want to instantiate Star object in my main class but I got unexpected identifier error for ‘Star’ in my console. I thought by adding <script src="Star.js"></script>
in index.html would solve the problem but it didn’t.
I need to import this class but I don’t how. Thanks for the help in advance !
Sorry, it’s a mistake I think, the class has been correctly imported. The error is something else but I can’t understand what. Here’s a picture of my console :
Welcome to the forum!
It would be great if you can share entire the code although I can see a portion in your screenshot.
From what I see in the image, it’s not how it works in JavaScript. It has quite different syntax from Java, and you cannot simply copy & paste to make it work. You might want to watch some tutorials on the Coding Train to learn p5.js:
Also if you want the answer, in fact the Coding Train already made a p5.js version of the starfield, which you can find on their website:
1 Like
Thank you, yes for a first post it is not clear at all, I will do better next time by adding all the code and complete description.
Ohh ok ! I watched the video of the Coding Train “Coding challenge number 1” but I did not understand that it was in java and not in javascript, I feel stupid for that ^^’
Thanks a lot !
no problem! I think the newer episodes of the coding challenges are in p5.js, but most of them have p5.js versions even if they were originally coded in processing (java)
1 Like