Storing object by UID / IID in matrices

Get help using Construct 2

Post » Sun Sep 09, 2012 10:55 am

Hi!

I'm trying to make a simple card solitaire/patience game.

I created a sprite called 'Card' with instance variables to store suit, number, stack/column, and position inside stack.

Stacks are stored in two matrices: a 2D matrix containing indices to the cards, and a 1D matrix containing pointers with the number of cards in each stack or column.

But if I store indices to the cards as UIDs, I find no card when I use Card object condition 'select object by UID', and, if I store indices as IIDs, I always find same card object (Card #0) when I use System object condition 'Select object Card with index X'


You can take a look at my project at:
here (10 Mb download)


Beware it is a 10Mb download, since it contains all images for the cards (they are needed to understand it).

(If you finally download it, you'll find useful to know the meaning of these Spanish words: Carta=>Card, Palo=>Suit, Numero=>Number, Mazo=>Stack, Columna=>Column, Fila=>Row).


B
39
S
11
G
5
Posts: 132
Reputation: 8,228

Post » Sun Sep 09, 2012 2:51 pm

You could use the arrays ... ( The only thing where i suck ! :P )
Check out this tutorial

Arrays for Beginners

Hope it helps !!kbdmaster2012-09-09 14:52:40
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Sun Sep 09, 2012 3:18 pm

I'm using array objects indeed. I forgot they are called "array" (not matrix) in computing.
B
39
S
11
G
5
Posts: 132
Reputation: 8,228

Post » Sun Sep 09, 2012 3:50 pm

Another way is using "instance variables"...

http://www.scirra.com/tutorials/361/understanding-uid-iid-health-of-enemies-and-rocket-smoke-trail

Don't use UID or IID, they are very volatile.
ImageImageImageImageImageImage
B
93
S
20
G
14
Posts: 1,218
Reputation: 19,500

Post » Sun Sep 09, 2012 5:02 pm

The cards created in event 9 can't be picked in event 12. See this thread: http://www.scirra.com/forum/r100-101-cant-pick-object_topic56200.html
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Sun Sep 09, 2012 5:30 pm

[QUOTE=ramones] The cards created in event 9 can't be picked in event 12. See this thread: http://www.scirra.com/forum/r100-101-cant-pick-object_topic56200.html[/QUOTE]

It can if you make a instance variable and check it in another event, like this:

>System: Repeat 1 time;
>>Create card on X,Y;
>>Set card.ID: 9;

>Card instance variable: card.ID = 9;
>Any other conditional;
>>Do whatever you want;


I made this sample for you:
http://www.scirra.com/arcade/example/1837/dealing-with-instance-variablesTELLES08082012-09-09 17:50:40
ImageImageImageImageImageImage
B
93
S
20
G
14
Posts: 1,218
Reputation: 19,500

Post » Sun Sep 09, 2012 7:05 pm

Many thanks to all.

I like your tiny cards, telles0808. Where did you get them from? Mine are from SVG-cards 1.01, that are good for high resolution, but render poorly at low resolution.
B
39
S
11
G
5
Posts: 132
Reputation: 8,228

Post » Sun Sep 09, 2012 7:07 pm

Feel free to use, they was made for an old game made with RPG Maker, so, they are based on the real cards and don't have rights ^^
ImageImageImageImageImageImage
B
93
S
20
G
14
Posts: 1,218
Reputation: 19,500

Post » Wed Dec 12, 2012 5:14 am

Just what I was looking for! Thank you @TELLES0808 :) your capx was very clearly.
B
29
S
6
G
5
Posts: 148
Reputation: 5,084


Return to How do I....?

Who is online

Users browsing this forum: Colludium and 30 guests