How do I spawn random single objects in an autorunner game

Just started using Construct 2? Post your questions here

Post » Sat Sep 06, 2014 5:25 am

Hey all,

I've been working on my first game and it's going to be an infinite runner game similar to Jetpack Joyride. I've looked at the autorunner template and I've modified it to suit my purposes. Right now, I have the floor spawning consistently in the way I want it to. I'm having problems though spawning single objects like an enemy, coin, set of 5 coins, ramp, etc.

I tried replicating the "NextBlock" code structure from the template but I couldn't get it to spawn single coins. As you can see, I changed the code and now I have the game spawning what appears to be 125 coins just pixels away from each other in a line. A bunch of ramps seem to be spawning on top of each other too and the game is spawning ramp upside down.

How can I spawn using code, say, a rectangle of 24 coins or like a set of coins that says "BARRY" like Jetpack Joyride or something. I figure if I understand how spawn a certain amount of coins whenever I want, I should be able to do that for enemies and more. I have another question regarding autorunners and creating artwork for them. I guess I should be creating my artwork (floor pieces) in increments of 2, yes? 32*32, 512*256* 16*32, etc?

So this is my first time creating a game with Construct 2. I've gone through a couple of video tutorials and examples and I'm still learning! If there are any tutorials out there that anybody thinks I need to see in regards to my problems or creating an infinite runner, please link or mention them. Thank you! And thanks for the help!
You do not have the required permissions to view the files attached to this post.
B
28
S
14
G
21
Posts: 179
Reputation: 13,548

Post » Sat Sep 06, 2014 7:31 am

As for the initial question of how to spawn single objects randomly, simple, use the random() function for time objects spawn and object positions. My guess on the whole shapes thing is, they would be pre-programmed shapes or along some kind of path system and the same spawn time concept with the random() function.

Check out this example maybe it'll help you.
You do not have the required permissions to view the files attached to this post.
B
13
S
2
G
1
Posts: 47
Reputation: 1,191

Post » Thu Sep 11, 2014 6:17 pm

Hey ryanhagz, thank you so much for your help! That was a real simple question! Man, I have a lot to learn!

I have another question now kind of a long the same lines. Should I make a new post or just post here? I'll probably have a couple of dozen questions regarding his game in the future. Anyway, now that I know how to spawn a single object like a coin or enemy, how would I spawn multiple coins or enemies? Say I wanted to created a 5 coins in a line or create a heart shaped cluster of coins. Stuff Jetpack Joyride did.

I don't know much about coding but I imagine I'll have to create a function or array that holds the coin information (like how many coins spawn, where they spawn, in what shape they spawn, etc). Am I thinking correctly?
B
28
S
14
G
21
Posts: 179
Reputation: 13,548


Return to Beginner's Questions

Who is online

Users browsing this forum: vslk and 4 guests