How do I pick a different group to activate each round

0 favourites
  • 5 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • Ok this is something probably super simple but for whatever reason i can't wrap my head around what's going on

    I'm trying to pick a different group to activate each time the game loop starts over again. It works once, then starts going super duper fast ignoring the "wait" command in each group.

    Is there a better way that i can setup a system that will pick a different group to enable , then when that group code is complete it disables itself, and next tick it will pick a different one?

    plz see attached capx and screen shot

    https://dl.dropboxusercontent.com/u/403350/groupBug.capx

  • Hi justifun,

    The "wait" thing is a pain, if you're not careful

    Your code now works like this:

    Tick 1:

    choose randomly (e.g. group 1)

    activate g1

    start waiting - but only for the code in group 1

    Tick 2: (group 1 already active)

    choose randomly (e.g. group 2)

    start waiting - but only for group 2 code

    Tick 3: (groups 1 and 2 already active0

    choose randomly .... etc

    Can you see the pattern? wait does not stop the initial [section 1] code to be re-executed every tick!

    What you can do is e.g. add a global var "isAnyGroupActive = 0"

    Set it to 1 before "wait"

    set it to 0 after "wait"

    In section 1 add:

    execute only if "isAnyGroupActive = 0"

  • I still dont quite understand how this is working.

    Here's a version of what i posted that DOES work as desired.

    If i modify disable either of the "Set IsAnyGroupActive to 0" then it all breaks

    In my head here's how i think its working.

    The game starts off picking a random wave value (1 2 or 3)

    eg: 1

    Event 4 checks if wave = 1 AND if isAnyGroupActive is 0 and starts processing those actions

    We now set isAnyGroupActive to 1 so that it wont process wave 1 the time it loops through the event sheet again (and theoretically stay processing whatever is going on in wave 1

    but then we have it setting isAnyGroupActive immediately to zero again

    so im confused.

    they way i thought it should be setup was that you would only need to change isAnyGroupActive to 1 once. Then the logic would stay processing in wave 1 until you changed it back to zero at a later point (perhaps after a keypress or something)

    But how / why does making it a value of 1 then 0 immediately make this work?

    thx CJK

  • Hi justifun,

    But how / why does making it a value of 1 then 0 immediately make this work?

    It certainly does not- impossible, because the change 1 to 0 is done in the same tick. Must be something else, but I admit I do not understand this bit of code fully.

    Some ideas (or more my questions to your screenshot): why wave1 code differs from code for waves2 and 3? Why do you call "Next" once from a sub-event, and in waves2 and 3 from the same event as "wait"? This will result in a different behaviour, when you add "wait" to wave1 - "wait" will apply only to current sub-event.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • CJK - the overall idea was that i wanted to have different "waves" in the game, imagine space invaders.

    there would be an overall function or something else that would enable/disable which wave was active, so that i could either have a predetermined order of the incoming waves, or the option to do something like "activate wave (random 1,3)"

    so if there's a better way of doing it i'm all ears.

    Wave 2 and 3 are the same simply because i didnt fill out any more details of which monsters would be spawned in there etc. for the purpose of my question.

    But imagine this.....

    Wave 1 - Monsters spawn, wait a few seconds, then start playing some music, then when a few of them are killed a different type of monsters are spawned etc. and then perhaps after 100 are killed total WAVE 1 is disabled and WAVE 2 is enabled and executing a new series of spawns/music/etc etc

    Is there a simpler way to approach a wave after wave system like this?

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