How do I spawn random single objects in an autorunner game

0 favourites
  • 3 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • 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!

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)