update(dt) {

        // Multiplies the speed by the dt parameter on the x axis
        this.x += this.speed * dt;

        // Once enemies reach the end of screen they appear again with different velocities
        if (this.x > 500) {
            this.x = -50;
            this.speed = 100 + Math.floor(Math.random() * 300);
        }

        // Reset player position on collision
        if (player.x < this.x + 80 &&
            player.x + 80 > this.x &&
            player.y < this.y + 60 &&
            60 + player.y > this.y) {
            openModal(true);
            player.x = 202;
            player.y = 405;
        }
    }
/**
     * This method updates the enemy position continuously with variable speeds
     * Also checks for collision to reset the player position
     * @param dt
     */
This method updates the enemy position continuously with variable speeds
Also checks for collision to reset the player position
@param dt
This method updates the enemy position continuously with variable speeds Also checks for collision to reset the player position @param dt
update(dt) {
        this.x += this.speed * dt;
        if (this.x > 500) {
            this.x = -50;
            this.speed = 100 + Math.floor(Math.random() * 300);
        }
        if (player.x < this.x + 80 &&
            player.x + 80 > this.x &&
            player.y < this.y + 60 &&
            60 + player.y > this.y) {
            openModal(true);
            player.x = 202;
            player.y = 405;
        }
    }
update ( dt ) { this . x += this . speed * dt ; if ( this . x > 500 ) { this . x = - 50 ; this . speed = 100 + Math . floor ( Math . random ( ) * 300 ) ; } if ( player . x < this . x + 80 && player . x + 80 > this . x && player . y < this . y + 60 && 60 + player . y > this . y ) { openModal ( true ) ; player . x = 202 ; player . y = 405 ; } }
This method updates the enemy position continuously with variable speeds
 Also checks for collision to reset the player position
 @param dt
This method updates the enemy position continuously with variable speeds Also checks for collision to reset the player position @param dt
// Multiplies the speed by the dt parameter on the x axis // Once enemies reach the end of screen they appear again with different velocities // Reset player position on collision