How do I set a conditional random?

Get help using Construct 2

Post » Sun Feb 28, 2016 9:49 pm

Hello all,

In my game I have a screen full of 26 letter sprites, each one a different letter of the alphabet. I want to make them shuffle so they are in different spots every few seconds to make the game much more challenging. However, I only want one instance of each letter on the screen. I know I can spawn a random letter by using spawn another object> Letters(Family). However, I don't know how to give it the condition to not pick one already on the screen. Any Ideas?

Thanks,

William
B
8
Posts: 25
Reputation: 356

Post » Sun Feb 28, 2016 10:03 pm

What do you think about an array?
You could mix it, pick numbers/letters, ...

I think you get a good idea with this tutorial
https://www.scirra.com/tutorials/280/cr ... match-game

  • System > On start of layout | system > load game from slot "brain"
  • System > On load failed | system > scroll to obj_Forum
B
17
S
8
G
5
Posts: 340
Reputation: 4,707

Post » Sun Feb 28, 2016 10:06 pm

I was going to suggest the same solution/tutorial, so take that as a second vote. :)
B
8
S
2
Posts: 32
Reputation: 620

Post » Sun Feb 28, 2016 10:28 pm

But my letters are objects, and cannot go into an array? I know how to build an array and randomize it, but what values in the array would let me spawn corresponding objects? I was thinking ID's, but you cant't spawn objects based on that in construct2 :(
B
8
Posts: 25
Reputation: 356

Post » Sun Feb 28, 2016 10:59 pm

No...but
How do I load a family into an array?
korbaach wrote:maybe you can use one sprite with 26 frames?

:)

rndLetters.capx
Image
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Sun Feb 28, 2016 11:04 pm

@korbaach,

That looks like it works for display, but i need my objects to be interactable; The user needs to click on them and they in turn perform actions based on their value (Each letter has a variable of it's own alphabetical value). I don't believe there is a way to have it all in one object with 26 different values? Any Recommendations?

Thanks, William
B
8
Posts: 25
Reputation: 356

Post » Sun Feb 28, 2016 11:20 pm

.....Unless I use the current frame number as alphabetical value? I could create an array with each alphabetical value("A-Z"), index 0 is A, index 25 is Z......I could say if
LetterArray.at(Letter.AnimationFrame) = uppercase(mid(WordArray.At(index),index2,1))
Then correct?
Am I crazy or does that sound viable?
B
8
Posts: 25
Reputation: 356

Post » Sun Feb 28, 2016 11:40 pm

you have frames 0,1,2..etc..&you set array(width=26) with index 0,1,2...then you can simple set value to Array.At(Sprite.AnimationFrame)..

scrabble-letter-values
Image


rndLettersValue.capx
Image

sprite3Letters.capx
Image
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests