How do I spawn loot in random locations inside a sprite

Get help using Construct 2

Post » Sat Feb 20, 2016 6:42 am

Basically I want a bunch of these different loot sprites to spawn in a area defined by a invisible sprite with a different spawn chance for each loot sprite. Like random loot in a room. I want to be able to make different spawn rates for each area, that would be very nice for my game. Is this possible and if not could I still spawn them like that some other way: is there a workaround?

This is a critical part in my game as looting is a big aspect of it please help me out.
B
27
S
12
G
5
Posts: 79
Reputation: 5,223

Post » Sat Feb 20, 2016 7:38 am

Use the random() expression.

Code: Select all
On SpawnCondition - Set RandomVariable to random(100)

If 0<RandomVariable<30 - Create 30%chanceLootSprite at InvisibleSprite.X+random(-InvisibleSprite.width/2,InvisibleSprite.width/2),InvisibleSprite.Y+random(-InvisibleSprite.Height/2,InvisibleSprite.Height/2)

If 30<RandomVariable<100 - Create 70%chanceLootSprite at InvisibleSprite.X+random(-InvisibleSprite.width/2,InvisibleSprite.width/2),InvisibleSprite.Y+random(-InvisibleSprite.Height/2,InvisibleSprite.Height/2)


Repeat for however much loot you want to create.
Mistakes were made.
B
53
S
27
G
114
Posts: 1,695
Reputation: 64,438

Post » Sat Feb 20, 2016 7:27 pm

Very helpful thanks!
B
27
S
12
G
5
Posts: 79
Reputation: 5,223


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 11 guests