update(dt) {
        // Multiply enemies movements by the dt parameter to ensure the game runs
        // at the same speed for all computers
        this.x += this.speed * dt;
        // Reset enemies positions and assign a random speed after every reset
        if (this.x > 5 * 101){
            this.x = -101;
            this.speed = this.getRandomInt(300, 400);
        }

        // If player collides with the enemies, reset the player to original position and decrement lives
        if ((Math.abs(this.x - player.x) < 101) && Math.abs(this.y - player.y) < 70) {
            player.reset();
            gamePanel.decrementLives();
        }
    }
// Parameter: dt, a time delta between ticks
dt, a time delta between ticks
dt a time delta between ticks
update(dt) {
        this.x += this.speed * dt;
        if (this.x > 5 * 101){
            this.x = -101;
            this.speed = this.getRandomInt(300, 400);
        }
        if ((Math.abs(this.x - player.x) < 101) && Math.abs(this.y - player.y) < 70) {
            player.reset();
            gamePanel.decrementLives();
        }
    }
update ( dt ) { this . x += this . speed * dt ; if ( this . x > 5 * 101 ) { this . x = - 101 ; this . speed = this . getRandomInt ( 300 , 400 ) ; } if ( ( Math . abs ( this . x - player . x ) < 101 ) && Math . abs ( this . y - player . y ) < 70 ) { player . reset ( ) ; gamePanel . decrementLives ( ) ; } }
Parameter: dt, a time delta between ticks
Parameter : dt a time delta between ticks
// Multiply enemies movements by the dt parameter to ensure the game runs // at the same speed for all computers // Reset enemies positions and assign a random speed after every reset // If player collides with the enemies, reset the player to original position and decrement lives