<commit_before>/*
 * MelonJS Game Engine
 * Copyright (C) 2011 - 2015, <NAME>, <NAME>, <NAME>
 * http://www.melonjs.org
 *
 */

me.ObservableVector2d = me.Vector2d.extend({
    /**
     * A Vector2d object that executes an onUpdate function. Use this over me.Vector2d when you need to know each time the vector is moved.
     * @class
     * @extends me.Vector2d
     * @constructor
     * @param {Number} [x=0] x value of the vector
     * @param {Number} [y=0] y value of the vector
     */
    init : function (x, y, settings) {
        /**
         * x value of the vector
         * @public
         * @type Number
         * @name x
         * @memberOf me.ObservableVector2d
         */
        Object.defineProperty(this, "x", {
            get : function () {
                return this._x;
            },

            set : function (value) {
                this.onUpdate(value, this._y, this._x, this._y);
                this._x = value;
            }
        });

        /**
         * y value of the vector
         * @public
         * @type Number
         * @name y
         * @memberOf me.ObservableVector2d
         */
        Object.defineProperty(this, "y", {
            get : function () {
                return this._y;
            },

            set : function (value) {
                this.onUpdate(this._x, value, this._x, this._y);
                this._y = value;
            }
        });

        this.onUpdate = settings.onUpdate;
        this._x = x;
        this._y = y;
    },

    /**
     * Add the passed vector to this vector
     * @name add
     * @memberOf me.ObservableVector2d
     * @function
     * @param {me.Vector2d} v
     * @return {me.ObservableVector2d} Reference to this object for method chaining
     */
    add : function (v) {
        var oldX = this._x;
        var oldY = this._y;
        this._x += v.x;
        this._y += v.y;
        this.onUpdate(this._x, oldX, this._y, oldY);
        return this;
    },

    /**
     * set the Vector x and y properties to the given values<br>
     * @name set
     * @memberOf me.ObservableVector2d
     * @function
     * @param {Number} x
     * @param {Number} y
     * @return {me.ObservableVector2d} Reference to this object for method chaining
     */
    set : function (x, y) {
        if (x !== +x || y !== +y) {
            throw new me.Vector2d.Error(
                "invalid x,y parameters (not a number)"
            );
        }

        var oldX = this._x;
        var oldY = this._y;
        this._x = x;
        this._y = y;
        this.onUpdate(this._x, oldX, this._y, oldY);

        return this;
    },

    /**
     * set the Vector x and y properties using the passed vector
     * @name setV
     * @memberOf me.ObservableVector2d
     * @function
     * @param {me.ObservableVector2d} v
     * @return {me.ObservableVector2d} Reference to this object for method chaining
     */
    setV : function (v) {
        return this.set(v.x, v.y);
    },

    /**
     * Substract the passed vector to this vector
     * @name sub
     * @memberOf me.ObservableVector2d
     * @function
     * @param {me.Vector2d} v
     * @return {me.ObservableVector2d} Reference to this object for method chaining
     */
    sub : function (v) {
        var oldX = this._x;
        var oldY = this._y;
        this._x -= v.x;
        this._y -= v.y;
        this.onUpdate(this._x, oldX, this._y, oldY);
        return this;
    }
});<commit_msg>[#668] Fix me.ObservableVector2d callback arguments<commit_after>/*
 * MelonJS Game Engine
 * Copyright (C) 2011 - 2015, <NAME>, <NAME>, <NAME>
 * http://www.melonjs.org
 *
 */

me.ObservableVector2d = me.Vector2d.extend({
    /**
     * A Vector2d object that executes an onUpdate function. Use this over me.Vector2d when you need to know each time the vector is moved.
     * @class
     * @extends me.Vector2d
     * @constructor
     * @param {Number} [x=0] x value of the vector
     * @param {Number} [y=0] y value of the vector
     */
    init : function (x, y, settings) {
        /**
         * x value of the vector
         * @public
         * @type Number
         * @name x
         * @memberOf me.ObservableVector2d
         */
        Object.defineProperty(this, "x", {
            get : function () {
                return this._x;
            },

            set : function (value) {
                this.onUpdate(value, this._y, this._x, this._y);
                this._x = value;
            }
        });

        /**
         * y value of the vector
         * @public
         * @type Number
         * @name y
         * @memberOf me.ObservableVector2d
         */
        Object.defineProperty(this, "y", {
            get : function () {
                return this._y;
            },

            set : function (value) {
                this.onUpdate(this._x, value, this._x, this._y);
                this._y = value;
            }
        });

        this.onUpdate = settings.onUpdate;
        this._x = x;
        this._y = y;
    },

    /**
     * Add the passed vector to this vector
     * @name add
     * @memberOf me.ObservableVector2d
     * @function
     * @param {me.Vector2d} v
     * @return {me.ObservableVector2d} Reference to this object for method chaining
     */
    add : function (v) {
        this.onUpdate(this._x + v.x, this._x + v.y, this._x, this._y);
        this._x += v.x;
        this._y += v.y;
        return this;
    },

    /**
     * set the Vector x and y properties to the given values<br>
     * @name set
     * @memberOf me.ObservableVector2d
     * @function
     * @param {Number} x
     * @param {Number} y
     * @return {me.ObservableVector2d} Reference to this object for method chaining
     */
    set : function (x, y) {
        if (x !== +x || y !== +y) {
            throw new me.Vector2d.Error(
                "invalid x,y parameters (not a number)"
            );
        }

        this.onUpdate(x, y, this._x, this._y);
        this._x = x;
        this._y = y;

        return this;
    },

    /**
     * set the Vector x and y properties using the passed vector
     * @name setV
     * @memberOf me.ObservableVector2d
     * @function
     * @param {me.ObservableVector2d} v
     * @return {me.ObservableVector2d} Reference to this object for method chaining
     */
    setV : function (v) {
        return this.set(v.x, v.y);
    },

    /**
     * Substract the passed vector to this vector
     * @name sub
     * @memberOf me.ObservableVector2d
     * @function
     * @param {me.Vector2d} v
     * @return {me.ObservableVector2d} Reference to this object for method chaining
     */
    sub : function (v) {
        this.onUpdate(this._x - v.x, this._x - v.y, this._x, this._y);
        this._x -= v.x;
        this._y -= v.y;
        return this;
    }
});
{'fraction_non_alphanumeric': 0.12089201877934272, 'fraction_numerical': 0.009096244131455399, 'mean_word_length': 1.5724528301886793, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4414488', 'n_tokens_mistral': 2174, 'n_tokens_neox': 2118, 'n_words': 604}