9.15: 2D Arrays in JavaScript - p5.js Tutorial

  Рет қаралды 116,662

The Coding Train

The Coding Train

Күн бұрын

Пікірлер: 78
@smoky_sam
@smoky_sam 5 жыл бұрын
I like the fact you aren't afraid to show where u made mistakes or got confused. Good explanation.
@realcygnus
@realcygnus 8 жыл бұрын
directly from the P5 included Examples, you can make a 2D array very much just like as in c, as follows; arr = []; in globals (as per usual), then just: for (var c = 0; c < cols; c++) { arr[c] = []; //ah ha !!! for(var r = 0; r < rows; r++) { arr[c][r] = random(255); }//4r }//4c seems you can declare it empty with arr = [[],[]]; but you need line 2 anyway. works like a champ !
@iphyzll1091
@iphyzll1091 8 жыл бұрын
You are so positive and helpful, i love your tutorials ! Please keep it up, thanks ! :)
@TheCodingTrain
@TheCodingTrain 8 жыл бұрын
+iPHYZLL , thank you!
@maxlesin3876
@maxlesin3876 3 жыл бұрын
I will never stop thanking you for this knowledge.
@lucasjacinto8440
@lucasjacinto8440 4 жыл бұрын
Thank you so much dude these two dimensional arrays were giving me trouble.
@flopasen
@flopasen 2 жыл бұрын
i'm learning this stuff right now for a little project and really appreciate being shown the primitive things and ideas for a function
@Zachucks
@Zachucks 4 жыл бұрын
The Coding Train lost his train of thought lol! New fav channel btw, very good teacher and nice charisma!
@GabrielDalposso
@GabrielDalposso 4 жыл бұрын
THANK YOU SO MUCH, I WAS SO LOST WITHOUT THIS
@taljune142010
@taljune142010 5 жыл бұрын
Thanks a lot Daniel! this is the only workable method for multidimensional array. It works for 3 dimensions as well.
@shreddymetal
@shreddymetal 8 жыл бұрын
I've seen people use these weird 2 dimensional arrays before and I never knew it was a common thing, thanks for this!
@TheCodingTrain
@TheCodingTrain 8 жыл бұрын
thanks!
@danbo967
@danbo967 7 жыл бұрын
They are pretty common in a lot of areas like database (array of posts has an array of comments). If you work with JSON you will find 2D arrays all the time. When doing game development you use 2D arrays for positioning objects. Each array in the array of positions stores [x,y] sometimes [x,y,z]. Those are a few cases that I remember right now. But they are all over the place.
@johnn4314
@johnn4314 6 жыл бұрын
Very solid educator
@mirankamal5431
@mirankamal5431 8 жыл бұрын
You the best.
@TheCodingTrain
@TheCodingTrain 8 жыл бұрын
thank you!
@younesbav0up316
@younesbav0up316 2 жыл бұрын
that was so helpful and you made fun to watch
@Popfictn
@Popfictn 8 жыл бұрын
Dan, i want to be able to fill with a specific color in the 2d array as opposed to a random one. How do i identify and fill a square with a specific colour? Thanks :-)
@shakyafernando3312
@shakyafernando3312 5 жыл бұрын
How do you target each individual box on the grid? (for example: if need to colour a specific box red)
@FredoCorleone
@FredoCorleone 6 жыл бұрын
Cols and rows are conceptually inverted, isn't it?
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
It's a good point. I've always done [cols][rows] b/c of being so used to (x,y) but the more I teach about matrices the more I see the convention of rows x cols. This is a recent discussion: github.com/processing/processing-docs/issues/676
@kreendurron
@kreendurron 7 жыл бұрын
Daniel can you re-visit this topic in future videos?
@Halo4envivo
@Halo4envivo 7 жыл бұрын
the source code for this tutorial is not on github, can you put it again? or tell me where is it, if it actually is on github but i didn't see it, please
@NooblantisDistrict
@NooblantisDistrict 3 жыл бұрын
2022 and still saving lives✌😂
@Korsasnoraven
@Korsasnoraven 5 жыл бұрын
Thanks so much for the video!!
@melodyhynes9904
@melodyhynes9904 5 жыл бұрын
So, say a 40x40 array of 0's and 1's to decide if content is locked or not (if 1 unlock content if 0 lock content) is there a better way to do this in terms of efficiency ? Say you call the array 'journals' and check the entire array for 1's and 0's to see if the corresponding place in the timelin (canvas drawn interactive timeline that shows the journals obtained) Is unlocked
@Es.me44
@Es.me44 6 жыл бұрын
You can use console.table(arr);
@codeandfood
@codeandfood 6 жыл бұрын
'Command + Shift + T' on MAC will open your last closed tab :)
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
Thank you Jeesun!
@oskar1504
@oskar1504 4 жыл бұрын
I "hoped" i learn something new and realized i already using 2d arrays without knowing about this as an used method.
@cap-advaith
@cap-advaith 5 жыл бұрын
hey dan is it like [row][column]............but u were saying [column][row].....why is that
@angladephil
@angladephil 6 жыл бұрын
Hello. What if Idon't know in advance what number of cols and rows I will need ?
@martinkubat9193
@martinkubat9193 3 жыл бұрын
Thanks. Perfect explanation. I missed step array[i] = [] in my code, used array[i][k] = x instead right away and it didn't work out. It's weird you can't initialize size of array in JS
@danaililiev1404
@danaililiev1404 5 жыл бұрын
thnx so much solved my problem
@saipanda893
@saipanda893 6 жыл бұрын
What shortcut key you use for remove the comment into code ?
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
Command slash!
@pittyconor2489
@pittyconor2489 5 жыл бұрын
Blocks[i] = []; i did this but it says Uncaught TypeError: Cannot set property '0' of undefined (sketch: line 61)
@TheChodex
@TheChodex 6 жыл бұрын
I think i will stick with making array[width*height] and then just using array[ y * array_width + x] formula :P Seems like less of a hassle :P
@dzhellenicpoetry
@dzhellenicpoetry 8 жыл бұрын
Nice! Thank you!
@noelearlwatson2724
@noelearlwatson2724 8 жыл бұрын
Nice video
@TheCodingTrain
@TheCodingTrain 8 жыл бұрын
thanks for watching!
@Metal565
@Metal565 8 жыл бұрын
Thanks Dan, is there going to be a video on objects in 2D array?
@TheCodingTrain
@TheCodingTrain 8 жыл бұрын
Great idea for a follow up, feel free to suggest! github.com/CodingRainbow/Rainbow-Topics/issues/100
@WistrelChianti
@WistrelChianti 2 жыл бұрын
thanks! That helped!
@d_06snehalprajapati90
@d_06snehalprajapati90 Жыл бұрын
Good explanation....>3
@mathis-meth4229
@mathis-meth4229 2 жыл бұрын
he feels like paul gilbert(guitarist) of programming
@Sleep_Attenuation
@Sleep_Attenuation 3 жыл бұрын
you are amazing
@calderarox
@calderarox 8 жыл бұрын
can you make a video about collision AABB and how to react to it?
@TheCodingTrain
@TheCodingTrain 8 жыл бұрын
Feel free to suggest: github.com/CodingRainbow/Rainbow-Topics/issues
@Samuelfodao
@Samuelfodao 8 жыл бұрын
AMAZINGGG!!!
@TheCodingTrain
@TheCodingTrain 8 жыл бұрын
thank you!
@peterrempel2458
@peterrempel2458 3 жыл бұрын
Thank you very much. It makes me satisfy to see, that an profi say what I'm thinking the last days and hours of learning: These f*#! moredimensual arrays confuse me :)
@TheAliakbarazad
@TheAliakbarazad 5 жыл бұрын
You Sir are pure goodness!!
@rorothegoatboat
@rorothegoatboat 2 жыл бұрын
didn't get the same result, random is not a function error is what i get
@Blindstick1
@Blindstick1 3 жыл бұрын
Thank you!
@nicholarucitadhamma6000
@nicholarucitadhamma6000 2 жыл бұрын
I want to give a suggestion. Tho I'm 2 years late😅 But if you want to reopen a tab you closed, you could open your web browser and press Shift+Ctrl+T it should work. If it doesn't then, well I don't know.
@cap-advaith
@cap-advaith 5 жыл бұрын
hey dan could u slow down a little bit a tiny bit ........because my video slow down button is not working......:-)
@gardeningandcooking5145
@gardeningandcooking5145 6 жыл бұрын
would you willing to write a js for me? I have been looking for someone who can do a small job for my website.
@lastskynet4346
@lastskynet4346 5 жыл бұрын
code line 8 ----> 10 Error detected i = rows j = cols for every cols of rows
@tomvos3317
@tomvos3317 7 жыл бұрын
but the real question is: can you make a 3D array? seriously, can you make one? im interested :P
@TheCodingTrain
@TheCodingTrain 7 жыл бұрын
Yes, any dimension is possible, they are really just arrays of arrays.
@tomvos3317
@tomvos3317 7 жыл бұрын
The Coding Train So in theory you van make An 123456789D array if I'm right :P BTW, I love your tutorials! They are really helpful, and they have got me into p5.js, which I never heard of until I saw your video's!
@klevisimeri607
@klevisimeri607 3 жыл бұрын
Love you
@valentinab.742
@valentinab.742 3 жыл бұрын
hi! where i can find the code?
@snigdharahman1480
@snigdharahman1480 3 жыл бұрын
Sir can you teach me pointers * or guide me to a good like with your qualitY. I struggle with it a low
@goldthumb
@goldthumb 2 жыл бұрын
You, I mean "me", have to learn fundamental things before you start building your own stuff in a reasonable speed. 2D array is fundamental.
@abhishekkattimani1302
@abhishekkattimani1302 6 жыл бұрын
Sir could you make the java video tutorial series right from basics.. please please..
@Alebtong1
@Alebtong1 7 жыл бұрын
I am confused
@FredoCorleone
@FredoCorleone 6 жыл бұрын
Confusion means you are learning
@latorious9489
@latorious9489 4 жыл бұрын
Python is just so much more simple Method: arr = [[random.randint(0, 1) for y in range(Rows)] for x in range(Cols)]
@chancewoosley3165
@chancewoosley3165 4 жыл бұрын
i love you
@WILPOLLOCK
@WILPOLLOCK 2 жыл бұрын
Your whiteboard is crooked. It's hurting my brain... 🤣
@bourbon3587
@bourbon3587 3 жыл бұрын
I just losing my concentration because of laughing(over ),shaking of hands and body
@Human_Evolution-
@Human_Evolution- 2 жыл бұрын
Too sporadic.. Screens zooming all over.
@lucanghuang8201
@lucanghuang8201 3 жыл бұрын
First time I watched this...very confusing.
@RigelNarcissus
@RigelNarcissus 8 жыл бұрын
let make2Darr = function(r, c) { return new Array(c).fill([]).map(e => new Array(r)); } ;)
@TheCodingTrain
@TheCodingTrain 8 жыл бұрын
oh wow, mind blown. github.com/CodingRainbow/Rainbow-Topics/issues/100
9.16: CodePen in p5.js - p5.js Tutorial
5:20
The Coding Train
Рет қаралды 13 М.
Nested Loops & 2D Arrays | Javascript | Tutorial 25
10:40
Giraffe Academy
Рет қаралды 52 М.
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19
My 17 Minute AI Workflow To Stand Out At Work
17:30
Vicky Zhao [BEEAMP]
Рет қаралды 28 М.
Coding Challenge 180: Falling Sand
23:00
The Coding Train
Рет қаралды 1,1 МЛН
Coding Challenge 11: 3D Terrain Generation with Perlin Noise in Processing
22:44
What was Coding like 40 years ago?
29:05
The Coding Train
Рет қаралды 1,8 МЛН
2D Array - Creative Coding with p5.js
9:27
Patt Vira
Рет қаралды 980
Coding Challenge 171: Wave Function Collapse
1:18:37
The Coding Train
Рет қаралды 562 М.
STOP Using Classes In JavaScript | Prime Reacts
14:02
ThePrimeTime
Рет қаралды 259 М.
AI learns to play 2048
11:11
Code Bullet
Рет қаралды 10 МЛН
Coding Challenge 183: Paper Marbling Algorithm
32:10
The Coding Train
Рет қаралды 81 М.