{"size": 1689, "ext": "js", "max_stars_repo_path": "js/laser.js", "max_stars_repo_name": "RevolutionMath/MelonJSExperiments", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "js/laser.js", "max_issues_repo_name": "RevolutionMath/MelonJSExperiments", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "js/laser.js", "max_forks_repo_name": "RevolutionMath/MelonJSExperiments", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.1206896552, "max_line_length": 92, "alphanum_fraction": 0.5127294257}
class Laser extends me.Entity {
    init(x, y) {
        this._super(me.Entity, 'init', [x, y, {
            width: game.Laser.width,
            height: game.Laser.height,
        }]);
        this.z = 5;
        this.body.setVelocity(0, 300);
        this.body.collisionType = me.collision.types.PROJECTILE_OBJECT;
        this.renderable = new(me.Renderable.extend({
            init() {
                const {
                    width,
                    height
                } = game.Laser;

                this._super(me.Renderable, 'init', [0, 0, width, height]);
            },
            onDestroyEvent() {},
            draw(renderer) {
                const color = renderer.getColor();

                renderer.setColor('#5EFF7E');
                renderer.fillRect(0, 0, this.width, this.height);
                renderer.setColor(color);
            }
        }));
        this.alwaysUpdate = true;
    }

    update(dt) {
        this.body.vel.y -= this.body.accel.y * dt / 1000;
        if (this.pos.y + this.height <= 0) {
            me.game.world.removeChild(this);
        }

        this.body.update();
        me.collision.check(this);

        return true;
    }

    onCollision(res, other) {
        if (other.body.collisionType === me.collision.types.ENEMY_OBJECT) {
            store.dispatch(actions.incrementScore());

            me.game.world.removeChild(this);

            game[`level${store.getState().level}`].scoreCard.score = store.getState().score;
            game[`level${store.getState().level}`].enemyManager.removeChild(other);
            return false;
        }
    }
}

game.Laser = Laser;
game.Laser.width = 5;
game.Laser.height = 28;