[SOLVED] Help with Power Up Multiplier

So I am trying to make so power-ups for my game(Ex Double Points or Damage).
Right now I am trying to make double points but I just haven’t had a great time with that.
I have tried a lot of stuff but just couldn’t get it to work.
The way it is coded is when this entity health is at 0 it will kill the enemy, add the points but it needs to multiply the points and add them only when the power-up has been collected.

    if(this.entity.tags.has('hex_Ps'))
{
//causes double points 
}

This is the kill and add points code on the enemy

Target.prototype.update = function(dt)
{


    if( this.currentHealth <= 0)
    {
     this.entity.destroy();
    this.player.script.points.addPoints(this.points);    

    } 
    
    
    var player = this.app.root.findByName('player').getPosition();
    
    
};

Plz help I am stumped…

sorry if my grammer is bad

Hi @Connor_Briggs! So if I understand you correctly you want to apply the points to the player script and multiply these points if the power-ups of the player has a certain value?

no sir i just want to multiply the points only when an enemy is killed and the powerup has been collected

the target script is on the enemy.When the enemy health is 0 it will add the points but i need it to be double the points only when the power up has been collected

In the example below I first add the normal points when the enemy dies. Then I check the the player script if enough power ups are collected. If that is the case I give the player again these points.

    // check enemy health
    if( this.currentHealth <= 0) {
        // add player points
        this.player.script.points.addPoints(this.points);

        // check if the player has enough power ups
        if (this.player.script.yourScript.powerUps >= 10) {
            // update the power ups becaucse they are used
            this.player.script.yourScript.powerUps -= 10;
            // add extra player points
            this.player.script.points.addPoints(this.points);
        }

        // destroy enemy
        this.entity.destroy();
    }

This is just an example, so you have to modify it yourself.

thank you so much. i’ll try that and see if it works.

thank you so much i got it to work

1 Like