How do I use Loop in game logic? (c2)

0 favourites
  • 5 posts
From the Asset Store
SynthWave Loop Pack includes 68 seamless loops, founded on 11 original melodies.
  • Hi Guys, Sorry it's me again.

    I understand basic loop logic, but how to apply this in construct.

    I have a variable LEVEL which starts at 1

    I have a player who collects coins and 1 enemy AI.

    I want to LOOP when player collects all coins.... so all coins respawn (which is fine).... but I want LEVEL to increment whilst adding another enemy on each level (harking it harder).

    Hope that makes sense.

    Thanks,

    Roberto

  • It's not really a loop. You just need to increment the LEVEL variable when some conditions are met (all coins collected, all enemies killed). And then you can start a new level, creating a number of new coins/enemies, which is based on the LEVEL value.

    So your code may look something like this:

    On start of layout
    	Repeat (LEVEL) times	: Create Enemy
    	Repeat (LEVEL*2) times	: Create Coin
    
    
    On Enemy destroyed
    if Enemy.count=1 // last enemy killed
    	Wait 1 second
    	Add 1 to LEVEL
    	Restart layout
    	
    
  • Thanks dop2000,

    That almost made sense.

    On Enemy destroyed

    if Enemy.count=1 // last enemy killed

    How does this bit interpret? I've tried a sub-event and I can't seem to find COUNT :(

    Sorry!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Oh! just tried:

    • On Enemy destroyed
    • Wait 1 second
    • Add 1 to LEVEL
    • Restart layout

    and it works great!

  • "if Enemy.count=1" checks is made using "System compare two values" condition.

    It checks if that destroyed enemy was the last remaining instance on the layout. If you only have one enemy on each level, then you don't need this check.

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