<commit_before>define(function (require, exports, module) {

	'use strict';

	// var $ = require('jquery');
	var _    = require('underscore');
	var buzz = require('buzz');

	var SimDraggable = require('views/sim-draggable');

	var html = require('text!templates/moving-man.html');

	require('less!styles/moving-man');

	/**
	 * Constants
	 */
	var MOVEMENT_STATE_IDLE  = 0;
	var MOVEMENT_STATE_LEFT  = 1;
	var MOVEMENT_STATE_RIGHT = 2;

	// These are from PhET and seem fairly arbitrary...
	var VELOCITY_SCALE     = 0.2;
	var ACCELERATION_SCALE = 0.8;

	var ARROW_HEAD_WIDTH = 15;

	/**
	 *
	 */
	var MovingManView = SimDraggable.extend({

		template: _.template(html),

		tagName: 'div',
		className: 'moving-man-view',

		events: {
			'mousedown'  : 'down',
			'touchstart' : 'down'
		},

		initialize: function(options) {
			SimDraggable.prototype.initialize.apply(this, [options]);

			this.simulation = options.simulation;
			this.movingMan  = this.simulation.movingMan;

			this.velocityVectorEnabled = false;
			this.velocityVectorVisible = false;

			this.accelerationVectorEnabled = false;
			this.accelerationVectorVisible = false;	

			this.crashSound = new buzz.sound('audio/phet/crash', {
				formats: ['ogg', 'mp3', 'wav']
			});

			this.listenTo(this.movingMan, 'collide', function(){
				this.crashSound.play();
			});
		},

		render: function() {
			this.renderMovingMan();
			this.bindDragEvents();
			this.resize();
			this.update(0, 0);
		},

		renderMovingMan: function() {
			this.$el.html(this.template());

			this.$velocityVector     = this.$('.arrow.velocity');
			this.$accelerationVector = this.$('.arrow.acceleration');
		},

		resize: function() {
			SimDraggable.prototype.resize.apply(this);

			this.pixelRatio = this.dragBounds.width / this.simulation.get('containerWidth');
		},

		down: function(event) {
			event.preventDefault();

			this.dragging = true;
			this.$el.addClass('dragging');

			// Start recording on drag if the simulation records and isn't currently
			if (!this.simulation.noRecording) {
				if (!this.simulation.get('recording'))
					this.simulation.record();
				if (this.simulation.get('paused'))
					this.simulation.play();
			}

			this.fixTouchEvents(event);

			this.dragX = event.pageX;
		},

		drag: function(event) {
			if (this.dragging) {

				this.fixTouchEvents(event);

				// Get position
				this._xPercent = (event.pageX - this.dragOffset.left) / this.dragBounds.width;
				this._xPosition = (this._xPercent * this.simulation.get('containerWidth')) - this.simulation.get('halfContainerWidth');

				this.movingMan.setMousePosition(this._xPosition);
				this.movingMan.positionDriven(true);

				// Get direction
				if ((event.pageX - this.dragX) > 0)
					this.movementState = MOVEMENT_STATE_RIGHT;
				else if ((event.pageX - this.dragX) < 0)
					this.movementState = MOVEMENT_STATE_LEFT;
				this.dragX = event.pageX;<commit_msg>Moving Man: specs compliance fix<commit_after>define(function (require, exports, module) {

	'use strict';

	// var $ = require('jquery');
	var _    = require('underscore');
	var buzz = require('buzz');

	var SimDraggable = require('views/sim-draggable');

	var html = require('text!templates/moving-man.html');

	require('less!styles/moving-man');

	/**
	 * Constants
	 */
	var MOVEMENT_STATE_IDLE  = 0;
	var MOVEMENT_STATE_LEFT  = 1;
	var MOVEMENT_STATE_RIGHT = 2;

	// These are from PhET and seem fairly arbitrary...
	var VELOCITY_SCALE     = 0.2;
	var ACCELERATION_SCALE = 0.8;

	var ARROW_HEAD_WIDTH = 15;

	/**
	 *
	 */
	var MovingManView = SimDraggable.extend({

		template: _.template(html),

		tagName: 'div',
		className: 'moving-man-view',

		events: {
			'mousedown'  : 'down',
			'touchstart' : 'down'
		},

		initialize: function(options) {
			SimDraggable.prototype.initialize.apply(this, [options]);

			this.simulation = options.simulation;
			this.movingMan  = this.simulation.movingMan;

			this.velocityVectorEnabled = false;
			this.velocityVectorVisible = false;

			this.accelerationVectorEnabled = false;
			this.accelerationVectorVisible = false;	

			this.crashSound = new buzz.sound('audio/phet/crash', {
				formats: ['ogg', 'mp3', 'wav']
			});

			this.listenTo(this.movingMan, 'collide', function(){
				this.crashSound.play();
			});
		},

		render: function() {
			this.renderMovingMan();
			this.bindDragEvents();
			this.resize();
			this.update(0, 0);
		},

		renderMovingMan: function() {
			this.$el.html(this.template());

			this.$velocityVector     = this.$('.arrow.velocity');
			this.$accelerationVector = this.$('.arrow.acceleration');
		},

		resize: function() {
			SimDraggable.prototype.resize.apply(this);

			this.pixelRatio = this.dragBounds.width / this.simulation.get('containerWidth');
		},

		down: function(event) {
			event.preventDefault();

			this.dragging = true;
			this.$el.addClass('dragging');

			// Start recording on drag if the simulation records and isn't currently
			if (!this.simulation.noRecording && !this.simulation.get('recording'))
				this.simulation.record();
			if (this.simulation.get('paused'))
				this.simulation.play();

			this.fixTouchEvents(event);

			this.dragX = event.pageX;
		},

		drag: function(event) {
			if (this.dragging) {

				this.fixTouchEvents(event);

				// Get position
				this._xPercent = (event.pageX - this.dragOffset.left) / this.dragBounds.width;
				this._xPosition = (this._xPercent * this.simulation.get('containerWidth')) - this.simulation.get('halfContainerWidth');

				this.movingMan.setMousePosition(this._xPosition);
				this.movingMan.positionDriven(true);

				// Get direction
				if ((event.pageX - this.dragX) > 0)
					this.movementState = MOVEMENT_STATE_RIGHT;
				else if ((event.pageX - this.dragX) < 0)
					this.movementState = MOVEMENT_STATE_LEFT;
				this.dragX = event.pageX;
{'fraction_non_alphanumeric': 0.15060965138244892, 'fraction_numerical': 0.004808517946075906, 'mean_word_length': 3.575019638648861, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2999999', 'n_tokens_mistral': 2327, 'n_tokens_neox': 1911, 'n_words': 342}