WEBVTT

00:00.540 --> 00:04.920
In this lesson we're going to cover a concept that's not really essential for all of you.

00:05.010 --> 00:10.350
But if some of you are going to get into game development this is certainly something that you need

00:10.350 --> 00:14.610
to keep in mind that you might be using when you make your games.

00:14.640 --> 00:22.080
Many games are what they're called tile based games which means that the game area the game board is

00:22.080 --> 00:24.740
basically divided in Negril.

00:24.750 --> 00:32.460
It has a grill and it has like cells in each cell has its own set coordinates so it has a number of

00:32.460 --> 00:35.990
row and it has a number of column.

00:36.310 --> 00:42.410
And I want to I want you to know that arrays can also be multidimensional.

00:42.510 --> 00:49.050
So all the races we've seen so far have one dimension which is which means that they are something like

00:49.050 --> 00:51.490
this.

00:51.780 --> 00:54.600
There's just one dimension one possible index.

00:54.750 --> 01:01.560
But you can also have multidimensional arrays on two dimensional arrays in particular are usually used

01:01.560 --> 01:06.930
to represent these griddles at least in some in some game frameworks.

01:06.930 --> 01:13.350
So let me create a two dimensional array.

01:13.980 --> 01:22.410
So that's going to be say our first row and then the second one is going to be part of our second row.

01:22.410 --> 01:27.060
I'm going to create a third row as well.

01:27.060 --> 01:33.330
So I've created here an array that's two dimensional and that's three by three.

01:33.360 --> 01:36.550
So we have three rows and three columns.

01:36.900 --> 01:41.100
Now accessing these elements.

01:41.160 --> 01:49.020
Well let's look at the array before see that we have an array and each element in the array is also

01:49.020 --> 01:49.870
an array.

01:49.950 --> 01:56.340
That's what multidimensional means that we can Rubus and more than one dimension with this.

01:56.340 --> 02:04.170
So the way that we can access these elements it's very straightforward it's very simple.

02:04.170 --> 02:08.650
So imagine I want to access this this number here number five.

02:08.880 --> 02:19.200
So first thing you do is that you find the index of the corresponding array.

02:19.210 --> 02:27.460
So in this case this is an index one right because it would be index is 0 that would be index one that

02:27.460 --> 02:29.490
will give us this whole thing.

02:30.520 --> 02:38.290
And you can actually see it and then if we want to access this number five in here that's just position

02:38.380 --> 02:40.360
0 1 2.

02:40.390 --> 02:49.910
So we put in another bracket and then we refer to the position of that element within this array.

02:50.140 --> 02:56.300
So that's how you can access individual elements to another example.

02:56.410 --> 03:00.110
How about I access this 7 over here.

03:00.850 --> 03:10.410
So that would be 0 1 2 and then the position 0 first position.

03:11.430 --> 03:18.230
And I can access the properties like that or to read and also to write.

03:18.260 --> 03:29.930
So if I want to replace this nine by 10 i'll just to be positioned to first and then position 0 1 2.

03:30.140 --> 03:36.410
So that would be this would be the location of that number and I want that to be 10.

03:36.920 --> 03:47.570
And if we look at our list again after doing that you'll see that this time in this array's Now this

03:47.570 --> 03:49.540
value is now 10.

03:50.570 --> 03:54.860
So that's a that's an introduction to multi dimensional arrays.

03:54.860 --> 03:56.870
There are many cases where these are used.

03:56.870 --> 04:03.050
It's important just to know what they are and how you can access a particular element within them whether

04:03.050 --> 04:05.650
it's to read it or to modify it.
