[ad_1]
In this video, I look at how to apply the concept of a vector in Processing itself using the PVector class. The video accompanies Chapter 1 from The Nature of Code book.
Twitter:
Read along:
Code:
Help us caption & translate this video!
[ad_1]
In this video, I look at how to apply the concept of a vector in Processing itself using the PVector class. The video accompanies Chapter 1 from The Nature of Code book.
Twitter:
Read along:
Code:
Help us caption & translate this video!
by
Tags:
Easily the best programming videos on YouTube, such a great energy, I'm constantly smiling whilst following along.
thank you so much love ur videos, btw when's the next stream?
Is there any reason why all of this wouldn't work the same in Brackets?
What is the file type for the class Ball?
my ellipse doesnt work when i put my pvectors in please help
Mind if I steal some of that good mood?
@6:13 Living with your weird ramblings. Sometimes those ramblings help me understand better.
Keep the weird ramblings and NEVER cut them out =)
I wish he was my teacher instead of "Te Taka" #boycottTeTaka
What editor to use??
class Ball {
PVector location;
PVector velocity;
Ball() {
location = new PVector(20,20);
velocity = new PVector(4,0);
}
void move(){
location.add(velocity);
}
void turn(){
if (location.x>width-20){
velocity.x=0;
velocity.y=4;
}
if (location.y>height-20){
velocity.x=-4;
velocity.y=0;
}
if (location.x<20){
velocity.x=0;
velocity.y=-4;
}
if (location.y<20){
velocity.x=4;
velocity.y=0;
}
}
void display(){
fill(0);
ellipse(location.x,location.y,20,20);
}
}
Can u tell me why ball is leaving my screen after 1st "run".
Thank you Sir , someday i am gonna meet you and have a cup of tea with you 🙂
I really like your wallpaper. Where did you find it?
Where do you clear your canvas? In my processing window I need to do it manually in a draw function.
Made this to better understand. Used println to print the vectors in console
PVector v1;
PVector v2;
void setup() {
size(500,500);
background(255);
v1 = new PVector(250,250);
v2 = new PVector(10,10);
frameRate(1);
}
void draw() {
noStroke();
fill(255);
rect(0,0,width,height);
// Add vector v2 to vector v1
v1.add(v2);
// subtract vector v2 to vector v1
//v1.sub(v2);
stroke(0);
fill(100);
strokeWeight(5);
line(v1.x,v1.y,v2.x,v2.y);
println("v1" + v1);
println("v2" + v2);
println("-—-");
}
I have to say: I have been following along from I.0 to here, and I'm glad that you've kept all of the codes relatively short (seeing as codes can get thousands of lines long). I have been able to easily replicate your examples—and I hope that I continue to work through this until I can make some sort of game!
how do i write this in my p5 ide?
there is a way to override the + operater in java right?
is a vector essentially a slope?
This guy makes me feel like it's okay to be as awkward as I am and it's so comforting
thank you sir.you are an excellent teacher.your videos are very interactive,funny and above all very easy to learn from.thanks a lot
U made processing funny and lovely for me
THANKK U SO MUCH
I love the way you teach Thank you for doing this , and also the explaining you do makes it easier to understand . Than You
When I say:
location = new PVector(width/2, height/2);
location.x and location.y become 50. It's as if location coordinates are being set to a percentage with respect to the drawing dimensions. If this is the case, I can work with it, but I'd like to know it doesn't seem to be using x and y coordinates directly? My screen size is 800×600 so I expected values of location.x and location.y to be 400 and 300 respectively
Why this channel has only 36k subs.
You are awesome
I watched the 1.4 Vector Math, there is one line I am not sure, mouse.sub(center), I was wondering what is the "centre" stands for? Million Thanks!
I get this error when I tries to declare "private PVector position;":
Cannot find a class or type named "PVector"
could you replace my programming tutorial teacher??
These are great, thanks Dan! …I have a feeling I'm not the only one learning this in Processing and then translating it for use in p5.js along the way. It's a great exercise, but is there a Nature of Code p5.js repository somewhere?
Thank you very much.Thats what I call infotainment! Keep going Mr Shiffman
super excellent and entertaining presentation. Thank you so much for the effort Daniel!
super excellent and entertaining presentation. Thank you so much for the effort Daniel!
Leave a Reply