# generate random coins over obstacles

Get help using Construct 2

### » Wed Mar 13, 2013 9:05 am

Hi i have a problem which is i made a game that random floors coming from the right side of the screen and the character have to jump on the floors in order not to fall.. The problem is that I want to spawn random number of coins over each floor randomly, and each coin would keep distance of few pixels of each other and I want to determine the amount of coins if it's possible too.
you can see it in this game:
would like to see an example
B
5
S
1
Posts: 16
Reputation: 532

B
5
S
1
Posts: 16
Reputation: 532

### » Wed Mar 13, 2013 8:56 pm

@shadowfan33 I could be wrong, but those coins don't look random. If it's an endless runner, it may be grabbing random floor chunks, but those coins looked precisely placed for a better platforming experience. They probably had something scripted to grab a specific coin layout for a specific length of floor.

That's not the example you requested, but if this game is what you're looking for, it's probably more crafted than it appears.
B
8
S
2
G
1
Posts: 37
Reputation: 1,476

### » Wed Mar 13, 2013 9:12 pm

@GabeOfThrones Maybe you right but still i need some example, my event is creating too many coins, always making them appear on each other and it dosen't look nice and even bad. I want to spawn like 5 for each floor and that they will keep an equal distance of pixels from each other like lined up soldiers. I'm stuck with this problem and can't continue my game..
B
5
S
1
Posts: 16
Reputation: 532

### » Wed Mar 13, 2013 11:04 pm

@shadowfan33 If you want 5 to spawn for each floor you could write a simple "for" loop that spawns and positions the first one above the floor in a particular spot and increments the X by your desired amount for the subsequent coins. If you want the position of the whole 5 coin chunk to move around some, you could figure out a range for the starting position and randomize the X and Y for that. You could also randomize the number of coins in a row just by limiting the for loop.

Simple example:
GabeOfThrones2013-03-13 23:20:59
B
8
S
2
G
1
Posts: 37
Reputation: 1,476

### » Sat Mar 16, 2013 8:14 am

you might be better off just making like 3-5 platforms off screen of course and use Pink invisible square to have math code to random select the platforms and with it you should just pin the coins on top of each one using image point i believe ?
B
7
S
2
G
3
Posts: 58
Reputation: 2,284