4.2: ArrayLists in Processing - The Nature of Code

  Рет қаралды 76,584

The Coding Train

The Coding Train

Күн бұрын

This video shows how to use an ArrayList for creating a Particle System.
Read along: natureofcode.co...
Example: github.com/shi...
📄 Code of Conduct: github.com/Cod...

Пікірлер: 67
@macieg8234
@macieg8234 5 жыл бұрын
Almost 4 years later - people are still watching your videos. You’re one of the best programming teachers I’ve ever had. I’m IT student from private IT academy and you are better than my lecturer - and your lessons are free. Within couple of weeks I’ll link your videos to my friends that are learning Java too. Stay awesome and make more videos!!! ❤️
@simonhollad5511
@simonhollad5511 4 жыл бұрын
Maybe because its private academy....
@DuniC0
@DuniC0 3 жыл бұрын
And people are still learning Java...
@exhydraboy2429
@exhydraboy2429 6 жыл бұрын
World's best Java Teacher.
@shyamavs4235
@shyamavs4235 4 жыл бұрын
I was in bed, watching this, and sort of falling asleep, imagine my shock when he said 'don't fall asleep, wake up' !!! :O
@ericboyer6652
@ericboyer6652 6 жыл бұрын
Thanks Dan. Fed up with working with predefined size arrays, following you on neural network stuff and trying to implement that in a arduino robot, i got to come back to this usefull video. As usual when stuck, I got to get back to fondementals, and so thanks for this usefull piece. Have a great day.
@72li208
@72li208 5 жыл бұрын
I take a moment to recognize your great work. I'm not a full time programmer but I've been doing a couple of web apps for my company and your javascript tutorial were always of great use, especially that p5.js is used a lot for visual animation and one can see directly the practical meaning behind the code. Now I'm taking up Java and I always have a look at your videos to assimilate the key principles. Thanks a lot !
@wollkann
@wollkann 8 жыл бұрын
This guy is great :) Quite fun to follow...
@TheCodingTrain
@TheCodingTrain 8 жыл бұрын
+Volkan Tuncay Thanks!
@Architector_4
@Architector_4 5 жыл бұрын
When I learned Processing, I ditched any tutorials and only studied the reference. Now I regret doing that. Not because I learned something the bad way or don't know something, but because I missed this beautiful, energetic man. ._.
@bengray8319
@bengray8319 6 жыл бұрын
hey just wanted to give you a massive thank you, you've been a great help to me in this video :)
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
So glad to hear!
@bastibob660
@bastibob660 4 жыл бұрын
Thank you 😁 That really really helped me out Huge respect to your programming and explaining skills 👏
@sulfrum
@sulfrum 7 жыл бұрын
it is what I was looking for... and the number of this video is 42... it couldn't be only a coincidence :P
@johanrojassoderman5590
@johanrojassoderman5590 4 жыл бұрын
Wait, lists have types o.O JavaScript isn't even obnoxious AND consistent. It's just obnoxious. Great video btw, I have done some coding in c# but wanted to try something different, and your videos are as interesting even if it reintroduces things I recognice from c#. Perfect balance between efficiency and clarity.
@elizaknight6980
@elizaknight6980 6 жыл бұрын
Thanks so much, I need this for my game project :)
@newgamedk
@newgamedk 7 жыл бұрын
this is really awesome!
@rgorazd
@rgorazd 7 жыл бұрын
Hi Daniel! First of all, thank you for your everything, giving to us! I really enjoy watching you, explaining things to us with such an enthusiasm! Second, I have a question. In your example, you use particles.add(new Particle()); which in my case does not work. I had to use particles.add(new Particle(new PVector(width/2, 20))); like in the example with only one particle. I'm using Processing 3. Regards!
@FreeDomSy-nk9ue
@FreeDomSy-nk9ue 4 жыл бұрын
That was a very good explanation just like the lag in it.
@zippobrand
@zippobrand 3 жыл бұрын
Hi Dan, I'm really hoping you will revisit this subject in your new Nature of Code and maybe explain how to sort an ArrayList because I'm having a hard time understand this and implement it in processing. Love.
@threadsnakegaming
@threadsnakegaming 4 жыл бұрын
when his get looks like a cross between get and set, perfect for instruction
@threadsnakegaming
@threadsnakegaming 4 жыл бұрын
and the fact that his semicolon looks like a j
@cesarbranco1889
@cesarbranco1889 3 жыл бұрын
Dude this Prof took so much Kaffee, he is kind of crazy! haha I loved it
@polyroguegames5820
@polyroguegames5820 6 жыл бұрын
Hey so if anyone is following this but using p5.js, you don't have to worry about ArrayList, since p5.js' array data structure is dynamic :)
@warrengeorge7126
@warrengeorge7126 6 жыл бұрын
A lot to take in but explained brilliantly
@Charlie05155
@Charlie05155 5 жыл бұрын
Man I really need to thank you
@DancingKeanu
@DancingKeanu 10 ай бұрын
1:24 The way he made that noise 🤣🤣🤣🤣
@imtrying3981
@imtrying3981 6 жыл бұрын
IM SO HAPPY IT VHRISTMAS DAY!!!
@lulila_
@lulila_ 2 жыл бұрын
Hey Dan! Could you make a video about string lists and text input from user? That would be super useful, thanks!!
@DasCartoonLand
@DasCartoonLand 5 жыл бұрын
dude youre the best!
@eandresrodriguez
@eandresrodriguez 5 жыл бұрын
Hi Daniel, you're such a great teacher. I write a "basic game" using processing and what you taught in ArrayList videos, but I got a weird behaviour that I'd like to help with. How could I share you my code to get comments from you or your java programmers followers?
@TheCodingTrain
@TheCodingTrain 5 жыл бұрын
I would suggest discourse.processing.org/! It's a good platform for Processing and p5.js related code questions. You can share code there easily! Feel free to link from here to your post.
@DuniC0
@DuniC0 3 жыл бұрын
Hi, I was wondering... why not use Java's Set, like HashSet, TreeSet or LinkedHashSet?
@END-oc4qu
@END-oc4qu 6 жыл бұрын
Hey if I wanted to multiply a 2 dimensional array by a value like 10 that has 3 rows and 4 columns with initial values present in each location, why would I set the "setw(5)" with the 5 argument instead of a (4) argument in this manipulator function.
@nektoxyz1013
@nektoxyz1013 4 жыл бұрын
why i cant create array of particles with : Particle[ ] particles = new Particle(50); i missed something? or something has changed in JS? Thanks.
@prtysh
@prtysh 7 жыл бұрын
Also, in the description, the link for github location is outdated, you have used a 0 prefix in the new folder structure. Please update the same for other viewers :)
@MicheleZaccagnini
@MicheleZaccagnini 8 жыл бұрын
Daniel, Thanks a lot for your awesome videos. Quick question: I am using Processing in Python mode and I can't find a Python version of ArrayList. Do you know if there is some class that can substitute it? Or is it in the making? Thanks!
@TheCodingTrain
@TheCodingTrain 8 жыл бұрын
+Michele Zaccagnini You can just use a regular array in Python which is exapandable. See the Python Mode examples (Particle System or Flocking) for how it's done. Thanks for watching!
@avemew5407
@avemew5407 2 жыл бұрын
I managed to add and place objects from an array list and delete objects after clicking a button and then the object I want to delete, how in the world can I change the position of ONE object after clicked...? best regards ^^
@lucianopazona9976
@lucianopazona9976 8 жыл бұрын
Gracias!
@Zebsy
@Zebsy 7 жыл бұрын
Good fun watch, thanks. Is this Java ? chrz
@TheCodingTrain
@TheCodingTrain 7 жыл бұрын
Yes indeed it is! (Using Processing as an IDE)
@puffolino1
@puffolino1 7 жыл бұрын
In the beginning you wrote Particle [] particle = new Particel [100];
@thefigmaster3519
@thefigmaster3519 6 жыл бұрын
Hi Dan, great vid! Do you have the working github link?
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
(Fixing! github.com/shiffman/The-Nature-of-Code-Examples/tree/master/chp04_systems/NOC_4_02_ArrayListParticles)
@DancingKeanu
@DancingKeanu 10 ай бұрын
3:46 Hooray!!! 🤣🤣🤣🤣🤣
@titiento
@titiento 6 жыл бұрын
That "for" changed me
@BlueTarkus
@BlueTarkus 7 жыл бұрын
I don't think I fully understood the .get() method. When you write Particle p = particles.get(4); p.update(); it means you're declaring a copy of the 5th particle and you're naming the copy "p", right? so with p.update() you're updating the copy, not the array itself, right? what am I missing here?
@reginahilt
@reginahilt 7 жыл бұрын
He said it passed the reference of the object. That means it is accessing the object itself and updates it.
@bettyevdokiagulayev4495
@bettyevdokiagulayev4495 4 жыл бұрын
love
@scamrev5800
@scamrev5800 7 жыл бұрын
Wish I could find out how to get past the get(0) to the values of the objects. Without 50 lines of code
@bennybrouwer
@bennybrouwer 7 жыл бұрын
It is not very clear in the documentation but as far as I understand, .get() is deprecated and should be replaced by the .copy() function, e.g. for copying a PVector named loc: location = new PVector(); location = loc.copy(); however, for a particle, the get() function still works - I don't know why
@samvoor496
@samvoor496 3 жыл бұрын
what programming language is this in?
@prtysh
@prtysh 7 жыл бұрын
Hey when I try running this, I get: build.pde:7:0:7:0: The constructor build.Particle() is undefined
@andreslok
@andreslok 7 жыл бұрын
Try particles.add(new Particle(new PVector(width/2, 20)));
@eotikurac
@eotikurac 9 жыл бұрын
my particle is a star shape but it is too big. what's a good way to resize the particle? edit: i couldn't do it with scale(), the stars would go crazy and all over the screen. it works with ellipse or rect, weirdly. so i eventually did it by tweaking the vector values and it's sort of okay but it's not the same thing.
@eotikurac
@eotikurac 9 жыл бұрын
+Daniel Shiffman i got the star particles in the right place with this method but they fall more slowly, as if the vector has been affected by scaling the shape down. this is bothering me a little because i don't know what is it that i'm doing wrong, but later in the chapter you showed how to inherit stuff from the main particle and use it for other particles so i got it going eventually and it looks spot on, so it doesn't really matter all that much. thank you.
@maciejjakubiak2828
@maciejjakubiak2828 5 жыл бұрын
Wait, I wrote EXACTLY the same code as you done, but it didn't work. What's going on?
@maciejjakubiak2828
@maciejjakubiak2828 5 жыл бұрын
Sorry, I didn't gave the particular reason of sketch bug. Somewhere in "particles.add(new Particle());", the program returns a error: "The constructor "Particle()" does not exist".
@TheCodingTrain
@TheCodingTrain 5 жыл бұрын
Would you mind asking at discourse.processing.org/! It's a better platform for Processing and p5.js related code questions. You can share code there easily! Feel free to link from here to your post.
@melik-alexandrefarhat2185
@melik-alexandrefarhat2185 5 жыл бұрын
In Java, I've always declared and initialized my arrays like this: float[] numbers = { 1.76, 1.68, 1.89, 1.72, 1.54, 1.78, 1.34, 1.78 };
@DancingKeanu
@DancingKeanu 10 ай бұрын
2:49 "blue" "giant"🤣🤣🤣
@imtrying3981
@imtrying3981 6 жыл бұрын
OOPS i mean CHRISTMAS
@dhruvgaur7047
@dhruvgaur7047 7 жыл бұрын
I want to see you without beard.
@teamnitrogen210
@teamnitrogen210 7 жыл бұрын
that would be really weird
@PTM1008
@PTM1008 4 жыл бұрын
7:24 is the biggest lie ever told in the history of mankind. That too again and again!
4.3: Deleting objects from ArrayList - The Nature of Code
14:59
The Coding Train
Рет қаралды 54 М.
Rust and RAII Memory Management - Computerphile
24:22
Computerphile
Рет қаралды 227 М.
The Joker wanted to stand at the front, but unexpectedly was beaten up by Officer Rabbit
00:12
The CUTEST flower girl on YouTube (2019-2024)
00:10
Hungry FAM
Рет қаралды 48 МЛН
1.2: PVector class - The Nature of Code
14:47
The Coding Train
Рет қаралды 98 М.
Naming Things in Code
7:25
CodeAesthetic
Рет қаралды 2,1 МЛН
4.7: Introduction to Polymorphism - The Nature of Code
8:46
The Coding Train
Рет қаралды 181 М.
How principled coders outperform the competition
11:11
Coderized
Рет қаралды 1,7 МЛН
Array vs. ArrayList in Java Tutorial - What's The Difference?
17:36
Coding with John
Рет қаралды 524 М.
Coding Challenge 180: Falling Sand
23:00
The Coding Train
Рет қаралды 913 М.
Destroying Enemies by Shooting them in Processing
23:43
Chris Whitmire Lessons
Рет қаралды 1,8 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 805 М.
Coding Challenge #14: Fractal Trees - Recursive
15:53
The Coding Train
Рет қаралды 891 М.
WHY IS THE STACK SO FAST?
13:46
Core Dumped
Рет қаралды 152 М.
The Joker wanted to stand at the front, but unexpectedly was beaten up by Officer Rabbit
00:12