nimos100's Recent Forum Activity

  • When i create this 3 levels with 6, 10 and 20 cards and when create last 10 pairs how level 1 and 2 will be working if game dont should have too many cards?

    My example simply shows how you can make it fairly simple using a fixed amount of cards. If you need more cards or more flexibility you will have to adjust the code for that. Its only meant as a starting point or to give you some ideas.

    If you need different amount of cards for each level you have to change the code so it can do that. Because you are right the current code doesn't work if the amount of cards changes. The reason for that is:

    Event 4: Here we add all cards in the card object to the list 2 times. So we can assign them to the cards that we place on the table in Event 6 and 7.

    Event 6-7: But here is the problem as we create the cards we also assign them a random card from the list. But if we only need 10 cards to be on the table but have added 50 different cards to the list for it to choose from. The chance is that we will end up with none matching cards.

    So to fix it, we have to be sure that only the needed amount of cards are available in the list and that we don't add more cards to the table than we have cards for.

    To make it easier to work with I add a function that will handle that for us.

    Its always a good idea, I think whenever you create a function to write with comment what the function need to work.

    So at the top you can see, it requires:

    "Needed cards" - This is the total number of cards needed. So 10 for instant means we have 5 cards with 2 of each type, so they match.

    "Cards_in_X" - How many cards should be in the horizontal direction. So 5 means you will have 5 cards in a line.

    "Cards_in_Y" - How many cards in the vertical direction, so we could make that 2 so you would have 5 cards in each line and 2 rows. Which equal 10 cards.

    Event 18: Since we added all cards in our game to the list in Event 4. We might have to many cards in the list for what we actually need. So the first thing we need to do, is to make sure that we only have the correct amount of cards to choose from. So we check whether the "Itemcount" in the list is greater than what we need. If that's the case we need to remove some cards from it. So we choose a random card from the list and store it in the variable "Card_to_remove". The reason to do this is because we added cards twice, so we also need to remove two entries from the list.

    Event 19: And we do that here by going through the list and remove all the cards from it which match this "Card_to_remove".

    I have a total of 10 different cards in the game. So if I use all of them, the list would look like this:

    Imagine that I only wanted to use 6, then the list could look like this:

    So now we can remove cards from the list and only end up with the ones we need.

    Event 20 - 21: These are the same as in the original, except that we use the "Cards_in_X" and "Cards_in_Y" to decide how we want the cards to be arranged.

    So we use the parameters (1) and (2) which we use when calling the functions in the loops to decide that. The reason I subtract one, is simply to avoid having to think about the 0 index in C2, when calling the function.

    Event 6: Now that the function is made we don't really have to think about it anymore, all we have to do is to make sure that we call it with the correct values. In this case we want 10 cards, 5 in each line and 2 rows.

    So as long as you don't go higher than what you have cards for in the game and you make sure that when calling the function this is true:

    [Needed cards = Cards_in_X * Cards_in_Y]

    Then it will work.

    CAPX - https://dl.dropboxusercontent.com/u/109921357/Simple_match%20game%20tut%20files/Simple_match_game.capx

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • nimos100 yes i set new row for more cards and that thing happen

    My guess is that you have added to many cards, because it should work.

    After you run the game and all the cards are on the layout, are the list empty? if it ain't its because you added more cards than you need.

  • nimos100 wow, thanks for your initiative, im wondering how make game with 20 cards on screen

    i add other card colors but not alwys card matches, sometimes i have last card with no pair

    After you have added the extra 5 cards, you go to Event 7: For "Y" 0 to 1 and you change that to For "Y" 0 to 3

    Remember the index starts at 0. So For "X" 0 to 4" = 5 which are the number of cards in the X (Horizontal) direction. So to get 20 cards, we need to have 4 rows in Y (Vertical) direction, because 5 * 4 = 20 , therefore you need it to be 0 to 3, because that's 4.

  • Its a bug in C2 it seems, these two conditions are not normally able to be used together. However it seems that C2s "validation check" only apply if you drag the "every x seconds" to the "On timer event". However no validation is made if you drag The "On timer event" to the "Every x second" event and then it apparently gets bugged and think its an "Is between angle" event

    You should post this in the bug section.

  • Here are some tips:

    1. Original size, will give you the best quality because you will neither add or remove pixel information. However if you need small but somewhat detailed images, this might not be the best way to go.

    2. Scaling down, can be a good idea as it can be difficult to draw a lot of details in a 32x32 sized image. So you can make the image larger say 128x128 and then scale it down. Since you are scaling down its more difficult to see the loss of details from the original sized image. Therefore it can be done. Imagine a picture of Mona Lisa at 1024x1024 and you scale it down to 32x32, then you need 1048576 pixels that made up Mona Lisa in the original image to suddenly be represented in 1024 pixels. So logically you will loose a lot of details, but since you are scaling down, the new image is so small that you can get away with it.

    3. Scaling up, if possible I would avoid doing this, but if you have to, you really need to scale by a small amount, especially if your original image is small to begin with. It will pretty much have the opposite effect of scaling down, because as you scale up its also easier to see all the errors since the image gets larger, which is because you are adding pixel information that ain't available in the original image, therefore you get this stretched, fuzzy/smooth look as it tries to compensate for these missing information. However if you original image is somewhat large to start with, you can get away with more scaling up.

  • The answer seems to be no but I figured I'd check first. Perhaps this can be a feature suggestion if it's at all possible to implement.

    Anyway, is there a way to apply the wrapping function of the Wrap behavior to other behaviors? So for example, have Pathfinding walk off the edge to wrap to the other side to take a shortcut? Or have LoS behavior spot an object on the other side of the layout by looking towards the edge?

    There are no way to do this with the current behaviours, simply because they weren't designed for it. But you could program your game to work like that if you wanted, might not be easy but think its possible.

  • Is between value picking

    This is just a minor thing, but it would make sense if the "system -> Is between values" were also available as a picking condition for objects.

    Since you can pick objects based on variable values, it would be nice if this were also a possibility without having to use other picking conditions.

  • > You can turn your Rooms into global objects, you do this in the properties panel, top left corner. Then they will be available in all your layouts.

    >

    Oh! I have to try that. I guess the UIDs are saved between the layouts, so I can access every object with the same UID through the rooms. Thank you, I will reply when I try it. Thanks in advance ^^

    Yeah its the same object from once its created with all settings etc.

  • You can turn your Rooms into global objects, you do this in the properties panel, top left corner. Then they will be available in all your layouts.

  • You are stretching the image?

    If you have 5*6 pixels in your image you have a total of 30 pixels of color information, if you stretch those to a 100*100 image you suddenly have 30 pixels of information to cover 10000 pixels so your image get stretched. Make the original image in the image editor match the size you need in the game and it wont stretch

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

    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.

    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.

    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:

    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.

    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.

    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

    Here is the CAPX so you can try it out:

    https://dl.dropboxusercontent.com/u/109921357/Simple%20match%20game/Simple_match_game.capx

  • too much to print screen;) i delete most addons now

    > 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

    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.

nimos100's avatar

nimos100

Member since 23 Sep, 2012

None one is following nimos100 yet!

Trophy Case

  • 12-Year Club
  • Coach One of your tutorials has over 1,000 readers
  • Educator One of your tutorials has over 10,000 readers
  • RTFM Read the fabulous manual
  • Email Verified

Progress

16/44
How to earn trophies