What am I doing wrong? Re: while loop

0 favourites
  • 5 posts
From the Asset Store
SynthWave Loop Pack includes 68 seamless loops, founded on 11 original melodies.
  • Keeps getting hung up. <img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad">

    capx: https://1drv.ms/u/s!AobC4q3rBlr6itBTdWySnTV6BE4Pmg

  • C2 is already a giant While loop, So you don't need while at all. get rid of it and add an Else to the event for the NOT case.

  • [quote:30229271]C2 is already a giant While loop, So you don't need while at all. get rid of it and add an Else to the event for the NOT case.

    What if this check is inside a triggered event? Then it isn't a part of the big C2 while loop.

    Example: When a triggered event happens such as a ship is destroyed by a laser, you want to spawn a new ship in a random spot, but you don't want it to overlap another existing ship. So you just do a while-loop to keep creating the ship until it's not in a spot that's overlapping.

  • That's different code though - not what have here. Presumably the condition would stop quickly and the While will exit. The test code doesn't meet this requirement.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Keeps getting hung up.

    You have NO code that makes the 'while' untrue.

    In general a 'while' is safe to use like this....

    Local Variable 'check' = 0

    Condition to check

    Action Set check to 1

    While

    check = 1

    ...Empty condition

    ...Action Make a change

    ...Condition to check

    ...Action set check to zero

    Or

    Local Variable 'check'. = 0

    If overlapping

    set check to 1

    While check = 1

    ...sub

    ...Action move the object

    ...Is NOT overlapping

    ...set check to 0

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