Why each event sheet dont work for each level

Just started using Construct 2? Post your questions here

Post » Mon Oct 24, 2016 4:08 pm

i use this templte to learn
https://www.scirra.com/tutorials/280/cr ... match-game

i modify this a bit
just create 3 levels
each level have own eveents to be shure nothing gonna happen wrong

first level works fine
but other levels dont wank show shuffled cards ;/

I put this subject for beginners questions because prabably its something silly and i dont see this
If you have time please take look at this !
https://dl.dropboxusercontent.com/u/44710358/mem.capx
B
25
S
8
Posts: 219
Reputation: 2,181

Post » Mon Oct 24, 2016 5:49 pm

You use addons in your project, so unless someone have those installed or are willing to install them I doubt you will get help :) Can you post screenshots of you code instead then it might be easier for people to help you.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Mon Oct 24, 2016 7:09 pm

too much to print screen;) i delete most addons now
nimos100 wrote:You use addons in your project, so unless someone have those installed or are willing to install them I doubt you will get help :) Can you post screenshots of you code instead then it might be easier for people to help you.
B
25
S
8
Posts: 219
Reputation: 2,181

Post » Mon Oct 24, 2016 8:13 pm

IGDev wrote:too much to print screen;) i delete most addons now
nimos100 wrote:You use addons in your project, so unless someone have those installed or are willing to install them I doubt you will get help :) Can you post screenshots of you code instead then it might be easier for people to help you.


There are three addons, called "Authentication", "Parse initialize" and last one is "Leader board".

Im not saying it to be annoying :) But its really difficult for anyone to get help if their capx contain addons, because people that might be able to help you, don't want to spend time installing several plugins just to debug some code. So most likely they will simply ignore them once downloaded and tried opened in C2 and they get an error that they are missing this and that addon. :)

Ps. You shouldn't delete random addons if you need them. Just make sure that those in your project are removed, either by saving another copy of it without them. that way you still have the original version that you work in. And I don't mean you have to delete them from you C2 plugin library just make sure that they are not used in your project.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Mon Oct 24, 2016 10:23 pm

hmmm weird i delete this addons for sure

please check this now

nimos100 wrote:
IGDev wrote:too much to print screen;) i delete most addons now
nimos100 wrote:You use addons in your project, so unless someone have those installed or are willing to install them I doubt you will get help :) Can you post screenshots of you code instead then it might be easier for people to help you.


There are three addons, called "Authentication", "Parse initialize" and last one is "Leader board".

Im not saying it to be annoying :) But its really difficult for anyone to get help if their capx contain addons, because people that might be able to help you, don't want to spend time installing several plugins just to debug some code. So most likely they will simply ignore them once downloaded and tried opened in C2 and they get an error that they are missing this and that addon. :)

Ps. You shouldn't delete random addons if you need them. Just make sure that those in your project are removed, either by saving another copy of it without them. that way you still have the original version that you work in. And I don't mean you have to delete them from you C2 plugin library just make sure that they are not used in your project.
B
25
S
8
Posts: 219
Reputation: 2,181

Post » Mon Oct 24, 2016 10:56 pm

The plugins are still there. Make a new dropbox entry.
ImageImageImage
B
71
S
22
G
247
Posts: 3,756
Reputation: 137,558

Post » Tue Oct 25, 2016 12:29 am

blackhornet wrote:The plugins are still there. Make a new dropbox entry.


new entry
https://dl.dropboxusercontent.com/u/44710358/mem2.capx
B
25
S
8
Posts: 219
Reputation: 2,181

Post » Tue Oct 25, 2016 2:19 am

Part of the problem is that you have duplicated all of the events. Now someone has to go through each to compare what might be different. This is the wrong way to do it. You don't want to do everything 3 times. Just do it once, with the differences isolated to each level.
ImageImageImage
B
71
S
22
G
247
Posts: 3,756
Reputation: 137,558

Post » Tue Oct 25, 2016 10:12 am

blackhornet wrote:Part of the problem is that you have duplicated all of the events. Now someone has to go through each to compare what might be different. This is the wrong way to do it. You don't want to do everything 3 times. Just do it once, with the differences isolated to each level.


i check this and update
each evens sheet is fine for each level

but cards for other levels are no shuffled
thats is bug i dont understand
B
25
S
8
Posts: 219
Reputation: 2,181

Post » Tue Oct 25, 2016 4:39 pm

