7.4: Adding and Removing Objects - p5.js Tutorial

  Рет қаралды 108,290

The Coding Train

The Coding Train

Күн бұрын

Пікірлер: 106
@smplchmp
@smplchmp 5 жыл бұрын
You are an excellent teacher! I often find myself reviewing fundamentals to stay sharp and nothing's worse than wasting time in an incoherent video or verbose documentation. Your flow is just right - informative, concise, and even entertaining so thank you!
@chaseh5639
@chaseh5639 8 жыл бұрын
Dear Daniel, I am getting my life right now watching your videos. A+
@TheCodingTrain
@TheCodingTrain 8 жыл бұрын
glad to hear!
@goldthumb
@goldthumb 2 жыл бұрын
Using lovely bubbles to teach JavaScript array is much much better than using plain integers as most of coding teachers did.
@dwighthayles1226
@dwighthayles1226 3 жыл бұрын
Daniel your teaching is really clear and it's also fun to see how the code can add or remove objects with the bubbles.
@diegoferreira3444
@diegoferreira3444 7 жыл бұрын
i reaaly like when you use analogy to explain things because programming is so abstract, and is nice to come with a picture of what's going on in the program
@X21XXI
@X21XXI 7 жыл бұрын
I don't even notice how long these videos are, so helpful.
@YnteryPictures
@YnteryPictures 9 жыл бұрын
You're just making my every day with these tuts! Seriously, my thing finally works!!YEEEEEEEEEEEEEEY :D someday I'll donate you a fucking million, just wait for it :3
@TheCodingTrain
@TheCodingTrain 9 жыл бұрын
+YnteryPictures So glad to hear!
@AK56fire
@AK56fire 3 жыл бұрын
Brilliant tutorial.. All of them.. Your energy is very fascinating to watch..
@kansel5813
@kansel5813 5 жыл бұрын
8:02 "I'm sure you have a question but you can't ask it" LMAO
@OlivioSarikas
@OlivioSarikas 7 жыл бұрын
For some reason mouseDragged does not work for me, although mousePressed works perfectly. Did anything change in P5 that prevents this from working? - It does work wiht mouseMove however, but that's not the same
@TheCodingTrain
@TheCodingTrain 7 жыл бұрын
Not that I know of!
@OlivioSarikas
@OlivioSarikas 7 жыл бұрын
strange. also thx for the answer. here is my code, maybe you can have a quick look at it: piratepad.net/91XoUUiAMa
@flipp_
@flipp_ 7 жыл бұрын
I've got the same problem! Have you found a solution yet?
@kiragibson3112
@kiragibson3112 7 жыл бұрын
that's a cool program
@gluetubeserver
@gluetubeserver 8 жыл бұрын
here is what did for the last challenge bit you mentioned of removing the objects when they are offscreen. function draw() { background(0); for (var i = 0; i < bubbles.length; i++) { if (bubbles[i].x > width || bubbles[i].y > height || bubbles[i].x < 0 || bubbles[i].y < 0) { console.log("out of bounds, deleting"); bubbles.splice(i, 1); break; } bubbles[i].move(); bubbles[i].display(); } }
@coderrishav
@coderrishav 4 жыл бұрын
It's like a snake 🐍 😁 Nice Video!
@s.akhtarjoomun263
@s.akhtarjoomun263 3 жыл бұрын
The rest of the world: It's cardio time. I need to get to the gym. Daniel: It's cardio time. I need to make a video
@typicallucas
@typicallucas 8 жыл бұрын
Just found your channel, this is an amazing resource - I'm learning a lot!
@Ancient1341
@Ancient1341 7 жыл бұрын
after hours of trying how to figure this out i finally did it
@Rapsoodys
@Rapsoodys 7 жыл бұрын
thanks dude .. u explain way better tha thos hindi vedeos i watched ...
@tasneemalam1359
@tasneemalam1359 2 жыл бұрын
thank you for making video , i hope you started a playlist about real analysis....
@rosapinkk11
@rosapinkk11 7 жыл бұрын
Thanks a lot, all your videos are very good. i learn a lot. :D
@zoomboost
@zoomboost 7 жыл бұрын
thank you for your work, it's fantastic!
@TheCodingTrain
@TheCodingTrain 7 жыл бұрын
Thank you so much!
@hcgreier6037
@hcgreier6037 2 жыл бұрын
It's nice when the Javascript teacher has a _promise_ for us....🤣
@zem.w5783
@zem.w5783 4 жыл бұрын
better than my online cores from uni
@MyPlaylist-xq8en
@MyPlaylist-xq8en 5 жыл бұрын
Awesome explanation! I give you my "Like" and "Subscribe". Good Job!
@HyperActive94
@HyperActive94 6 жыл бұрын
great explanation! love it! thanks
@cap.blue-97sama99
@cap.blue-97sama99 6 жыл бұрын
Great content!
@RABWA333
@RABWA333 7 жыл бұрын
very informative. thanks
@akshaypratap9376
@akshaypratap9376 4 жыл бұрын
what is the key difference between the java object and if the same thing achieves with the java classes?
@ralfspinoza
@ralfspinoza 6 жыл бұрын
good work. Thank you for that.
@Demobnector
@Demobnector 4 жыл бұрын
is this html5? cuz I am on a standard html. Is the html different to html5?
@dimashishkov2909
@dimashishkov2909 8 жыл бұрын
Daniel, first of all let me thank you for great job. These tutorials are both informative and very entertaining. A real please to watch and learn. I have a little question regarding this tutorial. Let's say we have a Bubble object which has 2 parameters X ad Y: "Bubble (x, y)" and I have global variable stated at the top of the sketch with the same names "var x", "var y". How could I access those global variables inside the object? Is it possible or am I missing some important concept here? Thank you very much in advance.
@TheCodingTrain
@TheCodingTrain 8 жыл бұрын
+Dima Shishkov the global variables are accessible by just referencing their name alone - "x" and "y"!
@dimashishkov2909
@dimashishkov2909 8 жыл бұрын
+Daniel Shiffman but in the video you refer to the Bubble's parameter (those in brackets) as "this.x = x", where "x" refers to the "x" in the Bubbles brackets. I did a quick test and even If I declare global parameters "x" and "y" and write "this.x = x" and "this.y = y", those "x" and "y" are still taken from the Constructor's brackets. So I can't declare global variables with the same names as in Constructor's brackets? Sorry, maybe I am missing something obvious, but I am quite new to programming.
@tz2014
@tz2014 7 жыл бұрын
yeah u are missing something obvious,because when u have "x" and "Y" in brackets they overwrites "x" and "y" declared as global variables at the top. This is how it works, if u have a two variable with the name one global and other in a function(like those in brackets), the global variable get overwritten,the javascript engine refer to the immediate one.
@scharfer56
@scharfer56 9 жыл бұрын
Alternatively, you can simply use the shift() method on an array to remove the first item from it.
@TheCodingTrain
@TheCodingTrain 9 жыл бұрын
+Ryan Scharfer Good tip, thanks!
@timetravellers8909
@timetravellers8909 9 жыл бұрын
Mr. Shiffman, how can I do a push() in Processing? Is it possible? If not, what's the workaround to achieve the same effect (adding bubbles when clicking) thanks!
@TheCodingTrain
@TheCodingTrain 9 жыл бұрын
+timetravellers You can use an ArrayList and the function add(). Here is a tutorial that shows some of this: kzbin.info/www/bejne/fp-2e41qprmWrbs
@timetravellers8909
@timetravellers8909 9 жыл бұрын
+Daniel Shiffman That's exactly what I was looking for, thanks a lot! Best videos on P5/Processing ever!
@TheCodingTrain
@TheCodingTrain 9 жыл бұрын
+timetravellers glad to hear!
@sadielectricalelectronicss8595
@sadielectricalelectronicss8595 6 жыл бұрын
Love you bro.....
@kic3000
@kic3000 7 жыл бұрын
Hi, Daniel, thanks for your videos. Im very enjoying with them. Here im trying to make some effect like, once you mouseDragged the circle, and with 1click , they will spread to random direction(out of screen). so, is there anyway to override the move() function of the constructor function of Bubble? thanks!
@marqimoth6987
@marqimoth6987 3 жыл бұрын
how do i delete something depending if the if function gets triggered
@bencruz7906
@bencruz7906 7 жыл бұрын
THANK YOU AWESOME!!!
@ashishchauhan7239
@ashishchauhan7239 6 жыл бұрын
hlo sir i am trying to store multiple data in local storage but errors can you help me to resolve this ?
@jaiir3203
@jaiir3203 6 жыл бұрын
How should I make an object in p5.js, by using the var bubble = function (){} method or should I use function bubble(){} What's the difference
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
Try ES6 classes! kzbin.info/www/bejne/rniVh5Wkq5WqrMk
@scharfer56
@scharfer56 9 жыл бұрын
Do you know how to configure the window that opens up when you preview your project to be exactly the size of the canvas? I like to create a 500*500 canvas, but when I preview the project, the window that opens up is 400*400 or so and I have to drag and stretch the window to see the whole canvas. I know running in the browser is an option, but I like the little pop up window...
@TheCodingTrain
@TheCodingTrain 9 жыл бұрын
+Ryan Scharfer Go and get the most recent editor. It should do this for you automatically. If you change the window size manually it will keep your manual adjustment, but you can reset that by quitting and relaunching the editor. See: github.com/processing/p5.js-editor/releases You can also file bug reports here if it's not working as you expect: github.com/processing/p5.js-editor/issues
@S0KE
@S0KE 8 жыл бұрын
Hey Daniel! I'm having kind of a problem here. I'm making a sidescrolling game using the translate function you showed in another video (I set the translate function to move on the Y axis based on the character position). I was testing something with the push and splice function and I made it add a new object to an array and delete the oldest one everytime I click, just like you did in this video. It seemed to work fine, however, I noticed that when I move my character up and click on the screen mouseY does not seems to be translated, because the objects start to apear down, in other words, it keeps appearing where the mouseY would be in the starting position as if I never moved the character at all. Is this behavior expected? If for example I click on 100,100 and then use translate to move my view -200 on the Y axis and click again, shouldn't I be clicking on 100,-100 now?
@KuyruksuzSatyr
@KuyruksuzSatyr 6 жыл бұрын
10:17 its fun for us too, we are all weird don't worry :D
@herrjose
@herrjose 4 жыл бұрын
daniel rules!
@zoecarlibur
@zoecarlibur 8 жыл бұрын
that was fun!
@tarekmustafa2525
@tarekmustafa2525 8 жыл бұрын
Awesome!
@havearelax31401
@havearelax31401 3 жыл бұрын
everything ok but I am not seeing that bubbles|||| vscode shows that its running but cannt see the exact output u showed
@videosaver1934
@videosaver1934 Жыл бұрын
This is p5js
@SaintPepsiSanCoca
@SaintPepsiSanCoca 9 жыл бұрын
Once again i got a question: I'm using the constructor function to create something(moving image for example) when mouseIsPressed. and when that "image" gets to a certain point, it resets back to its first position. but when i let go of the mouse before it hits the end value, and i click again. it just starts where I last let go of the mouse. How do I make it so that when my mouse is released it also resets its value. because I can't call it's reset function from out of the for loop.
@TheCodingTrain
@TheCodingTrain 9 жыл бұрын
+skrubritos you can! I would simply write a new function (or re-use an existing one) and call that function in the mouseReleased() event handler,i.e. function mouseReleased() { yourobject.reset(); }
@SaintPepsiSanCoca
@SaintPepsiSanCoca 9 жыл бұрын
+Daniel Shiffman thank you! but it's a little hard to target what i want to reset. because i used an array constructor to create something while the mouse is pressed within a if mouseispressed in the draw function. when i try to target the function in my object that's been created with the constructor function and thats in a for loop. if i try to target it outside of the for loop it says that its not a function. (so complicated) pff. thanks again for the help. final question. if the function is a mouseIsPressed. do i even need to use the constructor function? because I had it without constructor function before and then it did reset when i let go but the image wouldn't dissapear(reset) when it got to the and
@SaintPepsiSanCoca
@SaintPepsiSanCoca 9 жыл бұрын
+Daniel Shiffman sorry that was a really long message. I can't try what you said right now so all the coding thats going on is in my head so as soon as i can test the reset() function i'll let you know. also I had send you an email on your contact adress :)
@SaintPepsiSanCoca
@SaintPepsiSanCoca 9 жыл бұрын
+Daniel Shiffman one more addition to the mouseRelease it seems to trigger even when I havn't told it to do something. is that correct or does it do something that i'm not aware of :)
@SaintPepsiSanCoca
@SaintPepsiSanCoca 9 жыл бұрын
Daniel Shiffman Nevermind. thanks for the help! my Javascript/Jquery teacher helped me understand what i did wrong. Keep making videos shiffgod :3
@alvaromorales6828
@alvaromorales6828 8 жыл бұрын
Hey men , I am getting a little bit lost lately, but I don't wanna to rewatch your videos again , Can you provide some pdf or text document where I can go over ..?
@zyzo99
@zyzo99 6 жыл бұрын
Hello, what about AdobeJS ?Do you plan some videos about it? cheers! ))
@kikesitosk8xoxtla
@kikesitosk8xoxtla 7 жыл бұрын
What library are you using?
@fariat
@fariat 6 жыл бұрын
thanks
@GhostStyle007
@GhostStyle007 2 жыл бұрын
i don't rly understand what's the challenge you talked about at the end, i just added that at the end of your "for" loop: if(bubbles[i].x>width){ bubbles.splice(i,1) } and it works like expected
@tazulislam2698
@tazulislam2698 4 жыл бұрын
How to separate unique object from JSON array? please make a video.
@Markos_o
@Markos_o 7 жыл бұрын
hallo Dan , i can not download p5 !! why that ?
@kiragibson3112
@kiragibson3112 7 жыл бұрын
I'm having a really hard time understanding why you need the for loops in the example he uses. Why can I not just have the constructor function and the mousePressed function and that work? Why is the for loops a necessity? Why is the bubbles.length loop needed to have the mousePressed event work? Please help me understand this, someone. It's hard to look this stuff up on the internet and get a direct answer to my very specific question without someone here that can guide me through it.
@hyfahyf1552
@hyfahyf1552 5 жыл бұрын
How can we delete json genie array permanent
@deepakvishwakarma2043
@deepakvishwakarma2043 3 жыл бұрын
What is he using to code ???
@kbryanolan
@kbryanolan 5 жыл бұрын
oh..I'm not alone 🙊
@AlexOchs
@AlexOchs 7 жыл бұрын
am i the only one who has a problem with for loops? everytime i try to use one in p5.js i get the error "Move 'var' declarations to the top of the function."
@animore8626
@animore8626 7 жыл бұрын
Are you getting any hints as to what line of code is causing the error?
@johncerpa3782
@johncerpa3782 7 жыл бұрын
mouseDragged is not working for me
@saipanidarapu6656
@saipanidarapu6656 7 жыл бұрын
try to add the p5 library to your editor, i think its an inbuilt function.
@itzspellon1330
@itzspellon1330 3 жыл бұрын
i wanted to make if something touch the rect the rect disapears
@zandgall1837
@zandgall1837 7 жыл бұрын
You should make it so that every time you click, a new blue blob appears!
@marineoutsource
@marineoutsource 4 жыл бұрын
Wow ... !!!
@alnayab
@alnayab 6 жыл бұрын
ur awsme
@alonsomartins712
@alonsomartins712 2 жыл бұрын
7:37 Sempre que ele faz isso nos vídeos eu acho muito engraçado kskk
@SMC4free
@SMC4free 4 жыл бұрын
I was looking for an answer of that problem in the end of the video 🤦‍♂️
@Hydr312
@Hydr312 8 жыл бұрын
what about the "add" and "remove" comment ?
@andresfelipesierrasi
@andresfelipesierrasi 8 жыл бұрын
interesante p5 js
@lizabeti3457
@lizabeti3457 6 жыл бұрын
Awe You can also use array.split(indexOf(whatever), 1); which checks what’s the index of whatever 😂
@arieluzal
@arieluzal 8 жыл бұрын
These tutorials are all excellent! Could you possibly make one explaining inheritance in p5.js (eg: p5js.org/examples/examples/Simulate_Multiple_Particle_Systems.php)? Thanks!
@TheCodingTrain
@TheCodingTrain 8 жыл бұрын
Oh good idea! Suggest here: github.com/CodingRainbow/Rainbow-Topics/issues
@Mohammad_Awais
@Mohammad_Awais 7 жыл бұрын
* Need help!! Facing the issue while doing the same task in processing.. Bubble[] bubbles = new Bubble[50]; void setup() { size(600, 400); for(int i = 0; i < bubbles.length; i++) { bubbles[i] = new Bubble(); } } void draw() { background(0); for(int i = 0; i < bubbles.length; i++) { bubbles[i].move(); bubbles[i].display(); } } void keyPressed() { bubbles.splice(0,5); //here is the issue!! } ====== class Bubble { float x = random(0, width); float y = random(0, height); void display() { stroke(255); fill(255, 0, 150, 50); ellipse(x, y, 24, 24); } void move() { x = x + random(-1, 1); y = y + random(-1, 1); } }
@hyfahyf1552
@hyfahyf1552 5 жыл бұрын
Helllo
@zaidmohammed9380
@zaidmohammed9380 6 жыл бұрын
he didnt get anywhere
@jupiterjs031
@jupiterjs031 6 жыл бұрын
thanks
7.6: Checking Objects Intersection Part I - p5.js Tutorial
15:57
The Coding Train
Рет қаралды 105 М.
you will never ask about pointers again after watching this video
8:03
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
AI Is Making You An Illiterate Programmer
27:22
ThePrimeTime
Рет қаралды 277 М.
Wave Function Collapse: Overlapping Model
1:32:09
The Coding Train
Рет қаралды 38 М.
Coding a Web Server in 25 Lines - Computerphile
17:49
Computerphile
Рет қаралды 362 М.
7.7: Deleting Objects Using splice() - p5.js Tutorial
15:49
The Coding Train
Рет қаралды 34 М.
Coding Challenge 180: Falling Sand
23:00
The Coding Train
Рет қаралды 1,1 МЛН
Map vs Object in JavaScript
14:33
Leigh Halliday
Рет қаралды 22 М.
7.5: Removing Objects from Arrays - p5.js Tutorial
18:24
The Coding Train
Рет қаралды 101 М.
An Engineering Fairy Tale: Cascade Failure at the Super Kamiokande
22:21
Alexander the ok
Рет қаралды 721 М.
Coding Challenge 182: Apollonian Gasket Fractal
56:48
The Coding Train
Рет қаралды 90 М.
How do non-euclidean games work? | Bitwise
14:19
DigiDigger
Рет қаралды 2,5 МЛН