Adding a limit...?

  • I've created a game where 2 sets of enemies will be coming towards the player at random spawning times.

    I wanted there spawning time to increase over time to increase the difficulty of the game, so i added a Global Variable called 'SpawnTime'.

    The 'SpawnTime' will subtract from the enemy spawning rate. However i need to create a limit so that it doesnt subtract forever.

    I'll try and explain my even page below.....

    (1) every x seconds | random(5-SpawnTime, 8-SpawnTime) | Create Object | enemy1

    (2) every x seconds | random(1-SpawnTime, 3-SpawnTime) | Create Object | enemy2

    (3) every x seconds | 5 Seconds | Add 1 to SpawnTime

    So i basically need to stop the SpawnTime from constantly subtracting from the enemy spawn rate otherwise once the spawn rate reaches 0 then a loooooooads of enemies are just spawned all at once

  • Either stop incrementing spawn time when it reaches a certain value, or clamp your random() expressions in events 1 and 2, as follows:

    (1) every x seconds | clamp(random(5-SpawnTime, 8-SpawnTime), 1, 8) | Create Object | enemy1
    
    (2) every x seconds | clamp(random(1-SpawnTime, 3-SpawnTime), 1, 3) | Create Object | enemy2[/code:3b12fxkd]
    See the clamp expression on the [url=https://www.scirra.com/manual/126/system-expressions]System expressions manual page[/url].
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you I will have a go at it and get back to you.

    Thanks :D

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