IGDev wrote:
blackhornet wrote:Part of the problem is that you have duplicated all of the events. Now someone has to go through each to compare what might be different. This is the wrong way to do it. You don't want to do everything 3 times. Just do it once, with the differences isolated to each level.


i check this and update
each evens sheet is fine for each level

but cards for other levels are no shuffled
thats is bug i dont understand

Looked at the tutorial and it seems a bit complicated for what you are trying to achieve, so made a very simple example of how you can do it, which might be easier for you to work with.

Here is a detailed explanation of the code and how it works and why its made the way it is, then you can always extend it to what you need.

Image

1. This is the basic layout, a list that hold the card frames. These are the actual image frames found in the card object.
2. A card object, the image is the back of the card.

Image

3. Opening the card sprite in the editor, you can see it have 6 frames. The first frame (0) is used as the back of the card and then there is 5 different colours. These would be images in your case, I just use colours.

Image

4. There are 3 global variables which we will ignore for now.

In event 3: I do some clean up, its always a good idea to remove objects (Sprites) that you don't need to be there in the beginning of the game. In this case, because I know I will generate 10 cards, so I don't want a random card floating around causing problems. So I destroy all cards before anything else.

Event 4: Since its a matching game, I know there need to be 2 of each card somewhere in the cards. Therefore I use a repeat 2 times.
Next I add each "animationframe" in the cards starting from 1 to 5. If you look at the above image you have the backside of the card at frame 0 and then all the cards from frame 1 to 5. I use the "AnimationFrameCount - 1", because C2 counts the total number of frames to be 6, since the first index starts at 0. But I need the highest index to be 5, therefore I add -1 and make the loop start at 1.

Once that is completed you have a list like this:
Image

So two of each number from 1 to 5.

Event 6-7: We generate the card layout, by making two loops and add some numbers so we get the correct distance etc. The first loop (X) goes from 0 to 4 because I want 5 cards in each row and the second (Y) from 0 to 1. Remember that C2 starts at index 0, so 0 to 4 is 5 and 0 to 1 is 2. 5 * 2 = 10 cards.

Image

As we generate the layout we also choose a random index from the list which hold the pictures index and assign it to each card, and then we remove it from the list so it can't be chosen again.

So now we have our random cards nicely on the layout. So now to the player turning cards and to see if they match.

Image

So first of all I have added a Boolean variable to the card object, called "Turned" this is done so we can easily select the cards that the player have turned and to make sure that the player can't actually turn the same card twice.

Event 9: So if the player click a card, which is "Not turned" it will execute the code and the "Number_of_cards_turned" need to be less than 2, to avoid players turning to many cards.
So the first thing we do is to set the "animationframe" of the selected card to frame we assigned to it when we created the card. And then we add one to the global variable "Number_of_cards_turned" Which keep track of how many cards the player have turned so far.

Event 10 - 11: Since the player must only turn a maximum of 2 cards, we check to see whether its the first card or the second card that is currently being turned. And we store the picture value in the global variables called "Card_picture_1" or "Card_picture_2", the reason for this is that its much easier to compare values this way than to compare two identical sprite objects.

Next we mark the cards as being turned.

Event 12: Here we simply check if the player have turned 2 cards. If that's the case we wait 1.5 second so they have a chance to see what the second card they turned were.

Event 13: This is where we compare if card 1 and 2 are the same. If the Global variable "Card_picture_1" and "Card_picture_2" are the same then we know that the cards also are.

If that's the case (Event 14) We need to remove them. But first we have to reset the picking, because we started the whole event by picking a card based on whether we left clicked it or not and whether it was turned. But that wont work here because we need to remove both of the cards, therefore we use a Pick all Cards, which will ignore any former picking we did and then we can set up new conditions. So we then say that it should pick only the "Turned" cards, which are the two the player clicked and then we destroy them.
After that we reset all the variable back to their default values, so the player can choose again.

Event 15: (Else) If the two turned cards are not the same, we don't want to destroy them but simply turn them back around again. So as in Event 14 we reset the picking and choose only the "Turned" cards. Set their "animationframe" back to 0 so its the back side of the card showing and then reset all the global variables.

And then you have a working match game :D

Here is the CAPX so you can try it out:

https://dl.dropboxusercontent.com/u/109921357/Simple%20match%20game/Simple_match_game.capx
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Next

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest