How do I "For Every x Value Added to Number Variable, Go To Layout"

  • So I'm wondering is there a way to use the for statement in conjunction with a global number variable to set it so that, for every let's say 1000 points (or otherwise everytime 1000 points is added to score, or for every 1000 points added to score) go to next layout? I basically just want a level change that is based on accumulated score.

  • I just use 2 variables for this that count up together. One is the general score, the other is a variable that counts up to 1000 and upon hitting 1000 resets to 0. When the second variable hits 1000 you can change layout.

  • plinkie to the rescue again, thank you, that makes a lot of sense

  • So I added in the logic to this and have run into a problem,

    I use "Scoreext(1,2,3,4,...,12)" to represent the secondary number variable that actually changes the level and use "Score" number variable that adds up throughout every level (there is only one instance of "Score" that is used across all levels)

    [to explain further, "Score" is set on gamelevel1 to 0 and increases for every enemy you absorb, as you go through levels, the player's score is always referring to "Score" number variable created on level1]

    essentially to do what you suggested I added a variable to each level which is set "Scoreext(1,2,3...,12)" to "Score" number variable every tick. (There are 12 levels in the game)

    I then set it so (trigger once) when Scoreext (1,2,3...,12) = 1000 [this number varies from level to level] go to gamelevel2 and set Scoreext to 0

    the problem i have encountered is that if you apply this technique to only two levels it works fine, however if you do it to all twelve levels it suddenly stops working on any level. I have noticed from testing that if you make the game set "Score" to 1000 it will go to gamelevel2 as intended, however if you make the game set "Scoreext" to 1000 it does not go to gamelevel2 [I believe this is the core of the issue]

    With that I believe that the reason it isn't working is either that maybe it has something to do with the-- Set "Scoreext" to "Score" every tick (though I don't get why that would break it)

    or maybe that it has to do with the fact that I made it so there are 12 "Scoreext" that all are individual to the level they are on; the list looks like this gamelevel1 = Scoreext, gamelevel2 = Scoreext1, gamelevel3 = Scoreext2, so on so forth. Maybe the issues lies in that there are multiple instances of the "Scoreext" that are all referring to the one "Score" number variable?

    I'm not sure, any help would be appreciated.

    Also, plinkie , do you use the every tick function to make the variables count up together or is there another method I'm not seeing? If there is another method I could use it to further isolate the problem and test.

  • Well that escalated quickly. If you are changing the limits per level then you can do something like this :

    Points collected = add to Score2 (score for that level)

    Another variable, limit (varied limit to hit per level)

    Then say, if Score2 >= limit, go to next layout

    Then you set the limit variable separately, if level 1, limit=1000. if level 2, limit=2000 etc

  • ok i think i get it, i will test this and post the results later, i gotta head to school, but that is an interesting suggestion i will definitely try that.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So I'm wondering is there a way to use the for statement in conjunction with a global number variable to set it so that, for every let's say 1000 points (or otherwise everytime 1000 points is added to score, or for every 1000 points added to score) go to next layout? I basically just want a level change that is based on accumulated score.

    like plinkie said if u want it to be each 1000 points then u can simply do that by having 2 variables 1 stage/level one being score

    and then u compare

    score = stage*1000 set stage to stage+1

    thats it.

    if u want a different limit for each stage then u need a extra variable to replace the 1000 value and then u have lets say pointstonextlevel

    Condition 1

    everytick

    set pointstonextlevel to stage*(pointstonextlevel*1.3) (that would give u a 130% increase for each level gained. or double the initial level score target +30 % of current score target so if initial score target is 1000 the next target is 2000 + 30% of 2000 that is total of 2600 next level target score. for level 2.)

    Separated condition from above one.

    score = stage*pointstonextlevel set stage to stage+1

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