How do I make an Infinite level system?

1 favourites
  • 13 posts
From the Asset Store
Unlock Levels, Worlds & skin plus add coins by watching ads
  • Currently the way I have the level system setup is I have two global variables 1st Experience and 2nd Player level. And I attached an image of the coding minus when the enemy is destroyed it adds one to the experience global variable. So far this code works great for a level system of course I only have enough code in place for one level as of right now I would need to repeat this for x times for what the level cap I would want adjusting the experience value to be a higher requirement for each level if desired. but what I want to know is how can I make the game add to my global Player level without having to insert 100 or mode separate lines of level code and make the experience requirement scale up each time a new level is achieved. my game is suppose to be an infinite type of game with an infinite leveling system.

  • To make an infinite system, you would just need a formula to calculate the xp needed, such as Level*50 (so 50 for lv1, 100 for lv2, etc) And then change the code to this:

    (Note in this example the formula is Level * 50)

    If Experience >= Level * 50:

    Subtract Level * 50 from Experience

    Add 1 to Level

  • Is there not a way to make a system event also update the system event. Because in that example from how I am understanding it for each level I need to make a line of code with that formula. Is there not a way to make the system change the * 50 to * 100 and so on without making a line of code for each of those events?

  • That's the only event you need. Level * 50 will take the player level and do the math for you, you don't need to copy-paste the event. That's all you need. Note that the "Subtract X from Experience" must come before adding 1 to level for this to work properly.

    Unless what you mean is the xp needed rises in a non-linear method, in which case your best bet is Level ^ 2 (or 1.5 for a less steep curve). The ^ just makes it an exponential, meaning it isn't linear but also means a very steep curve after some time.

  • Awesome thank you for the help that worked perfectly I was just misunderstanding that formula, is there a way to display the experience gained and needed as this amount is increased?

  • I actually figured out how to display the values but I'm running into an issue of it getting to a certain point if the player level is high enough there is no longer enough room on the screen to display the value how would you make the display show it in decimals instead of the full number value example being 10000 is 10k, 1,000,000 is 1m, 2,500,000 is 2.5m?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There is probably a better way to do this, but here is an example: (if you prefer I can probably send the project file)

    also if needed i can explain in more depth if you want.

  • If you could send me that event sheet that would be awesome. it makes sense what you are doing the only thing is I'm new to construct so I don't know how you make those sub events if that's what they are.

  • Here is the file (Note that when you copy-paste it into your project, replace all mentions of 'value' to whatever you want to shorten, then delete the value variable when all done. Do the same and replace all the mentions of "Text" to whatever text object you want to change.

    BTW to add sub events, you can either right-click or two-finger-click on an event to open a menu, then select "Add sub-event". the quicker way to to press B when you have an event selected. B is the shortcut to adding a blank sub event.

    And no, this event sheet doesn't use any sub events.

    Hope this helps!

  • And to access the file, click the link, then press Download in the top-right since I shared via Google Drive, then go to the editor and on the start page select Open then Project File.

  • Thankyou for the help and your example worked great and when I coded the thousands into my project that also worked great but for some reason the millions is not displaying correctly. Is there something I might be missing or maybe something that could be conflicting?

  • I actually figured out why it wasn't working. I had created multiple sub groups for each value marker millions, billions, trillions..ect and I had duplicated the coding for the thousands into each one with the intent of changing them but for some reason having multiple instances of that same code prevented the millions from working so once I disabled all of the other groups it was working correctly. Thanks for all of your help, and by the way after looking into this quite a bit I think your solution seem to be the most strait forward.

  • Glad I could help!

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