FIFO in a 2d array

Get help using Construct 2

Post » Mon Jul 23, 2012 3:49 pm

Hi!

I've looked at several threads, manual entries and tutorials but I still can't find the solution to my problem.

I want to do a grid where every column has its own queue (very similar to a 4 in a row game but inverted [like if you could insert coins from the bottom]).
I've tried the push and pop functions and they work great with 1D columns but, when it comes to 2D, I don't know how to indicate wich column must be pushed and poped.

Any ideas? I supose it should be an easy task but I don't know much about programming so I can't really figure it out by myself.

Sorry for opening a new thread about arrays but ,believe me, I have checked the entire page searching for an answer but coudn't find anything related.

bye and thanks!
B
9
S
3
G
3
Posts: 39
Reputation: 3,112

Post » Mon Jul 23, 2012 5:27 pm

[quote]I've tried the push and pop functions and they work great with 1D columns but, when it comes to 2D, I don't know how to indicate wich column must be pushed and poped.[/quote]
The push or pop will affect all the columns. With the array all the columns are the same height, and all the rows are the same width.

The solution is to have multiple instances of 1d arrays.
B
79
S
24
G
53
Posts: 4,728
Reputation: 40,219

Post » Mon Jul 23, 2012 5:39 pm

I thought on having multiples arrays but I suposed there was a better option.

I gave the push and pop examples but if you know an alternative way to acomplish this queue effect without'em, i'll apreciate it.Antylope2012-07-23 17:41:29
B
9
S
3
G
3
Posts: 39
Reputation: 3,112

Post » Mon Jul 23, 2012 6:41 pm

Here is an example of my suggestion:
http://dl.dropbox.com/u/5426011/examples13/array_instances.capx

An alternate would be to not use an array at all, just use sprites and collisions to do it visually.
B
79
S
24
G
53
Posts: 4,728
Reputation: 40,219

Post » Mon Jul 23, 2012 8:19 pm

Thanks! That may work or, at least, simplify things.
B
9
S
3
G
3
Posts: 39
Reputation: 3,112


Return to How do I....?

Who is online

Users browsing this forum: Khamsou, Yahoo [Bot] and 19 guests