<commit_before>//= require ../view

(function () {
  'use strict';

  var app = window.app;

  var _ = window._;
  var PIXI = window.PIXI;
  var requestAnimFrame = window.requestAnimFrame;

  app.GamesShowView = app.View.extend({
    width: app.config.game.width,

    height: app.config.game.height,

    listeners: {
      users: {add: 'addCharacter', 'remove change:isDead': 'removeCharacter'}
    },

    initialize: function () {
      this.stage = new PIXI.Stage(0xffffff);
      this.renderer = new PIXI.autoDetectRenderer(this.width, this.height);
      this.characters = new app.Character.Collection();
      this.container = new PIXI.DisplayObjectContainer();
      this.container.addChild(this.layer1 = new PIXI.DisplayObjectContainer());
      this.container.addChild(this.layer2 = new PIXI.DisplayObjectContainer());
      this.container.position.x = this.width / 2;
      this.container.position.y = this.height - 100;
      this.stage.addChild(this.container);
      this.$el.append(this.renderer.view);
      this.users = this.model.get('users');
      var line = new PIXI.Graphics();
      line.lineStyle(2, 0xFF0000);
      line.moveTo(-(this.width / 2), 0);
      line.lineTo(this.width / 2, 0);
      this.layer1.addChild(line);
      this.createSawblades();
      _.bindAll(this, 'render');
      this.render();
    },

    render: function () {
      this.renderer.render(this.stage);
      requestAnimFrame(this.render);
    },

    createSawblades: function () {
      var sawBlades = _.flatten(_.map([-1, 1], function (dir) {
        return _.times(30, function (y) {
          var sawBlade = new PIXI.Sprite(PIXI.TextureCache['saw-blade.png']);
          sawBlade.anchor.x = sawBlade.anchor.y = 0.5;
          sawBlade.position.x = dir * (app.config.game.width / 2);
          sawBlade.position.y = -((0.5 + y) * (sawBlade.height / 2));
          sawBlade.scale.x = dir;
          this.layer2.addChildAt(
            sawBlade,
            _.random(this.layer2.children.length)
          );
          return sawBlade;
        }, this);
      }, this));
      this.listenTo(this.model, 'step', function (dt) {
        _.each(sawBlades, function (sawBlade) {
          sawBlade.rotation += sawBlade.scale.x * Math.PI * 10 * dt;
        });
      });
    },

    addCharacter: function (user) {
      var character = new app.Character({user: user});
      this.characters.add(character);
      this.layer2.addChild(character.get('sprite'));
    },

    removeCharacter: function (user) {
      var character = this.characters.findWhere({user: user});
      if (!character) return;
      var sprite = character.get('sprite');<commit_msg>Give sawblades a random starting rotation<commit_after>//= require ../view

(function () {
  'use strict';

  var app = window.app;

  var _ = window._;
  var PIXI = window.PIXI;
  var requestAnimFrame = window.requestAnimFrame;

  app.GamesShowView = app.View.extend({
    width: app.config.game.width,

    height: app.config.game.height,

    listeners: {
      users: {add: 'addCharacter', 'remove change:isDead': 'removeCharacter'}
    },

    initialize: function () {
      this.stage = new PIXI.Stage(0xffffff);
      this.renderer = new PIXI.autoDetectRenderer(this.width, this.height);
      this.characters = new app.Character.Collection();
      this.container = new PIXI.DisplayObjectContainer();
      this.container.addChild(this.layer1 = new PIXI.DisplayObjectContainer());
      this.container.addChild(this.layer2 = new PIXI.DisplayObjectContainer());
      this.container.position.x = this.width / 2;
      this.container.position.y = this.height - 100;
      this.stage.addChild(this.container);
      this.$el.append(this.renderer.view);
      this.users = this.model.get('users');
      var line = new PIXI.Graphics();
      line.lineStyle(2, 0xFF0000);
      line.moveTo(-(this.width / 2), 0);
      line.lineTo(this.width / 2, 0);
      this.layer1.addChild(line);
      this.createSawblades();
      _.bindAll(this, 'render');
      this.render();
    },

    render: function () {
      this.renderer.render(this.stage);
      requestAnimFrame(this.render);
    },

    createSawblades: function () {
      var sawBlades = _.flatten(_.map([-1, 1], function (dir) {
        return _.times(30, function (y) {
          var sawBlade = new PIXI.Sprite(PIXI.TextureCache['saw-blade.png']);
          sawBlade.anchor.x = sawBlade.anchor.y = 0.5;
          sawBlade.position.x = dir * (app.config.game.width / 2);
          sawBlade.position.y = -((0.5 + y) * (sawBlade.height / 2));
          sawBlade.scale.x = dir;
          sawBlade.rotation = Math.PI * 2 * Math.random();
          this.layer2.addChildAt(
            sawBlade,
            _.random(this.layer2.children.length)
          );
          return sawBlade;
        }, this);
      }, this));
      this.listenTo(this.model, 'step', function (dt) {
        _.each(sawBlades, function (sawBlade) {
          sawBlade.rotation += sawBlade.scale.x * Math.PI * 10 * dt;
        });
      });
    },

    addCharacter: function (user) {
      var character = new app.Character({user: user});
      this.characters.add(character);
      this.layer2.addChild(character.get('sprite'));
    },

    removeCharacter: function (user) {
      var character = this.characters.findWhere({user: user});
      if (!character) return;
      var sprite = character.get('sprite');
{'fraction_non_alphanumeric': 0.1489913011290024, 'fraction_numerical': 0.012400518230612622, 'mean_word_length': 2.5228161668839637, 'pattern_counts': {'":': 0, '<': 3, '<?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': '742666', 'n_tokens_mistral': 1788, 'n_tokens_neox': 1719, 'n_words': 316}