This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2009-11-16 22:18:48

The-Whiz
Scratcher
Registered: 2007-07-09
Posts: 1000+

2-D Arrays

Scratch has 1 dimensional arrays...

Code:

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?

Code:

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

 

#2 2009-11-16 22:40:46

scmb1
Scratch Team
Registered: 2009-03-19
Posts: 1000+

Re: 2-D Arrays

Yes, it could be useful...


http://i48.tinypic.com/2z5pqad.png

Offline

 

#3 2009-11-16 23:40:01

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: 2-D Arrays

Good idea! It's great! I thought about this before... but never thought much about it.  tongue


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#4 2009-11-16 23:42:21

greenflash
Scratcher
Registered: 2009-05-27
Posts: 1000+

Re: 2-D Arrays

Then it would be very easy to make spreadsheets. It would also be easy to make complex codes (polyalphabetic ones)

I approve!  big_smile


http://i48.tinypic.com/2wrkirk.pnghttp://i46.tinypic.com/6r5zk7.pnghttp://i45.tinypic.com/2vtxr1t.png

Offline

 

#5 2009-11-16 23:48:32

Chrischb
Scratcher
Registered: 2008-07-24
Posts: 1000+

Re: 2-D Arrays

I love this idea! It would help with branching into more detail, and contains more space as well.


I fall: It's a tragedy. You fall: It's comedy.
Hmph enjoy your fall - I get a lovely spring... without pans of new leaves.

Offline

 

#6 2009-11-17 01:26:25

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: 2-D Arrays

I love this! My dad wanted me to make a game with scratch and he asked about this. But I said scratch only has 1-d arrays so I couldn't make that game.  smile  I support!  big_smile


Hai.

Offline

 

#7 2009-11-17 07:02:08

The-Whiz
Scratcher
Registered: 2007-07-09
Posts: 1000+

Re: 2-D Arrays

Thanks for the support!

Offline

 

#8 2009-11-17 14:58:16

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: 2-D Arrays

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...


http://i.imgur.com/WBkM2QQ.png

Offline

 

#9 2009-11-17 15:05:07

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: 2-D Arrays

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)


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#10 2009-11-17 16:59:05

floatingmagictree
Scratcher
Registered: 2008-10-21
Posts: 1000+

Re: 2-D Arrays

Erm... what's an array?

Offline

 

#11 2009-11-18 01:44:10

Chrischb
Scratcher
Registered: 2008-07-24
Posts: 1000+

Re: 2-D Arrays

floatingmagictree wrote:

Erm... what's an array?

An list is the Scratch equivalent of an array.


I fall: It's a tragedy. You fall: It's comedy.
Hmph enjoy your fall - I get a lovely spring... without pans of new leaves.

Offline

 

#12 2009-11-18 05:40:33

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: 2-D Arrays

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


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#13 2009-11-18 06:55:20

floatingmagictree
Scratcher
Registered: 2008-10-21
Posts: 1000+

Re: 2-D Arrays

Chrischb wrote:

floatingmagictree wrote:

Erm... what's an array?

An list is the Scratch equivalent of an array.

Oh...

Offline

 

#14 2009-11-18 07:20:39

The-Whiz
Scratcher
Registered: 2007-07-09
Posts: 1000+

Re: 2-D Arrays

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

 

#15 2009-11-18 17:38:42

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: 2-D Arrays

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.


http://i.imgur.com/WBkM2QQ.png

Offline

 

#16 2009-11-18 18:47:06

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: 2-D Arrays

If you have some elements that are different amounts of character then that won't work.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#17 2009-11-18 20:04:08

samurai768
Scratcher
Registered: 2009-07-21
Posts: 1000+

Re: 2-D Arrays

Paddle, maybe u could make a project of that!

It would be very helpful.

Offline

 

#18 2009-11-19 15:12:39

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: 2-D Arrays

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.


http://i.imgur.com/WBkM2QQ.png

Offline

 

#19 2009-11-23 05:38:14

gvdh
Scratcher
Registered: 2009-08-30
Posts: 1

Re: 2-D Arrays

Of course, if you could add a list as an item of another list, you could then construct n-D arrays

Offline

 

#20 2009-11-23 06:33:14

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: 2-D Arrays

yeah gvdh


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#21 2010-06-17 19:29:20

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: 2-D Arrays

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)


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#22 2010-06-17 19:33:09

Aidan
Scratcher
Registered: 2007-06-15
Posts: 1000+

Re: 2-D Arrays

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_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)

*cough*Necropost*cough*

Offline

 

#23 2010-06-17 22:37:12

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: 2-D Arrays

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_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)

*cough*Necropost*cough*

Lol, I noticed that right after I posted it. I have a tendency to do that.


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#24 2010-06-18 03:56:35

juststickman
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: 2-D Arrays

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  big_smile


http://is.gd/iBQi2 Add grob to your sig and help with world dominiation!http://is.gd/iBQ9Q                                                             Hey guys, we're seriously naming our team bob?

Offline

 

#25 2010-06-18 16:43:44

The-Whiz
Scratcher
Registered: 2007-07-09
Posts: 1000+

Re: 2-D Arrays

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  big_smile

Yeah, but notice that this was posted 7 months ago...

Offline

 

Board footer