Scratch has 1 dimensional arrays...
1-D Array 1. 1 2. 2 3. 3 4. 4 5. 5 6. 6 7. 7 8. 8 9. 9
But what about 2 dimensional arrays?
2-D Array 1A. 1 1B. 2 1C. 3 2A. 4 2B. 5 2C. 6 3A. 7 3B. 8 3C. 9
I think this would be a useful addition to Scratch.
Offline
Good idea! It's great! I thought about this before... but never thought much about it.
Offline
Then it would be very easy to make spreadsheets. It would also be easy to make complex codes (polyalphabetic ones)
I approve!
Offline
I don't see why you need it. In my Level Creator, where it would be probably be needed the most, I didn't need it...
Offline
2-D arrays are pretty essential if you want to easily store data that is sorted into grids. Sure you can use many arrays but that just waste time and creates inefficiencies. What if you need 100 rows worth of data, it is practical to make 100 lists? It would also be really really nice if you could put variables inside of variable names when you cal variables.
Last edited by archmage (2009-11-17 15:07:24)
Offline
I would like higher order arrays...but we must remember that Scratch's first goal is to be approachable to beginners. You can always construct an indexing formula so that a 2D array can be stored in a 1D array.
Example:
If you want to store a 2D array with rows that are 9 elements long in a 1D list then the formula might be
Item_Number = (Row_Number-1) * 9 + Column_Number
Offline
Chrischb wrote:
floatingmagictree wrote:
Erm... what's an array?
An list is the Scratch equivalent of an array.
Oh...
Offline
Paddle2See wrote:
I would like higher order arrays...but we must remember that Scratch's first goal is to be approachable to beginners. You can always construct an indexing formula so that a 2D array can be stored in a 1D array.
Example:
If you want to store a 2D array with rows that are 9 elements long in a 1D list then the formula might be
Item_Number = (Row_Number-1) * 9 + Column_Number
Yeah...
Paddle2See is right again.
Offline
Paddle2See wrote:
If you want to store a 2D array with rows that are 9 elements long in a 1D list then the formula might be
Item_Number = (Row_Number-1) * 9 + Column_Number
Exactly. This is the same general formula that I use for calculating in my level creator player.
Offline
If you have some elements that are different amounts of character then that won't work.
Offline
Paddle, maybe u could make a project of that!
It would be very helpful.
Offline
samurai768 wrote:
Paddle, maybe u could make a project of that!
It would be very helpful.
Mine basically uses it, but because mine is a bit more complicated because it has to round the x position to the nearest 30 tile which its well difficult to understand at a glance.
Offline
Paddle2See wrote:
I would like higher order arrays...but we must remember that Scratch's first goal is to be approachable to beginners. You can always construct an indexing formula so that a 2D array can be stored in a 1D array.
Example:
If you want to store a 2D array with rows that are 9 elements long in a 1D list then the formula might be
Item_Number = (Row_Number-1) * 9 + Column_Number
Great thinking, and simple too; this will make my Swap 'Ems project much easier.
Still, it would be nice to have support for 2D arrays. (Simpler to edit, more beginner-friendly)
Offline
Harakou wrote:
Paddle2See wrote:
I would like higher order arrays...but we must remember that Scratch's first goal is to be approachable to beginners. You can always construct an indexing formula so that a 2D array can be stored in a 1D array.
Example:
If you want to store a 2D array with rows that are 9 elements long in a 1D list then the formula might be
Item_Number = (Row_Number-1) * 9 + Column_NumberGreat thinking, and simple too; this will make my Swap 'Ems project much easier.
Still, it would be nice to have support for 2D arrays. (Simpler to edit, more beginner-friendly)
*cough*Necropost*cough*
Offline
Aidan wrote:
Harakou wrote:
Paddle2See wrote:
I would like higher order arrays...but we must remember that Scratch's first goal is to be approachable to beginners. You can always construct an indexing formula so that a 2D array can be stored in a 1D array.
Example:
If you want to store a 2D array with rows that are 9 elements long in a 1D list then the formula might be
Item_Number = (Row_Number-1) * 9 + Column_NumberGreat thinking, and simple too; this will make my Swap 'Ems project much easier.
Still, it would be nice to have support for 2D arrays. (Simpler to edit, more beginner-friendly)*cough*Necropost*cough*
Lol, I noticed that right after I posted it. I have a tendency to do that.
Offline
Perfect, there is a very easy way to do this....
Add a list to a list (BYOB).
But I'm not sure how it would be displayed if not that.
This would be perfect for tile based games
Offline
juststickman wrote:
Perfect, there is a very easy way to do this....
Add a list to a list (BYOB).
But I'm not sure how it would be displayed if not that.
This would be perfect for tile based games
Yeah, but notice that this was posted 7 months ago...
Offline