Simple Array Shuffle Question?

0 favourites
From the Asset Store
Simple but fun word game. Restore an original word from shuffled letters.
  • For that, I already have that logic. (First C3p project I have uploaded). Now I want a way to do it easier. I have multiple Sets of animation, eg, Colors, Numbers, Alphabet etc. (Second c3p Project)

    Thanks to you and other community members I have come to this far. :)

  • Every time when the user restarts the layout I want PICTURE_SET & TEXT_SET to have random values. Please check the image below.

  • So for that, I created a JSON array and put all my animation names into it, (and want to make it random). And then trying to retrieve and set the name from it to PICTURE_SET & TEXT_SET. Please check the bellow image.

    Sorry for posting these it in so many different posts.

  • Empty cells in the array make the task more difficult. You should either copy non-empty cells into a temporary array, and shuffle it. Or use this method with Advanced Random:

    dropbox.com/s/elkhyxz8u75syzb/QuestionForDop2000%20%28With%20Layouts%29.c3p

  • I'm speechless. Thank you.

  • Hi Dop. Few questions.

    1. You can see I have two different sprites, one is "PICTURE_SET" & another one is "Preview_PICTURE_SET", my question is Can I ditch the Preview_PICTURE_SET entirely? and just use another instance of "PICTURE_SET" for the preview purpose?

    My failed attempt. So for that what I did, Created another instance of PICTURE_SET (Now I have a total of 7 instances on the screen) gave another Instance Variable called "XYZ" and set it to 1. And made all other 6 instances' "XYZ Instance Variable" to 0.

    In the event-sheet created a condition when "XYZ=1" set the animation PICTURE_SET to "" - Now I'm not sure what I have to give here. Please help.

    2. How to make FRAMES of each PICTURE_SET to random order. I have multiple frames for some animation. I want it to appear randomly every time when user restart.

    For eg. (Please refer to the picture below) Letter B have two frames, I want it to appear randomly.

    So for that what I did, (Please check the image below)

    Created 6 different Global Variable, On the start of the layout Set each GV to choose(0,1,2,3).

    (range is 0 to 4 because I do have some animation which has more than 2 frames) and then gave a condition and set the animation frame to that Global Variable. It sometimes works, I know I made it unnecessarily big. Please help.

  • 1. I don't know. You have lots of objects with long names, I have no idea about their purpose.

    2. Simply add "Sprite set animation frame to random(self.AnimationFrameCount)" after you set a random animation to the sprite.

  • 2. WOW, Awesome. Thank you.

    1. Please check the image below.

    when the user clicks any instance of "PICTURE_SET", "Preview_PICTURE_SET" will have exactly the same picture previewed on it. that the purpose of "Preview_PICTURE_SET".

    also, please the previous c3p

    dropbox.com/s/elkhyxz8u75syzb/QuestionForDop2000%20%28With%20Layouts%29.c3p

  • Can I ditch the Preview_PICTURE_SET entirely? and just use another instance of "PICTURE_SET" for the preview purpose?

    Yes, you can. Just make sure it's not picked in the event where you assign random animations. You can use a boolean instance variable isPreview for this.

    When you need to pick the preview instance, use "isPreview set" condition

    When you need to pick all random instances, use "isPreview is NOT set"

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Empty cells in the array make the task more difficult. You should either copy non-empty cells into a temporary array, and shuffle it. Or use this method with Advanced Random:

    https://www.dropbox.com/s/elkhyxz8u75syzb/QuestionForDop2000%20%28With%20Layouts%29.c3p?dl=0

    Every previous quest has been solved, as usual, thanks dop2000

    The array shuffle logic you gave work fantastically, it amazingly skips the blank array cell.

    One question, I have one final round where the user will be faced every combination. means every ARRAY JSON cell from the X & Y-axis. means all data from JSON Alphabet, Number, Color, will come randomly. I thought it will be easy if I only edit Y-axis value to AdvancedRandom.Permutation(n) but it's not working. Please help.

  • means all data from JSON Alphabet, Number, Color, will come randomly.

    You should have mention this before..

    If you are not planning to make frequent changes to this array, maybe it would be easier if you made it 1D. Put all values on one X axis (in one line), numbers first, then letters, then colors. Without empty spaces between them.

    Then you can use my method with Advanced Random, but for numbers you create premutation table with length 10 starting from 0. For letters - length 7 starting from 10. For colors - length 8 starting from 17. For mix of everything - length 25 starting from 0.

  • Thanks for your reply. Actually, the logic you gave previously is what I wanted and it works fantastically well. While looking at the JSON table I got that idea, What if I have one level with the utmost difficulty, kind of a boss fight. (I don't know calling it boss fight make sense xD). So I asked this

    means all data from that one JSON ARRAY (consists Alphabet, Number, Color) will come randomly.

    Initially, I thought only altering "Y-axis value to AdvancedRandom.Permutation(n)" will work but no,

    If it not that long to crack I still request you to help me to crack this 😅 because the array needs to be updated quite often 1D array way would be quite tedious.

    but anyways I'm still grateful to you because of you I have come this far and exploring different ideas.

  • Since every quiz question is a separate animation, you can do this easier without arrays. Put an instance with each animation on the layout (off-screen). Then in "On start of layout" event pick a random instance and move it to the layout. Repeat 6 times.

    This will work for numbers, letters, colors, or any mix of them. All you need to do is put the correct instances on the layout.

  • Interesting. Only caveats would be to place every image off-screen. Got that.

    Another way I tried it (similar to what you have suggested using 1D array)

    Created a new row and copy and paste every element to it.

    Then changed this

    One question. What "+ System: LoopIndex < 100" does?

    Does it shuffle the cells 100 times? If my ARRAY s both X, Y-axis exceeds 100 cells in length and widht should I update that "100" accordingly?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)