Adding a limit...?

Get help using Construct 2

Post » Mon Mar 23, 2015 8:36 pm

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
B
8
S
2
Posts: 146
Reputation: 1,132

Post » Mon Mar 23, 2015 10:00 pm

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

Code: Select all
(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

See the clamp expression on the System expressions manual page.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,126

Post » Tue Mar 24, 2015 12:51 am

Thank you I will have a go at it and get back to you.

Thanks :D:D
B
8
S
2
Posts: 146
Reputation: 1,132


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests