9.5: Arrays of Flexible Size - Processing Tutorial
HTML-код
- Опубликовано: 9 фев 2025
- Book: Learning Processing A Beginner's Guide to Programming, Images, Animation, and Interaction
Chapter: 9
Official book website: learningprocess...
Twitter: / shiffman
This video discusses the inevitable quandary of what to do when you want to resize your array dynamically while a program is running.
github.com/shi...
For ArrayLists, check out this video:
• 4.2: ArrayLists in Pro...
Help us caption & translate this video!
amara.org/v/QbxB/
📄 Code of Conduct: github.com/Cod...
your tutorials are just perfect
Really great videos! I got into programming last year. Decided to teach myself, and after trying few tutorials (python/JAVA/Khan academy ) finally found Processing! it has so far has been the most productive and effective way for me to learn. Thank you very much Daniel Shiffman! (and processing team!)
+apxnmed21322314 so glad to hear, thank you!
Watching in 2023 --- This Daniel guy has really gotten more professional in making videos, but the content is more reliable than the chat AI that was recently released.
Is there anyone who couldn't love this guy ?!
Dan I'm a Telecommunications engineer and 3 weeks ago I had ZERO knowledge abou coding and programming.
I have enjoyed every second of your videos and I have learned so much in programming that I have ever imagined.
Today I have finished this video and proudly I have made a game with OOP and arrays.
I really want to meet you in person and give a real gift for what you have taught me because just saying thank you in the comments isn't enough.
Also I want to show you my game. I know you wouldn't like it because there is no comments on them but I will comment on it if you agreed to see my code. I talked too much already 😂. Than you and you are awesome 👍❤️
This is so amazing to hear thank you for the nice feedback!
Hello, did you build the game in Processing? Or another engine?
You make a lot of sense, and I appreciate your effort! You do sometimes ramble though
It's part of the magic hahah
YOU ARE AMAZING, Okay!!! Your deeds will not go unnoticed young sir!
best tutorials ever seen
ok, now I know that I can happily go to videos for chapter 15. oh well. hopefully chapters 10-14 videos will see the light of day some day.
Thanks for the tutorial, I made a little game out of it.
ArrayList bs = new ArrayList();
int time;
//0 = intro
//1 = start
//2 = end
int state;
void setup() {
size(640, 360);
state = 0;
}
void draw() {
switch(state) {
case 0:
background(0);
fill(255);
textAlign(CENTER);
textSize(32);
text("BUBBLE CLICKER", width/2, height/2);
textSize(16);
text("Mouse(LEFT) to pop", width/2, height/2 + 20);
text("Mouse(MIDDLE) to reset", width/2, height/2 + 40);
text("Mouse(RIGHT) to add bubble", width/2, height/2 + 60);
text("CLICK TO START", width/2, height/2 + 100);
break;
case 1:
background(0);
fill(255);
textAlign(LEFT);
textSize(24);
text("Bubble= "+bs.size(), 10, 24);
textAlign(RIGHT);
textSize(16);
text("F= "+floor(frameRate), width-10, 16);
break;
case 2:
background(0);
fill(255);
textAlign(CENTER);
textSize(24);
text("YOU WIN", width/2, height/2);
break;
}
//for (Bubble b : bs) {
// b.display();
// b.ascend();
// b.top();
//}
if (state != 2) {
for (int i = bs.size() - 1; i >= 0; i--) {
bs.get(i).display();
bs.get(i).ascend();
bs.get(i).top();
if (bs.get(i).popped() == true) {
bs.remove(i);
}
}
spawnEvery(2, 1);
}
if (state == 1 && bs.size()
I tried your game its pretty cool, congrats.
The first page is unresponsive for me, if I click, nothing happens. Maybe because I'm on a Mac? I'd love to play this!
Well, if you just press and hold the left button its not actually clicker but why i am complaning, im not able to do nor 1% of this! Great job!
lol four years later this is still really cool. It still works with the newer version of Processing.
although i couldnt solve my problem with this video yet i gain knowledge and it was very well explained sir . goodjod !
I'm learning java sas and m so happy to find he video I realy needed a way to get all my objects into one array to build a decent collision system that is expendable
Really useful, thank you +Daniel Shiffman
+Missi0n141 glad to hear, thank you!
Thank you so much for your brilliant lessons!
+김이현 you're welcome!
im so glad we both love bubbles!!!! :D
omg ive been trying to get a mouse click to have a bubble appear since the object oriented tutorials that introduced bubbles. I literally just got it figured out as you say it in this video (im watching and following along while trying the code on my laptop).
Interested now to see the end of this video and how its done different/ similar. Right now i have a maxBubbles variables initializing the array and a bubblesDisplayed variable for "i" in my draw function for loop. every mouse click increments "bubblesDisplayed" but maxBubbles is static. Very cool!
edit* annnnnnd thats the exact same way this video shows! awesome! you rock!
Thank you so much for explaining this to me and linking me to that excelent example
Video still helps me thx
Thanks you sir! very nice tutorial!!!
hey! i need some help with a code problem im having and i cannot understand whats causing i tor how to fix it... heres the problem:
i wrote a program using arrays and objects to create ball objects on the screen wherever the mouse is clicked. now i wanted to make them bounce around on collision instead of just passing right through each other so i wrote a function called collide in which if the distance between the centres of the 2 balls was less than the sum of the radii then it would change their velocities! now i run the program and its running fine till there are about 5 balls on the screen but as soon as i get a high number of balls on the screen the balls *randomly* start overalpping with each other and start revolving around each other quirkily... i do not understand whats happening please help.
this is magic, thank you!
7:16 sounds cool at x2 speed
Hey Daniel! Following on your tutorial, I created an animation of bubbles of random sizes moving upwards on the screen. I want to add a feature of the bubbles popping when they collide with each other. But it doesn't seem to work. I can't seem to figure out what code to write to make it work like I want. Could you please help with this problem?
Bubble [] bubbles = new Bubble [100] ;
void setup () {
size (640, 480, P2D);
for (int indices = 0; indices < bubbles.length; indices += 1) {
bubbles [indices] = new Bubble (random (width), height, random (80));
}
}
void draw () {
background (0);
for (int indices = 0; indices < bubbles.length; indices += 1) {
bubbles[indices].ascend ();
if (bubbles [indices].together (bubbles [indices])) {
bubbles[indices].pops ();
}
bubbles[indices].display ();
bubbles[indices].top ();
}
}
class Bubble {
float x, y;
float d;
float driftX;
float speedY;
float alpha;
Bubble (float tempX, float tempY, float tempD) {
x = tempX;
y = tempY;
d = tempD;
driftX = 2;
speedY = random (0.25, 2);
alpha = random (20, 107);
}
void display () {
fill (255, 223 + (random (-20, 0)), 0, alpha);
noStroke ();
ellipse (x, y, d, d);
}
void ascend () {
x += random (driftX*-1, driftX);
y -= speedY;
}
void top () {
if (y+d < 0) {
y = height;
}
}
boolean together (Bubble other) {
float distance = dist((x + d/2), (y+d/2), (other.x+((other.d)/2)), (other.y+((other.d)/2)));
if (distance == 0) {
return true;
} else {
return false;
}
}
void pops () {
d = 0;
}
}
thanks for your videos!
4:53
Is there any tutorials for using an array with millis()? I would like to add a bubble every second but also be able to click them away? is this possible?
i don't get the part about a chance of a bubble appearing per frame. are we supposed to use some sort of frame function?
I can't find chapter 10 for some reason. Did you even make one? It just goes straight to chapter 15 after this.
can I draw random circles as you showed without using objects ?
your tutorials are great but I wonder if it's possible to upload a game to steam with Processing. If it's possible can you make a tutorial, thanks :)
The github link is dead; where did he use his 'total' variable?
do you think you can give us the code you used for this tutorial? also I am stuck on the exercises if anyone can help I would appreciate it so much!!
I need to do a better job of organizing all the code. You can find it here: github.com/CodingTrain/website/tree/master/Tutorials/Processing/unsorted
The Coding Train thank you so much!!!
Good tutorial but pls push the Framerate at least up to 24 ;)
I only see you stutter arround the picture.
Sir!!
Can we declare an array as arr [2+3]
Sir please comment 🙏
I'd love to see an array being created and read from a local buffer in a visual manner.
If I create a pointer to this memory at x position. Then place a value at x + offset of data length. And use that to read and write from the buffer at an index. This would be the proper technique correct?
It just seems so simple and visual this way.
What if I keep pressing mouse button and reach 100 ?
It will eventually throw OutofBounds exception.
I don't get how the bubbles are continuing once they hit the top. There's nothing in your code that I see doing that! Help!
Here's the bit of code inside the Bubble class, that makes the bubbles continue once they hit the top:
void top(){
if (y < -diameter/2){
y = height+diameter/2;
}
}
Bro said he had a cough🤣right after having a cough😭
Do you have any vids on 2d arrays??
+Myles Jeremiah I believe I talk a bit about 2d arrays in this video: ruclips.net/video/tENSCEO-LEc/видео.html But yes, this seems like a missing topic! Will add to my list!
Another request for that! Great tutorials thank you so much for making them
Hi Dan, please make videos from the lesson 10 to 14. We are stuck here. It is important.
Thanks in advance.
+BABLU KUMAR I will try to get to this, but I have a bunch of things on my list first! For chapter 13 take a look at the nature of code series: ruclips.net/user/shiffmanplaylists?shelf_id=6&view=50&sort=dd
Nice
Which language is being used for this tutorial?
Is it Java?
This video uses Processing (which is built on top of the Java programming language). For more info, visit processing.org and also this video might help ruclips.net/video/AmlAiKsiy0o/видео.html.
This dude is cracked
Hey,you look like harry Porter 😅btw nice explanation
♥
7:17
YOU ARE JAMESBOND
I love this guy lmao
An array is a constant.
flexible size, DOES matter :)
6:10 😂😂😂
please explain with programing language. come into the point.
for that never ending thing I just wrote this
if (total>=100) {
total=100/2;
}
can't think of anything else 😅😛
And I don't understand the last exercise if anyone could explain......
I hate arraylists' syntax who thought it was a good idea to make their syntax look like that?
What's wrong with it? Pretty much almost every language has a similar syntax.