Random Position problems

Get help using Construct 2

Post » Mon Jan 20, 2014 3:14 pm

I need to randomize the starting position of 10 objects in 10 specific locations, so far I got, however when it randomizes the objects in places, it overlaps some elements
I need a solution to where to start, they are in different positions, and not overlap each other.

remembering, random works, only that sometimes, an element overlap each other
can someone help me?

tks (:
and I'm sorry if it is not the right place for this question, I'm new here
B
5
Posts: 34
Reputation: 322

Post » Mon Jan 20, 2014 6:20 pm

I'm completely new to here, so my answer may be completely non-sense, but, try checking if the object you just placed is in collision/overlapping other objects, if so reposition it again, not the best way to do it, but might work I guess
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643

Post » Mon Jan 20, 2014 6:46 pm

You could go the complex route and have an array that stores previous positions, to test whether the one you are placing has something in its place already, or simply throw in a collision/overlapping test, and redo the random again if it tests positive.
Image
B
27
S
9
G
5
Posts: 489
Reputation: 11,950

Post » Tue Jan 21, 2014 10:40 am

I like I could do to when collision / overlapping, redo the random?

in my event sheet: (I can not post images yet D:)

- On start of layout: destroys the object to be randomized
- then create object positioned in "slot.x" - "slot.y"
- and do other procedures to leave his position on the random slot

("slot" are 10 objects I created, which will be organized on the screen, and other objects, will be randomized on him, remembering that I want each object on top of a slot, none on the other)
tks
B
5
Posts: 34
Reputation: 322


Return to How do I....?

Who is online

Users browsing this forum: RIDETHEPIG and 7 guests