0 Favourites

How do I Generate the Pillars ONCE in an Autorunner?

  • The pillars are randomly generated every single time they're destroyed or the layout restarts, how can I make it so the pillars are only randomly generated in one certain way, so when they're deleted, they're all in the same positions as before?

  • Maybe create 10 groups and each group has your set spawn sequence inside, then set it to randomly select one of your groups

  • I'd say something like what uzumiapps suggested. Although, instead of groups, you could have a global variable called "STAGE", and set it to 1-10 on layout start at random, then define what each stage means as sub events of your primary creation event!

  • CaesarSalad

    How about this?:

    https://www.dropbox.com/s/pzcukq604drys ... .capx?dl=0

    This generates a random level on the fly, saving it to an array as you go - I'm saving heights, but you could swap this for sprite frames/animations, different sprites etc

    Pressing the space bar will allow you to replay the level from the start; if you reach the point where you restarted in the saved level then it will continue randomly generating the level from that point.

    Press R to reset the level.

    If you want to permanently save the current level then you could save the dictionary to local storage, allowing you to reopen it in subsequent play sessions.

  • Thank you all for the comments! I'll check out everything in a few hours!

    @mekonbekon Thank you especially, I'll check it out in a few hours

  • CaesarSalad

    How about this?:

    This generates a random level on the fly, saving it to an array as you go - I'm saving heights, but you could swap this for sprite frames/animations, different sprites etc

    Pressing the space bar will allow you to replay the level from the start; if you reach the point where you restarted in the saved level then it will continue randomly generating the level from that point.

    Press R to reset the level.

    If you want to permanently save the current level then you could save the dictionary to local storage, allowing you to reopen it in subsequent play sessions.

    So the capx you gave me is basically exactly what I wanted, thank you very much. But I tried to incorporate this into my project and optimize it but it still isn't working properly. Here's a download to the capx www[DOT]dropbox[DOT]com/s/86q1bph11qnwowc/ScirraHelpPlease[DOT]capx?dl=0

    The game overall is a bit buggy but we're just focusing on the generation part, all of that is on the bottom of the event sheet. If wanted I can add credit in the app as this is going on the Playstore. Thank you

  • Sorry CaesarSalad I'm still running v244 due to client work so can't view the file - could you post a screenshot of the code instead?

  • Sorry CaesarSalad I'm still running v244 due to client work so can't view the file - could you post a screenshot of the code instead?

    I can at the late afternoon EST. It's 7AM here, Stay tuned.

  • Sorry CaesarSalad I'm still running v244 due to client work so can't view the file - could you post a screenshot of the code instead?

    So I tweaked it a bit as you can see in the "code" and this is how it turns out. Even from the original it just isn't right.

    Window size 630, 360

    Layout Size 630, 360

    Margins 500, 500

  • Sorry CaesarSalad I'm still running v244 due to client work so can't view the file - could you post a screenshot of the code instead?

    If the images sent don’t help you help me, you could always get the newest beta of Construct 2, I’ve looked everywhere to figure out how to do something like this and the Capx you gave me was genius and exactly what I needed, it just won’t work on my Capx, I think it’s a layout sizing issue but then again it just looks messed up. Looking forward to a response

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • CaesarSalad

    Apologies for the delay in getting back to you. I'm still running the latest stable version due to client work, so can't update C2 yet, sadly.

    Based on the code and image you posted one or more of the following could be a problem:

    The X-axis spawn position for the pillar creation looks incorrect - it should be 630, not 1100.

    Make sure that the origin point of the pillars is in the bottom left hand corner.

    Also, the array's initial dimensions should start be 0,1,1.

    Aside from that I can't see anything obvious that would be causing issues. Hope that helps

  • CaesarSalad

    Apologies for the delay in getting back to you. I'm still running the latest stable version due to client work, so can't update C2 yet, sadly.

    Based on the code and image you posted one or more of the following could be a problem:

    The X-axis spawn position for the pillar creation looks incorrect - it should be 630, not 1100.

    Make sure that the origin point of the pillars is in the bottom left hand corner.

    Also, the array's initial dimensions should start be 0,1,1.

    Aside from that I can't see anything obvious that would be causing issues. Hope that helps

    Alrighty I'll try this soon. In a few hours I'll have access to a PC.

  • CaesarSalad

    Apologies for the delay in getting back to you. I'm still running the latest stable version due to client work, so can't update C2 yet, sadly.

    Based on the code and image you posted one or more of the following could be a problem:

    The X-axis spawn position for the pillar creation looks incorrect - it should be 630, not 1100.

    Make sure that the origin point of the pillars is in the bottom left hand corner.

    Also, the array's initial dimensions should start be 0,1,1.

    Aside from that I can't see anything obvious that would be causing issues. Hope that helps

    Still doesn’t seem to be working. Anyway I could get the Capx working for you? The Generation is wrong yet I based it off the Capx you gave me. Not sure why it isn’t working.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic Locked topic
220 14,893
Tom's avatar
Tom Construct Team Founder
Unread hot topic
187 45,147
Yann's avatar
Yann
Unread hot topic
99 10,152
karshinkoff's avatar
karshinkoff