How do I Create a ramdom stack of individual crates (sprites

Get help using Construct 2

Post » Sat Aug 13, 2016 5:30 pm

Hi All,

I'm new to Construct 2 (with a very basic amount of coding knowledge).
I want to make an endless runner that features obstacles on the ground that you could jump on/over or smash through.

I've been able to deconstruct the endless runner template and can figure out most things really, but I'm having some trouble figuring the obstacle thing out. I want the obstacles to be generated at random intervals (I can figure that out). I want the obstacles themselves to be random numbers of stacked individual sprites that could even be swapped out easily and have their own behavior/animations (Example: crates, boxes, cinderblocks, etc. that could each be platforms or get smashed through when player sprite overlaps). So there would be like pyramids (or maybe even some other randomly shaped) stacks of these sprites.

Some ideas I had were to create an invisible sprite at the set random position, then have the visible crate/box sprites spawn at positions relative to that invisible sprite. Maybe the invisible sprite has to be tileable or something to create a random height for the stacks of individual sprites. Maybe these individual sprites have to be in a container or family or something.

I really got stuck there and was hoping to get some ideas. My thought is to set things up to eventually allow for quick swapping out of sprite artwork.

Thanks a lot in advance for any assistance or ideas you may be able to contribute.
B
9
S
1
Posts: 3
Reputation: 431

Post » Mon Aug 15, 2016 11:58 am

It really depends on how you've set up the general endless runner gameplay but what you've described there is creating invisible 'spawn points' which sounds about right. You could have a 'numStacked' variable which picks a random number which relates to how many are stacked on top of each other. You could have this in an obstacle Family so you only have to set the number of stacked items once.
B
47
S
18
G
84
Posts: 2,262
Reputation: 49,778

Post » Mon Aug 22, 2016 11:19 pm

plinkie wrote:It really depends on how you've set up the general endless runner gameplay but what you've described there is creating invisible 'spawn points' which sounds about right. You could have a 'numStacked' variable which picks a random number which relates to how many are stacked on top of each other. You could have this in an obstacle Family so you only have to set the number of stacked items once.


Well thanks for the reply. I've been brainstorming and experimenting when I get the time. The technique I'm currently using is creating a series of events for each stack that I'll later call at random intervals as functions. I'm using an invisible sprite and creating instances of the sprites in positions relative to that spawn point.

I tried a whole lot of other stuff that wasn't working out for me, including using IID to identify and place the crate sprites. Anyway, I think this is my solution for now, but I'll see along the way if I can come up with a more elegant solution.
B
9
S
1
Posts: 3
Reputation: 431

Post » Tue Aug 23, 2016 12:50 am

Yes that sounds good. You could put an instance variable on the spawn point and give it an integer value. If 1 > call function Stacked1, if 2 > call function Stacked2, then the functions relate to which objects are being spawned in terms of position as you described. Then every time a spawn point appears on screen give it a random number, that should randomize what is spawning. Simple enough!
B
47
S
18
G
84
Posts: 2,262
Reputation: 49,778

Post » Tue Aug 23, 2016 12:56 am

plinkie wrote:Yes that sounds good. You could put an instance variable on the spawn point and give it an integer value. If 1 > call function Stacked1, if 2 > call function Stacked2, then the functions relate to which objects are being spawned in terms of position as you described. Then every time a spawn point appears on screen give it a random number, that should randomize what is spawning. Simple enough!


Thanks! I just wrapped up my session wondering how best to go about randomizing that. I'll give that a shot next time :D
B
9
S
1
Posts: 3
Reputation: 431


Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], boulerzzz and 4 guests