Go to random layout.

For questions about using Classic.

Post » Fri Apr 05, 2013 10:42 pm

I want to go to a random layout when a level ends. Random within a select group of layouts, so as not to go to the menu or whatever.

I thought about spawning a random invisible tile at the levels exit that corresponds to a unique layout, but this doesnt seem to be the most practical way to achieve this.

Any of you out there have a better, easier way?
B
4
Posts: 7
Reputation: 339

Post » Sat Apr 06, 2013 4:29 am

Nevermind, figured it out by thinking a little more, now i feel dumb.
B
4
Posts: 7
Reputation: 339

Post » Mon Apr 08, 2013 4:41 pm

Thats cool. Can you tell me how you did it ?
B
5
S
1
Posts: 20
Reputation: 690

Post » Tue Apr 09, 2013 10:58 pm

"Go to layout" and then "random(n) + a" where n is the number of layouts to select from after starting point a.

For more direct layout selection you can use an array like R0j0hound did for sprite spawning like so:

{"man", "woman", "monster", "kid"}@(random(4)+1)
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Thu Apr 11, 2013 4:13 am

Ill try that out Jayjay, thanks for the tip.

I found another way, not sure if its the best way, but it worked for me.

At the start of the layout I generate a random number within say 1 and 100, and store it in a global variable.

I set this number at the layout start because I use it to randomize other stuff too.

At the end of the layout, if my number is between 1 and 10, go to layout 1. If its between 11 and 30, go to layout 2, between 31 and 100 go to layout 3, etc.

Dont know how practical this is, but it does the job and it also lets me decide how often a layout should appear by playing around with the ranges.

In this example layout 2 would be used less than layout 3, but more than 1 because of the chances my number has to land on each range.
B
4
Posts: 7
Reputation: 339

Post » Sun Jun 09, 2013 11:03 pm

where exactl have I add the "Go to layout" and then "random(n) + a" ?
B
4
Posts: 7
Reputation: 214

Post » Tue Sep 09, 2014 2:20 am

Its actually System-> Go to layout (by name) then type random in the text box.
B
3
Posts: 1
Reputation: 177

Post » Mon Sep 22, 2014 7:28 am

So me and some classmates are making a quiz for a client. We have come up with alot of questions and divided them into categories. The client wants them to be randomized. My question is, how do you randomize the questions within one category? Thanks in advance.
B
4
Posts: 10
Reputation: 220

Post » Tue Sep 23, 2014 4:54 am

@farrellsupreme, well if you keep the questions in order (eg: questions 1 to 4 are category 1, 5 to 8 are 2, 9 to 15 are 3, etc).

You can do it this way:

global('QuestionNum') = floor(random(global('CategoryQuestions')) + global('CategoryFirstQuestion'))

So that could be this code for category 1:

QuestionNum = floor(random(4) + 1 )

Random always goes just up to the number inside so in this case it would be rounded (floored) to 3, then add the +1 for making the category range of 1 to 4
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Mon Sep 29, 2014 11:14 am

We tried it but it didn't work. Can i send the file to someone? I have one with 12 questions and one with 14 questions.. I'm wondering if one of you can randomize it??
B
4
Posts: 10
Reputation: 220

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests