<commit_before>// defines your module and loads any dependencies
define([
	'stage'
], function(Stage) {

	console.log("unit.js loaded");
	/*
		Create Object and Constructor
		https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create
	 */
	function Unit(startX,startY,spriteSrc){
			//console.log("Unit Constructor is called");	//debug: did all the constructors call correctly?
			
			/*
				Initialion - all variable/funciton must have "this." before
				Use "var" to change the variable/funciton become private 
	  			"x || 0" just means "if there is a value for x, use that. Otherwise use 0."
			 */
			this.x = startX || 0;
			this.y = startY || 0;
			// prepare sprite
			this.sprite = new Image();
			this.sprite.src = spriteSrc;
			this.spriteOrigin = {x:0,y:0};
			this.spriteReady=false;

			// update sprite origin according to sprite size
			var that = this;
			this.sprite.onload = function(){
				that.spriteOrigin = {x:that.sprite.width/2, y:that.sprite.height/2};
				that.spriteReady=true;
			};
	};

	// tick event handler
	Unit.prototype.tick = function(dt){
		// empty
	};

	Unit.prototype.render = function(ctx){
		if(this.spriteReady){
			//draw image
			var drawX = this.x - this.spriteOrigin.x;
			var drawY = this.y - this.spriteOrigin.y;
			ctx.drawImage(this.sprite,drawX,drawY);
		}

	};
	/**
	 * remove the unit, without death effect
	 */
	Unit.prototype.remove = function(){
		// to be overridden
	}
	/**
	 * Check if at least part of the unit is within the canvas
	 * @return {Boolean} Whether it is within the canvas
	 */<commit_msg>Add radius in Unit Class (default is the half size of width)<commit_after>// defines your module and loads any dependencies
define([
	'stage'
], function(Stage) {

	console.log("unit.js loaded");
	/*
		Create Object and Constructor
		https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create
	 */
	function Unit(startX,startY,spriteSrc){
			//console.log("Unit Constructor is called");	//debug: did all the constructors call correctly?
			
			/*
				Initialion - all variable/funciton must have "this." before
				Use "var" to change the variable/funciton become private 
	  			"x || 0" just means "if there is a value for x, use that. Otherwise use 0."
			 */
			this.x = startX || 0;
			this.y = startY || 0;
			// prepare sprite
			this.sprite = new Image();
			this.sprite.src = spriteSrc;
			this.spriteOrigin = {x:0,y:0};
			this.spriteReady=false;
			this.radius = 0;
			// update sprite origin according to sprite size
			var that = this;
			this.sprite.onload = function(){
				that.spriteOrigin = {x:that.sprite.width/2, y:that.sprite.height/2};
				that.spriteReady=true;
				that.radius = that.sprite.width/2;
			};
	};

	// tick event handler
	Unit.prototype.tick = function(dt){
		// empty
	};

	Unit.prototype.render = function(ctx){
		if(this.spriteReady){
			//draw image
			var drawX = this.x - this.spriteOrigin.x;
			var drawY = this.y - this.spriteOrigin.y;
			ctx.drawImage(this.sprite,drawX,drawY);
		}

	};
	/**
	 * remove the unit, without death effect
	 */
	Unit.prototype.remove = function(){
		// to be overridden
	}
	/**
	 * Check if at least part of the unit is within the canvas
	 * @return {Boolean} Whether it is within the canvas
	 */
{'fraction_non_alphanumeric': 0.13161875945537066, 'fraction_numerical': 0.005446293494704993, 'mean_word_length': 3.046511627906977, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '2174829', 'n_tokens_mistral': 1248, 'n_tokens_neox': 1071, 'n_words': 305}