Help spawning random sprites but with conditions

Get help using Construct 2

Post » Mon Nov 26, 2012 5:25 pm

Hello,

Is anyone able to help me. I have a family of sprites and I want to spawn 2 of them at random and position them at random angles (from an array of angles). I need to make sure that the 2 sprites are not the same sprite at the same angle. They can be the same sprite at different angles or different sprites at the same angle. I have no idea how to write this so any help to point me in the right direction would be great.

Thank you.
B
18
S
4
G
2
Posts: 77
Reputation: 1,588

Post » Mon Nov 26, 2012 6:16 pm

you could do it like this

example
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Mon Nov 26, 2012 7:23 pm

Hi @vtrix

Thanks so much for getting back to me, and thanks for the capx. Unfortunately my angles are set to 90 degree increments (0, 90, 180, 270).

In my game both sprites and the angles they're set to are chosen at random.

This is more or less what I want. The problem I'm having is occasionally the 2 sprites spawned are the same sprites at the same angle.

Is there a way I can check to see if sprite 1 and sprite 2 are the same, and if they are, then set them both to different angles.

I hope that makes sense, if not let me know.

Thanks.
B
18
S
4
G
2
Posts: 77
Reputation: 1,588

Post » Mon Nov 26, 2012 8:19 pm

@unplugged

i found a solution

example
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Mon Nov 26, 2012 8:51 pm

@vtrix

Wow, that's fantastic, and it works really well. I've been scratching my head over this for a while, so I really really appreciate the help you have given me.
B
18
S
4
G
2
Posts: 77
Reputation: 1,588

Post » Mon Nov 26, 2012 9:27 pm

no problem, glad i could help
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028


Return to How do I....?

Who is online

Users browsing this forum: anty21ro, LeFuji, RookieDev, TRMG, Yahoo [Bot] and 18 guests