Random Gen.Cluster Problem

Get help using Construct 2

Post » Sat Dec 22, 2012 1:22 am

Hi. In my game, I have a layout that randomly generates a map. BUT, for some reason, it all generates in one area, I want it spread out. This is what I have: So, what do I do?
B
29
S
7
G
3
Posts: 361
Reputation: 6,187

Post » Sat Dec 22, 2012 1:30 am

I believe if you increase the size of your layout/margin then you can set them all to (random(width) and random(height. The layout of the items will be random, but otherwise you'd have to manually place them all and that's just a total bother.
B
6
Posts: 90
Reputation: 690

Post » Sat Dec 22, 2012 1:46 am

Thanks! Is there any way I can make certain objects spawn randomly, but in certain formations?
B
29
S
7
G
3
Posts: 361
Reputation: 6,187

Post » Sat Dec 22, 2012 2:16 am

Ahoy ! You forgot to put a range in your script
You see , set all the random(1024) to random(0,1024) !
Or I'll only spawn in 1024,1024
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

Post » Sat Dec 22, 2012 2:18 am

[QUOTE=Whiteclaws] Ahoy ! You forgot to put a range in your script
You see , set all the random(1024) to random(0,1024) !
Or I'll only spawn in 1024,1024[/QUOTE] Is that any different from what I said? Not to sound mean, but it's a serious question. :)
B
6
Posts: 90
Reputation: 690

Post » Sat Dec 22, 2012 2:20 am

[QUOTE=InvaderX] Thanks! Is there any way I can make certain objects spawn randomly, but in certain formations?[/QUOTE] Do you mean like have trees spawn in a triangle formation, but randomly across the map? If you make another sprite with the same textures, but pre-set in that formation, you could have that sprite spawn in randomly like normal trees. I'm sure there are other ways, but that's what comes to mind. :) Hope that helped.
B
6
Posts: 90
Reputation: 690

Post » Sat Dec 22, 2012 3:58 am

[QUOTE=WAFFLE OF WAR] [QUOTE=Whiteclaws] Ahoy ! You forgot to put a range in your script
You see , set all the random(1024) to random(0,1024) !
Or I'll only spawn in 1024,1024[/QUOTE] Is that any different from what I said? Not to sound mean, but it's a serious question. :)[/QUOTE]

Random require a min value and a max value. So yes it is different than what you said.
random(0, 1024) will produce a number between 0 and 1023
random(1024) will produce a number of 1024

what your saying is set X to random(width), random(height). which will not solve the problem of items being placed in only one location

random(0, width)
random(0, height)


@OP
You can also do a "repeat x" loop. So you don't need to create numerous "create tree" actions.jayderyu2012-12-22 04:00:47
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Sat Dec 22, 2012 7:01 am

[QUOTE=jayderyu]random(0, 1024) will produce a number between 0 and 1023
random(1024) will produce a number of 1024[/QUOTE]
What? No, that is incorrect. random(1024) is the same as random(0,1024)!

If it were like you're saying, it would be a bug, because it would be the same as typing 1024.
B
35
S
8
G
8
Posts: 532
Reputation: 6,868

Post » Sat Dec 22, 2012 3:04 pm

By the way InvaderX... You should use loops when you repeat things
[code]+On start of layout
    +repeat 14 times
        -> create Tree on layer 1 at (random(1024),random(1024))
    +repeat 10 times
        -> create Wall on layer 1 at (random(1024),random(1024))[/code]
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sat Dec 22, 2012 3:52 pm

I did not know C2 had that! Thanks!
B
29
S
7
G
3
Posts: 361
Reputation: 6,187

Next

Return to How do I....?

Who is online

Users browsing this forum: imnotspecial, tomi71, totoe, Yahoo [Bot] and 13 guests