<commit_before>/* global goog, lime, obacht */
/* jshint strict: false, devel:true */

goog.provide('obacht.Collision');
goog.require('obacht.themes');
//goog.require('obacht.Game');

/**
 * Collision Detector
 *
 * @constructor
 */
obacht.Collision = function (player, trap) {
    "use strict";
    this.object1pos = player.character.getPosition();
    this.object2pos = trap.character.getPosition();

    /*Size Object1*/
    this.obj1w = player.character.getSize().width;
    this.obj1h = player.character.getSize().height;

    /*Left Top Corner Player*/
    this.obj1x = Math.round(this.object1pos.x / 10) * 10 - (this.obj1w / 2);
    this.obj1y = Math.round(this.object1pos.y / 10) * 10 - (this.obj1h / 2);

    /*Size Object2*/
    this.obj2w = trap.character.getSize().width;
    this.obj2h = trap.character.getSize().height;

    /*Left Top Corner Trap*/
    this.obj2x = Math.round(this.object2pos.x / 10) * 10 - (this.obj2w / 2);
    this.obj2y = Math.round(this.object2pos.y / 10) * 10 - (this.obj2h / 2);

    /*Request BoundingBoxes | Name = BoundingBoxes Object 2*/
    this.bbobj1 = player.boundingBoxes;
    this.bbobj2 = trap.boundingBoxes;

    var i = 0;
    while (i < trap.boundingBoxes.length) {

        //New Calculation Bounding Boxes
        this.obj2x = this.obj2x - this.bbobj2[i].x;
        this.obj2y = this.obj2y + this.bbobj2[i].y;

        //New Size like Bounding Boxes
        this.obj2w = this.bbobj2[i].width;
        this.obj2h = this.bbobj2[i].height;

        console.log(i);
        i = i + 1;
    }
};

obacht.Collision.prototype = {

    rect: function () {
        "use strict";

        return this.obj1x < this.obj2x + this.obj2w  &&
            this.obj2x < this.obj1x + this.obj1w  &&
            this.obj1y < this.obj2y + this.obj2h &&
            this.obj2y < this.obj1y + this.obj1h;

    }
};<commit_msg>Bugfix  Collision.js (Still without crouch)<commit_after>/* global goog, lime, obacht */
/* jshint strict: false, devel:true */

goog.provide('obacht.Collision');
goog.require('obacht.themes');
//goog.require('obacht.Game');

/**
 * Collision Detector
 *
 * @constructor
 */
obacht.Collision = function (player, trap) {
    "use strict";
    this.object1pos = player.character.getPosition();
    this.object2pos = trap.character.getPosition();

    /*Size Object1*/
    this.obj1w = player.character.getSize().width;
    this.obj1h = player.character.getSize().height;

    /*Left Top Corner Player*/
    this.obj1x = Math.round(this.object1pos.x / 10) * 10 - (this.obj1w / 2);
    this.obj1y = Math.round(this.object1pos.y / 10) * 10 - (this.obj1h / 2);

    /*Size Object2*/
    this.obj2w = trap.character.getSize().width;
    this.obj2h = trap.character.getSize().height;

    /*Left Top Corner Trap*/
    this.obj2x = Math.round(this.object2pos.x / 10) * 10 - (this.obj2w / 2);
    this.obj2y = Math.round(this.object2pos.y / 10) * 10 - (this.obj2h / 2);

    /*Request BoundingBoxes | Name = BoundingBoxes Object 2*/
    this.bbobj1 = player.boundingBoxes;
    this.bbobj2 = trap.boundingBoxes;

    var state = false;
    var i = 0;
    while (i < trap.boundingBoxes.length) {

        //New Player i==0
        this.obj1x = this.obj1x - this.bbobj1[0].x;
        this.obj1y = this.obj1y + this.bbobj1[0].y;

        this.obj1w = this.bbobj1[0].width;
        this.obj1h = this.bbobj1[0].height;

        //New Trap
        this.obj2x = this.obj2x - this.bbobj2[i].x;
        this.obj2y = this.obj2y + this.bbobj2[i].y;

        this.obj2w = this.bbobj2[i].width;
        this.obj2h = this.bbobj2[i].height;

        if (this.obj1x < this.obj2x + this.obj2w  &&
            this.obj2x < this.obj1x + this.obj1w  &&
            this.obj1y < this.obj2y + this.obj2h &&
            this.obj2y < this.obj1y + this.obj1h === true){
        state=true;
        }

        //console.log(i);
        i = i + 1;
    }
};

obacht.Collision.prototype = {

    rect: function () {
        "use strict";
        return this.state;

    }
};
{'fraction_non_alphanumeric': 0.15710348283638187, 'fraction_numerical': 0.03733400150338261, 'mean_word_length': 2.3405857740585776, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '742661', 'n_tokens_mistral': 1564, 'n_tokens_neox': 1464, 'n_words': 269}