PDA

View Full Version : Anybody familiar with JavaScript?


Mindless
02-22-2017, 12:42 AM
I've been watching this YouTube channel where this professor at NYU teaches Java and JavaScript and he does these coding challenges. The guy is weird as fuck but for some reason his antics make it so I can actually learn the coding stuff w/o my eyes glazing over and wanting to kill myself.

Anyway, the most recent coding challenge was this little thing that you could put text in and it would convert that text into dots and those dots would automatically seek their location in order to form that text. Then you could move the mouse over it and it would scatter the dots within a certain number of pixels of the pointer and if the pointer was far enough from then the it would automatically move the dots back into place. At the end of the video the professor makes suggestions for what people should do with the code and one of the things was change the colors of the dots to colors of the rainbow. The channel used to be called Coding Rainbow (Like Reading Rainbow) and I figure that should be an easy enough thing to do. What I ended up creating though is a seizure inducer and I can't figure out what the fucking deal is. I'm pretty sure it's assigning a new color to each dot every time the draw() function runs but I'm at a loss at how to prevent that or change it.

Here's the code where I give it the color scheme
Vehicle.prototype.show = function() {
var vRed = [209, 0, 0];
var vOrange = [255, 102, 34];
var vYellow = [255, 218, 33];
var vGreen = [51, 221, 0];
var vBlue = [17, 51, 204];
var vIndigo = [34, 0, 102];
var vViolet = [51, 0, 68];
var RoyGBiv = [vRed, vOrange, vYellow, vGreen, vBlue, vIndigo, vViolet];

var vColor = random(RoyGBiv)

strokeWeight(8);
stroke(vColor[0], vColor[1], vColor[2]);
//stroke(255);
point(this.pos.x, this.pos.y);
}

Here's a github repo with the entirety of the code for the thing: https://github.com/CodingTrain/Rainbow-Code/tree/master/challenges/CC_59_Steering_Text_Paths

Shodan
02-22-2017, 02:17 AM
I don't know the answer to your question, but why ask this sort of question on a rap battle forum? Wouldn't make much sense to ask a question about a rap lyric on a software forum...

Nicholas
02-22-2017, 03:37 AM
I don't know the answer to your question, but why ask this sort of question on a rap battle forum? Wouldn't make much sense to ask a question about a rap lyric on a software forum...

Actually I find it refreshing to read something different even if I have no idea how to help the OP.

Mindless
02-22-2017, 08:48 AM
I don't know the answer to your question, but why ask this sort of question on a rap battle forum? Wouldn't make much sense to ask a question about a rap lyric on a software forum...

Because I know there are coders here and the coding board I put it in is slow as fuck.

Mindless
02-22-2017, 12:45 PM
X?

And I thought you wrote php or something Nicholas?

Nicholas
02-22-2017, 01:01 PM
X?

And I thought you wrote php or something Nicholas?

No, I can't code. I started learning at one point so may of posted on here at the time? It's one of those things I've wanted to do for ages but not done.

Mindless
02-23-2017, 02:25 AM
No, I can't code. I started learning at one point so may of posted on here at the time? It's one of those things I've wanted to do for ages but not done.

https://www.youtube.com/user/shiffman

The guy is cringey as fuck but he explains Java and JavaScript w/o making you want to eat a bowl of cheerios with bleach instead of milk. Give it a shot if you're interested.