<commit_before>var GameState = function(game) {
}

GameState.prototype.updateClock = function()
{
    this.clock.setSeconds(this.clock.getSeconds() + 1);
    if ( this.clock.getSeconds() == 59)
	player.score += SCORE_PERSECOND;
    this.clock.setMilliseconds(0);
}

GameState.prototype.create = function()
{
    this.map = this.add.tilemap('map');
    for (var k in moonlightSettings['map']['tilesets']) {
	var ts = moonlightSettings['map']['tilesets'][k];
	this.map.addTilesetImage(ts['name']);
    }
    this.map_collision_layers = [];
    pfgrid = [];

    for (var ln in moonlightSettings['map']['layers']) {
	lp = moonlightSettings['map']['layers'][ln];
	if ( lp['type'] == "tiles" ) {
	    layer = this.map.createLayer(ln);	    
	    this.map.setCollisionBetween(
		lp['collisionBetween'][0],
		lp['collisionBetween'][1],
		lp['collides'],
		ln
	    );
	    if ( lp['inject_sprites'] == true ) {
		this.aiSprites = game.add.group();
		this.aiSprites.debug = true;
		this.map.createFromObjects('AI', 3544, 'player', 0, true, false, this.aiSprites, AISprite);
		this.aiSprites.forEach(function(spr) {
		    spr.update_new_values();
		}, this)
		player = this.add.sprite((19 * 32), (21 * 32), 'player');
		player.score = 0;
		player.lightmeter = 0;

	    };
	    if ( lp['collides'] == true ) {
		this.map_collision_layers.push(layer);
		for (var i = 0; i < layer.layer.data.length; i++)
		{
		    if ( i >= pfgrid.length )
			pfgrid[i] = [];
		    for (var j = 0; j < layer.layer.data[i].length; j++)
		    {
			if (layer.layer.data[i][j].index > 0) {
			    pfgrid[i][j] = 1;
			} else if ( pfgrid[i][j] != 1 ) {
			    pfgrid[i][j] = 0;
			}
		    }
		}
	    }
	    layer.resizeWorld();
	}
    }

    pathfinder_grid = new PF.Grid(this.map.width,
				  this.map.height,
				  pfgrid);
    pathfinder = new PF.AStarFinder({allowDiagonal: false});
    
    this.physics.arcade.enable(player);
    player.body.setSize(16, 16, 8, 16);
    player.body.center = new Phaser.Point(player.body.width / 2, player.body.height + player.body.halfHeight);
    player.body.collideWorldBounds = true;
    //player.body.immovable = true;

    addAnimation(player, 'bipedwalkleft');
    addAnimation(player, 'bipedwalkright');
    addAnimation(player, 'bipedwalkup');
    addAnimation(player, 'bipedwalkdown');
    addAnimation(player, 'bipedrunleft');
    addAnimation(player, 'bipedrunright');
    addAnimation(player, 'bipedrunup');
    addAnimation(player, 'bipedrundown');

    this.camera.follow(player, Phaser.Camera.FOLLOW_TOPDOWN);
    controls = game.input.keyboard.createCursorKeys();
    controls.steal = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);

    this.effectSprites = game.add.group();
    this.map.createFromObjects('EffectSprites', 5, 'player', 0, true, false, this.effectSprites, EffectSprite);
    this.effectSprites.forEach(function(spr) {
	spr.update_new_values();
    }, this)

    this.shadowTexture = game.add.bitmapData(game.world.width, game.world.height);
    // drop this lower to make the map darker
    this.shadowTextureColor = [20, 20, 20];
    this.shadowSprite = game.add.image(0, 0, this.shadowTexture);

    this.shadowSprite.blendMode = Phaser.blendModes.MULTIPLY;

    this.staticLights = game.add.group();
    this.map.createFromObjects('Lights', 97, 'player', 0, true, false, this.staticLights, Light);
    this.staticLights.forEach(function(light) {
	light.update_new_values();
    }, this)

    this.aiSpriteEffects = game.add.group();
			     
    this.staticSounds = game.add.group();
    this.map.createFromObjects('Sounds', 11, 'player', 0, true, false, this.staticSounds, SoundSprite);
    this.staticSounds.forEach(function(snd) {
	snd.update_new_values();
    }, this)

    this.bubble_group = game.add.group();

    this.uigroup = game.add.group();
    this.recentlyStolenGroup = game.add.group();
    this.game.time.advancedTiming = true;

    this.clock = new Date();
    this.clock.setHours(20, 00, 0, 0);
    this.clockTimer = game.time.create(true);
    this.clockTimer.repeat(DAYLIGHT_TIMER_REPEAT, 
			   DAYLIGHT_TIMER_REPEATCOUNT,
			   this.updateClock,
			   this);
    this.clockTimer.start();

    game.camera.deadzone.height -= 68;

    var hudoffset = game.camera.height - 68;
    this.hud = this.game.add.image(0, hudoffset, 'hud', 0, this.uigroup);
    this.hud_hourhand = this.game.add.sprite(39, 
					     hudoffset + 36, 
					     'clock_hourhand', 
					     0, 
					     this.uigroup);
    this.hud_hourhand.anchor.setTo(0.5, 0.5);
    this.hud_minutehand = this.game.add.sprite(39, 
					       hudoffset + 36, 
					       'clock_minutehand', 
					       0, 
					       this.uigroup);
    this.hud_minutehand.anchor.setTo(0.5, 0.5);
    this.hud_clockoverlay = this.game.add.image(39, 
						hudoffset + 36, 
						'clock_overlay', 
						0, 
						this.uigroup);
    this.hud_clockoverlay.anchor.setTo(0.5, 0.5);
    
    // this.clockText = this.game.add.text(
    // 	20, SCREEN_HEIGHT - 40, '', { font : '16px Arial', fill: '#ffffff' }, this.uigroup
    // );

    this.scoreText = this.game.add.text(
        SCREEN_WIDTH - 80, SCREEN_HEIGHT - 30, '', 
	{ font: '16px Arial', fill: '#ffffff' }, this.uigroup
    );

    this.lightbar = this.game.add.sprite(255,
    					hudoffset + 7 + 6,
    					'lightbar',
    					0,
    					this.uigroup);
    this.lightbar.anchor.setTo(0, 0.5)
    this.uigroup.setAll('fixedToCamera', true);	
}

