How do I create an object in random positions?

Get help using Construct 2

Post » Mon May 25, 2015 6:45 am

@sudeep98
well, random is random so duplicates may happen.
In your case a 1 in 16 chance.
@korbaach knows a better way I am sure, (please let us know Korbaach :D )
but
one way is
I like using sprites as it is more visual for me...
Image
.
be sure to change the count to however many sprite2 you have on your layout
and
remember even in this example above, when the count resets to zero, there is a chance (1 in 16 your game) it may reset to the same sprite.
B
36
S
10
G
4
Posts: 250
Reputation: 7,963

Post » Mon May 25, 2015 2:29 pm

...not so elegant..and not so random solution..
..but simple..no arrays,loops,functions...

Image
B
66
S
24
G
7
Posts: 1,514
Reputation: 11,039

Post » Mon May 25, 2015 3:31 pm

or
if you prefer the sprite method.
Here is a way to NEVER repeat.
you need to have
2 instance variables on the SetSprite.
One for Overlap and
another for LastOne
and the wait time to change the LastOne from 1 to 0 needs to be a touch longer than whatever the Every X seconds count
Image
Last edited by producermark11 on Mon May 25, 2015 11:36 pm, edited 2 times in total.
B
36
S
10
G
4
Posts: 250
Reputation: 7,963

Post » Mon May 25, 2015 8:40 pm

Lot of learning, Thanq for both of u @producermark11 @korbaach
B
24
S
7
Posts: 337
Reputation: 2,224

Post » Mon May 25, 2015 9:15 pm

@korbaach your solution is working only on X axis, I can see overlapping on Y axis. I tired to put all the combinations of X&Y but it's becoming a lengthier code, instead do you have any other way of solving it?
B
24
S
7
Posts: 337
Reputation: 2,224

Post » Mon May 25, 2015 11:23 pm

Why not consider using the sprite method above?
And, if say, you want to add ( or subtract) the number of enemy positions during the game,
it is probably easier to do that with the sprite method and keep the game in
one layout/event sheet
B
36
S
10
G
4
Posts: 250
Reputation: 7,963

Post » Tue May 26, 2015 8:17 am

@producermark11 I'll surely try that now. Tnx
B
24
S
7
Posts: 337
Reputation: 2,224

Previous

Return to How do I....?

Who is online

Users browsing this forum: BackendFreak, farsen, lahbach, newt, TRMG, Yahoo [Bot], Yarfapet and 19 guests