How do I spawn enemies faster?

0 favourites
  • 5 posts
From the Asset Store
Pixel Enemies for SHMUP consists of 45 enemy ship sprites to be used in your game.
  • Hey Devs,

    I am having troubles increasing the spawn rate of my game.

    What I need to do is increase the spawn rate when score reaches 5. Not only does the spawn rate need to increase when the score is 5 but it needs to continuously increase every 5 score.

    I have attached an image with my current setup. Any ideas? Thanks! [/attachment:jf7td12x]

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here's how I would do it. Seems to work. Attached is the image for the setup.

    Basically the setup is this. Create a variable to hold the SpawnRate. This is the rate your enemies will generate and is based on your needs. 100 per minute or whatever. Whenever your score changes (event #3 in the image) you set a variable named SpawnRateModifier to your Score % 5 (using the modulus operator). This will return 0 if your score is divisible by 5 (so 5, 10, 15, 20, etc.). You also set a value called CheckSpawnModifier to 1 (more on this below).

    Then every tick (event #2 in the image) check two conditions: Is SpawnRateModifier == 0 (in other words, is the score divisible by 5) *and* is CheckSpawnModifier == 1. If it is then you do two actions. First, change CheckSpawnModifier to 0. We do this because we're doing this check every tick. If we didn't set this value and check it on every tick, the second action would keep firing the entire time until the score changed. Then for the second action we add 10 to the SpawnRate.

    So running this, after a few seconds when the score hits 5, the spawn rate is increased to 110 and stays there until the score reaches 10 at which point the SpawnRate is 120.

    Obviously you won't be changing the score every 2 seconds like I did in the demo so it's best to have a function that you call to modify the score and setup these variables at the same time. You can also create variables for SpawnIncrease (instead of a hard coded value) and add that to the SpawnRate.

    Hope that helps.

    Enjoy!

  • create 2 more global variables named stage, counter as numbers

    Event:

    on collision with Ball

    Action:

    Add 1 to Score

    Add 1 to Counter

    Event:

    Counter greater or equal 5

    Action:

    set Counter =0

    Add 1 to Stage

  • Make a var (something like difficulty) and set 1.

    then, create a repeat loop in the same event of the spawn and set the 'count' to the difficulty variable.

    you just have to increase the variable every time you want more enemies.

    I think this will work.

  • Here's how I would do it. Seems to work. Attached is the image for the setup.

    Basically the setup is this. Create a variable to hold the SpawnRate. This is the rate your enemies will generate and is based on your needs. 100 per minute or whatever. Whenever your score changes (event #3 in the image) you set a variable named SpawnRateModifier to your Score % 5 (using the modulus operator). This will return 0 if your score is divisible by 5 (so 5, 10, 15, 20, etc.). You also set a value called CheckSpawnModifier to 1 (more on this below).

    Then every tick (event #2 in the image) check two conditions: Is SpawnRateModifier == 0 (in other words, is the score divisible by 5) *and* is CheckSpawnModifier == 1. If it is then you do two actions. First, change CheckSpawnModifier to 0. We do this because we're doing this check every tick. If we didn't set this value and check it on every tick, the second action would keep firing the entire time until the score changed. Then for the second action we add 10 to the SpawnRate.

    So running this, after a few seconds when the score hits 5, the spawn rate is increased to 110 and stays there until the score reaches 10 at which point the SpawnRate is 120.

    Obviously you won't be changing the score every 2 seconds like I did in the demo so it's best to have a function that you call to modify the score and setup these variables at the same time. You can also create variables for SpawnIncrease (instead of a hard coded value) and add that to the SpawnRate.

    Hope that helps.

    Enjoy!

    Very good code!

    That works well but I still need the system event timer to go from 3.5 down to 3.4, 3.3, 3.2...etc every 5 score.

    any ideas?

    I will attach the .capx file

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