update(x, y) {
        // the player is trying to move off the right side of the screen
        if (this.x >= 402) {
            this.x = 402;
        }

        // the player is trying to move off the left side of the screen
        if (this.x <= -2) {
            this.x = -2;
        }

        // The player is trying to move off the bottom of the screen
        if (this.y > 404) {
            this.y = 404;
        }

        /** 
         * The player is trying to move off the top of the screen. When the
         * player reaches the top of the screen, they win the game. When the
         * game is won, the player's position is reset to their initial
         * position, all the enemies are stopped, and a message appears on the
         * screen announcing the victory.
         */
        if (this.y <= -11) {
            setTimeout(() => {
                // return the player to their initial position
                this.x = 200;
                this.y = 404;
                // stop all enemies
                for (const enemy of allEnemies) {
                    enemy.speed = 0;
                }
                // print the victory message on the screen
                this.victory = true;
                this.render();
            }, 100);
        }
    }
/**
     * @description Prevent the player from moving off the screen.
     * @param {number} x The horizontal position of the player
     * @param {number} y The vertical position of the player
     */
@description Prevent the player from moving off the screen.
@param {number} x The horizontal position of the player
@param {number} y The vertical position of the player
@description Prevent the player from moving off the screen . @param { number } x The horizontal position of the player @param { number } y The vertical position of the player
update(x, y) {
        if (this.x >= 402) {
            this.x = 402;
        }
        if (this.x <= -2) {
            this.x = -2;
        }
        if (this.y > 404) {
            this.y = 404;
        }
        if (this.y <= -11) {
            setTimeout(() => {
                this.x = 200;
                this.y = 404;
                for (const enemy of allEnemies) {
                    enemy.speed = 0;
                }
                this.victory = true;
                this.render();
            }, 100);
        }
    }
update ( x , y ) { if ( this . x >= 402 ) { this . x = 402 ; } if ( this . x <= - 2 ) { this . x = - 2 ; } if ( this . y > 404 ) { this . y = 404 ; } if ( this . y <= - 11 ) { setTimeout ( ( ) => { this . x = 200 ; this . y = 404 ; for ( const enemy of allEnemies ) { enemy . speed = 0 ; } this . victory = true ; this . render ( ) ; } , 100 ) ; } }
@description Prevent the player from moving off the screen.
@description Prevent the player from moving off the screen .
// the player is trying to move off the right side of the screen // the player is trying to move off the left side of the screen // The player is trying to move off the bottom of the screen /** 
         * The player is trying to move off the top of the screen. When the
         * player reaches the top of the screen, they win the game. When the
         * game is won, the player's position is reset to their initial
         * position, all the enemies are stopped, and a message appears on the
         * screen announcing the victory.
         */ // return the player to their initial position // stop all enemies // print the victory message on the screen