GameState.prototype.getClockGamma = function() {
    var clockgamma = 60 - this.clock.getMinutes();
    if ( this.clock.getHours() >= 20 ) {
	clockgamma += (23 - this.clock.getHours()) * 60;
    } else {
	clockgamma += this.clock.getHours() * 60;
    }
    clockgamma = parseInt(clockgamma / 6);
    return clockgamma;
}

GameState.prototype.updateShadowTexture = function() {
    var cv = this.shadowTextureColor;
    var uigamma = parseInt(getDOMValue("uiGamma"));
    var clockgamma = this.getClockGamma();
    this.shadowTexture.context.fillStyle = ("rgb(" + (cv[0] + clockgamma + uigamma) + 
					    "," + (cv[1] + clockgamma + uigamma) + 
					    "," + (cv[2] + clockgamma + uigamma) + ")"
					   );
    this.shadowTexture.context.fillRect(0, 0, game.world.width, game.world.height);
<commit_msg>Lightbar was off by 1px<commit_after>var GameState = function(game) {
}

GameState.prototype.updateClock = function()
{
    this.clock.setSeconds(this.clock.getSeconds() + 1);
    if ( this.clock.getSeconds() == 59)
	player.score += SCORE_PERSECOND;
    this.clock.setMilliseconds(0);
}

GameState.prototype.create = function()
{
    this.map = this.add.tilemap('map');
    for (var k in moonlightSettings['map']['tilesets']) {
	var ts = moonlightSettings['map']['tilesets'][k];
	this.map.addTilesetImage(ts['name']);
    }
    this.map_collision_layers = [];
    pfgrid = [];

    for (var ln in moonlightSettings['map']['layers']) {
	lp = moonlightSettings['map']['layers'][ln];
	if ( lp['type'] == "tiles" ) {
	    layer = this.map.createLayer(ln);	    
	    this.map.setCollisionBetween(
		lp['collisionBetween'][0],
		lp['collisionBetween'][1],
		lp['collides'],
		ln
	    );
	    if ( lp['inject_sprites'] == true ) {
		this.aiSprites = game.add.group();
		this.aiSprites.debug = true;
		this.map.createFromObjects('AI', 3544, 'player', 0, true, false, this.aiSprites, AISprite);
		this.aiSprites.forEach(function(spr) {
		    spr.update_new_values();
		}, this)
		player = this.add.sprite((19 * 32), (21 * 32), 'player');
		player.score = 0;
		player.lightmeter = 0;

	    };
	    if ( lp['collides'] == true ) {
		this.map_collision_layers.push(layer);
		for (var i = 0; i < layer.layer.data.length; i++)
		{
		    if ( i >= pfgrid.length )
			pfgrid[i] = [];
		    for (var j = 0; j < layer.layer.data[i].length; j++)
		    {
			if (layer.layer.data[i][j].index > 0) {
			    pfgrid[i][j] = 1;
			} else if ( pfgrid[i][j] != 1 ) {
			    pfgrid[i][j] = 0;
			}
		    }
		}
	    }
	    layer.resizeWorld();
	}
    }

    pathfinder_grid = new PF.Grid(this.map.width,
				  this.map.height,
				  pfgrid);
    pathfinder = new PF.AStarFinder({allowDiagonal: false});
    
    this.physics.arcade.enable(player);
    player.body.setSize(16, 16, 8, 16);
    player.body.center = new Phaser.Point(player.body.width / 2, player.body.height + player.body.halfHeight);
    player.body.collideWorldBounds = true;
    //player.body.immovable = true;

    addAnimation(player, 'bipedwalkleft');
    addAnimation(player, 'bipedwalkright');
    addAnimation(player, 'bipedwalkup');
    addAnimation(player, 'bipedwalkdown');
    addAnimation(player, 'bipedrunleft');
    addAnimation(player, 'bipedrunright');
    addAnimation(player, 'bipedrunup');
    addAnimation(player, 'bipedrundown');

    this.camera.follow(player, Phaser.Camera.FOLLOW_TOPDOWN);
    controls = game.input.keyboard.createCursorKeys();
    controls.steal = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);

    this.effectSprites = game.add.group();
    this.map.createFromObjects('EffectSprites', 5, 'player', 0, true, false, this.effectSprites, EffectSprite);
    this.effectSprites.forEach(function(spr) {
	spr.update_new_values();
    }, this)

    this.shadowTexture = game.add.bitmapData(game.world.width, game.world.height);
    // drop this lower to make the map darker
    this.shadowTextureColor = [20, 20, 20];
    this.shadowSprite = game.add.image(0, 0, this.shadowTexture);

    this.shadowSprite.blendMode = Phaser.blendModes.MULTIPLY;

    this.staticLights = game.add.group();
    this.map.createFromObjects('Lights', 97, 'player', 0, true, false, this.staticLights, Light);
    this.staticLights.forEach(function(light) {
	light.update_new_values();
    }, this)

    this.aiSpriteEffects = game.add.group();
			     
    this.staticSounds = game.add.group();
    this.map.createFromObjects('Sounds', 11, 'player', 0, true, false, this.staticSounds, SoundSprite);
    this.staticSounds.forEach(function(snd) {
	snd.update_new_values();
    }, this)

    this.bubble_group = game.add.group();

    this.uigroup = game.add.group();
    this.recentlyStolenGroup = game.add.group();
    this.game.time.advancedTiming = true;

    this.clock = new Date();
    this.clock.setHours(20, 00, 0, 0);
    this.clockTimer = game.time.create(true);
    this.clockTimer.repeat(DAYLIGHT_TIMER_REPEAT, 
			   DAYLIGHT_TIMER_REPEATCOUNT,
			   this.updateClock,
			   this);
    this.clockTimer.start();

    game.camera.deadzone.height -= 68;

    var hudoffset = game.camera.height - 68;
    this.hud = this.game.add.image(0, hudoffset, 'hud', 0, this.uigroup);
    this.hud_hourhand = this.game.add.sprite(39, 
					     hudoffset + 36, 
					     'clock_hourhand', 
					     0, 
					     this.uigroup);
    this.hud_hourhand.anchor.setTo(0.5, 0.5);
    this.hud_minutehand = this.game.add.sprite(39, 
					       hudoffset + 36, 
					       'clock_minutehand', 
					       0, 
					       this.uigroup);
    this.hud_minutehand.anchor.setTo(0.5, 0.5);
    this.hud_clockoverlay = this.game.add.image(39, 
						hudoffset + 36, 
						'clock_overlay', 
						0, 
						this.uigroup);
    this.hud_clockoverlay.anchor.setTo(0.5, 0.5);
    
    // this.clockText = this.game.add.text(
    // 	20, SCREEN_HEIGHT - 40, '', { font : '16px Arial', fill: '#ffffff' }, this.uigroup
    // );

    this.scoreText = this.game.add.text(
        SCREEN_WIDTH - 80, SCREEN_HEIGHT - 30, '', 
	{ font: '16px Arial', fill: '#ffffff' }, this.uigroup
    );

    this.lightbar = this.game.add.sprite(256,
    					hudoffset + 7 + 6,
    					'lightbar',
    					0,
    					this.uigroup);
    this.lightbar.anchor.setTo(0, 0.5)
    this.uigroup.setAll('fixedToCamera', true);	
}

GameState.prototype.getClockGamma = function() {
    var clockgamma = 60 - this.clock.getMinutes();
    if ( this.clock.getHours() >= 20 ) {
	clockgamma += (23 - this.clock.getHours()) * 60;
    } else {
	clockgamma += this.clock.getHours() * 60;
    }
    clockgamma = parseInt(clockgamma / 6);
    return clockgamma;
}

GameState.prototype.updateShadowTexture = function() {
    var cv = this.shadowTextureColor;
    var uigamma = parseInt(getDOMValue("uiGamma"));
    var clockgamma = this.getClockGamma();
    this.shadowTexture.context.fillStyle = ("rgb(" + (cv[0] + clockgamma + uigamma) + 
					    "," + (cv[1] + clockgamma + uigamma) + 
					    "," + (cv[2] + clockgamma + uigamma) + ")"
					   );
    this.shadowTexture.context.fillRect(0, 0, game.world.width, game.world.height);

{'fraction_non_alphanumeric': 0.16041065126724416, 'fraction_numerical': 0.02045235803657363, 'mean_word_length': 3.0391966310333656, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '4379828', 'n_tokens_mistral': 5004, 'n_tokens_neox': 4424, 'n_words': 722}