0 Favourites

Introduce powerups at certain intervals in game

  • Hi all,more help required if possible please.

    I am doing a basic shooting game and I have introduced a power up when the players score has reached a certain score for example when the player score has reached 100 a powerup will move onto the screen at a random position along the x axis and drop off the bottom of the screen. How can I achieve this again when the players score reaches another value , say 500 or something like that , and keep creating it as the score increases at different intervals.

    Thanks in advance.

  • You could use two separate variables. One for the score itself, and one that increases equally with the score and works as a counter.

    Actually follow the counter for the sake of the power up, and when the power up is spawned reset the counter variable to 0.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Do you want it to be a linear (i.e. every 100 points), exponential (i.e 100, 200, 400, 800 points, etc...) increase between power ups or do you want to use a list of values that you personally are picking arbitrary?

    The Mod operator is your friend here...That's the '%' symbol.

    Linear:

    System -> Compare Variable Score > 0

    System -> Compare Variable Score % 100 = 0

    -- System -> Trigger Once While True

    -- (Spawn your power up)

    Exponential is a little more tricky:

    Global Variable -> PowerUp = 1

    System -> Compare Value Score > 0

    System -> Compare Value Score %(PowerUp*100) = 0

    -- System -> Trigger Once While True

    -- System Add to PowerUp 1

    -- (Spawn your power up)

    And picking from a list is even more tricky if you aren't use to arrays.. You'll need an array object (we'll call it PowerUpArray):

    System -> On Layout Start

    --PowerUpArray Push Back 100 on X axis

    --PowerUpArray Push Back 300 on X axis

    --PowerUpArray Push Back 900 on X axis

    --(Repeat until all are in the array

    PowerUpArray -> Contains Score

    -- System -> Trigger Once While True

    -- (Spawn your power up)

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