These are the stills shots of the movie
This here is the explanation of what my movie is about and how 2D arrays work, I wrote what I thought was Pseudo code, which actually turned out to be real code and would work if I put it into processing.:
An array is a vending machine.
My stop motion movie of a vending machine in use depicts a metaphorical 2d array and how they work.
An array is a storage unit for a linear ordered list of data; a vending machine is a storage unit for things, in this case, drinks. Each storage unit has an index number, just like the drinks in this vending machine have an index number. An array only becomes interactive when an index number is referenced in the code, which is the same as a vending machine; the drink will just stay in the refrigerated air doing nothing, unless you put the correct change in and press the right buttons, then you will get the drink you ask for! A vending machine however, is a 2d array, therefore, is a little more complex than just a linear list of data.
Some example code better shows what makes this a 2d array:
//normal array
int [ ][ ] vendingmachine = {drink1, drink2,drink3,drink4}; //one shelf
But because there is more than one shelf (more than one list of data), it creates a 2d array, so would look like this:
//2d array
int [ ][ ] vendingmachine =
{ {drinkA1, drinkA2 ,drinkA3, drinkA4}, // shelf one
{drinkB1 ,drinkB2, drinkB3, drinkB4}, // shelf two
{drinkC1, drinkC2 ,drinkC3, drinkC4}, //shelf three
{drinkD1, drinkD2, drinkD3, drinkD4}}; // shelf four
Lets say we want drinkC2, an array works like a grid, and drinkC2 is 3 down and two across on the grid named ‘vendingmachine’, in code this is written like this:
vendingmachine[3][2];
This works the same in the real life situation of a vending machine, when you press A3, it will go to shelf A, and get the third drink on that shelf.