<commit_before>/// <reference path="../tsd/phaser.d.ts"/>

const maxForce = 2000; // who knows
const SHOW_PHYSICS_DEBUG = false;
const MOTION_FORCE = 2;
const RECOIL_FORCE = 20;
const RECOIL_DURATION_MS = 150;

declare const dat: any;
const gui = new dat.GUI();
const armsTotal = 3;
const foodCount = 100;
const urchinCount = 5;
const shellCount = 7;
const maxFoodToWin = 3;

var tweaks = {
	stiffness: 30,
	damping: 500,
	playerBodyMass: 10,
	mouthMass: 5,
	tentacleForce: 140,
	armLengthStiffness: 40,
	armLengthRelaxation: 30,
	cameraScale: 1
}

function extendGuiParameterToSupportMultipleListeners(guiParam) {
	guiParam.___changeCallbacks___ = [];
	guiParam.addListener = (function (callback) {
		this.___changeCallbacks___.push(callback);
	}).bind(guiParam);
	guiParam.onChange((function (val) {
		this.___changeCallbacks___.forEach(cb => cb(val));
	}).bind(guiParam));
}

var stiffness = gui.add(tweaks, 'stiffness', 1, 50);
extendGuiParameterToSupportMultipleListeners(stiffness);

var damping = gui.add(tweaks, 'damping', 1, 500);
extendGuiParameterToSupportMultipleListeners(damping);

var mouthMass = gui.add(tweaks, 'mouthMass', 1, 100);

var tentacleForce = gui.add(tweaks, 'tentacleForce', 10, 500);

var armLengthStiffness = gui.add(tweaks, 'armLengthStiffness', 1, 50);
extendGuiParameterToSupportMultipleListeners(armLengthStiffness);

var armLengthRelaxation = gui.add(tweaks, 'armLengthRelaxation', 1, 50);
extendGuiParameterToSupportMultipleListeners(armLengthRelaxation);

var cameraScale = gui.add(tweaks, 'cameraScale', 0.5, 3);



function setPivotCenter(image: Phaser.Image) {
	image.pivot.set(image.width / 2, image.height / 2);
}

class SimpleGame {
	game: Phaser.Game;

	title: Phaser.Sprite;

	mouthGod: Phaser.Sprite;
	mouthGodEatAnimation: Phaser.Animation;
	mouthLips: Phaser.Image;
	eyes: Eye[];

	playerBody: Phaser.Sprite;
	armList: Arm[];

	crab: Crab;

	keyList = [];

	allFood: Phaser.Group;
	urchinGroup: Phaser.Group; //Declare ALL the globals
	urchinReaction: boolean;

	armsCollisionGroups: Phaser.Physics.P2.CollisionGroup[];
	mouthCoillisionGroup: Phaser.Physics.P2.CollisionGroup;

	foodEatenCount: number;

	constructor() {
		this.game = new Phaser.Game(640, 480, Phaser.AUTO, 'content', {
			create: this.create, preload: this.preload, update: this.update
		});
	}
	preload() {
		this.game.load.image('background', 'assets/background-tile.png'); // assets/background-tile-space-theme.png
		this.game.load.image('segment', 'assets/ball.png');
		this.game.load.image('eyeball-base', 'assets/eyeball-base.png');
		this.game.load.image('eyeball-iris', 'assets/eyeball-iris.png');
		this.game.load.image('eyeball-highlight', 'assets/eyeball-highlight.png');
		this.game.load.image('mouth-closed', 'assets/mouth-closed.png');
		this.game.load.image('mouth-bite0', 'assets/mouth-bite0.png');
		this.game.load.image('mouth-bite1', 'assets/mouth-bite1.png');
		this.game.load.image('mouth-bite2', 'assets/mouth-bite2.png');

		this.game.load.image('food', 'assets/boigah.png');
		this.game.load.image('shell', 'assets/shell.png');
		this.game.load.image('energy', 'assets/energy.gif');
		this.game.load.image('urchin', 'assets/urchin.png');

		this.game.load.image('doodad01', 'assets/background-doodad-01.png');
		this.game.load.image('doodad02', 'assets/background-doodad-02.png');
		this.game.load.image('doodad03', 'assets/background-doodad-03.png');
		this.game.load.image('doodad04', 'assets/background-doodad-04.png');
		this.game.load.image('doodad05', 'assets/background-doodad-05.png');
		this.game.load.image('doodad06', 'assets/background-doodad-06.png');
		this.game.load.image('doodad07', 'assets/background-doodad-07.png');
		this.game.load.image('doodad08', 'assets/background-doodad-08.png');
		
		this.game.load.spritesheet('mouth', 'assets/mouth-spritesheet.png', 87, 91);

		this.game.load.image('title', 'assets/title.png');
	}

	create() {

		this.game.add.tileSprite(0, 0, 1920, 1920, 'background');

		this.game.world.setBounds(0, 0, 1920, 1920);

		console.log(this.game.world.centerX, this.game.world.centerY);

		let spawnOffset = 200;

		this.mouthGod = this.game.add.sprite(spawnOffset, spawnOffset, 'mouth', 1);
		this.mouthGod.scale.set(2);

		this.mouthGodEatAnimation = this.mouthGod.animations.add('eat');

		let playerBodyScale = 0.65;
		this.playerBody = this.game.add.sprite(this.mouthGod.x + spawnOffset, this.mouthGod.y + spawnOffset, "segment");
		this.playerBody.scale.set(playerBodyScale); 


		this.foodEatenCount = 0;
		//add eyes
		// const eyeDistance = 1;
		// this.eyes = [];
		// for (var i = 0; i < 3; i++) {
		// 	// i eye captain
		// 	let x = Math.sin(2 * Math.PI * (i / 3) + 2 * Math.PI / 6) * eyeDistance;<commit_msg>Moved spawn a bit further away from the corner.<commit_after>/// <reference path="../tsd/phaser.d.ts"/>

const maxForce = 2000; // who knows
const SHOW_PHYSICS_DEBUG = false;
const MOTION_FORCE = 2;
const RECOIL_FORCE = 20;
const RECOIL_DURATION_MS = 150;

declare const dat: any;
const gui = new dat.GUI();
const armsTotal = 3;
const foodCount = 100;
const urchinCount = 5;
const shellCount = 7;
const maxFoodToWin = 3;

var tweaks = {
	stiffness: 30,
	damping: 500,
	playerBodyMass: 10,
	mouthMass: 5,
	tentacleForce: 140,
	armLengthStiffness: 40,
	armLengthRelaxation: 30,
	cameraScale: 1
}

function extendGuiParameterToSupportMultipleListeners(guiParam) {
	guiParam.___changeCallbacks___ = [];
	guiParam.addListener = (function (callback) {
		this.___changeCallbacks___.push(callback);
	}).bind(guiParam);
	guiParam.onChange((function (val) {
		this.___changeCallbacks___.forEach(cb => cb(val));
	}).bind(guiParam));
}

var stiffness = gui.add(tweaks, 'stiffness', 1, 50);
extendGuiParameterToSupportMultipleListeners(stiffness);

var damping = gui.add(tweaks, 'damping', 1, 500);
extendGuiParameterToSupportMultipleListeners(damping);

var mouthMass = gui.add(tweaks, 'mouthMass', 1, 100);

var tentacleForce = gui.add(tweaks, 'tentacleForce', 10, 500);

var armLengthStiffness = gui.add(tweaks, 'armLengthStiffness', 1, 50);
extendGuiParameterToSupportMultipleListeners(armLengthStiffness);

var armLengthRelaxation = gui.add(tweaks, 'armLengthRelaxation', 1, 50);
extendGuiParameterToSupportMultipleListeners(armLengthRelaxation);

var cameraScale = gui.add(tweaks, 'cameraScale', 0.5, 3);



function setPivotCenter(image: Phaser.Image) {
	image.pivot.set(image.width / 2, image.height / 2);
}

class SimpleGame {
	game: Phaser.Game;

	title: Phaser.Sprite;

	mouthGod: Phaser.Sprite;
	mouthGodEatAnimation: Phaser.Animation;
	mouthLips: Phaser.Image;
	eyes: Eye[];

	playerBody: Phaser.Sprite;
	armList: Arm[];

	crab: Crab;

	keyList = [];

	allFood: Phaser.Group;
	urchinGroup: Phaser.Group; //Declare ALL the globals
	urchinReaction: boolean;

	armsCollisionGroups: Phaser.Physics.P2.CollisionGroup[];
	mouthCoillisionGroup: Phaser.Physics.P2.CollisionGroup;

	foodEatenCount: number;

	constructor() {
		this.game = new Phaser.Game(640, 480, Phaser.AUTO, 'content', {
			create: this.create, preload: this.preload, update: this.update
		});
	}
	preload() {
		this.game.load.image('background', 'assets/background-tile.png'); // assets/background-tile-space-theme.png
		this.game.load.image('segment', 'assets/ball.png');
		this.game.load.image('eyeball-base', 'assets/eyeball-base.png');
		this.game.load.image('eyeball-iris', 'assets/eyeball-iris.png');
		this.game.load.image('eyeball-highlight', 'assets/eyeball-highlight.png');
		this.game.load.image('mouth-closed', 'assets/mouth-closed.png');
		this.game.load.image('mouth-bite0', 'assets/mouth-bite0.png');
		this.game.load.image('mouth-bite1', 'assets/mouth-bite1.png');
		this.game.load.image('mouth-bite2', 'assets/mouth-bite2.png');

		this.game.load.image('food', 'assets/boigah.png');
		this.game.load.image('shell', 'assets/shell.png');
		this.game.load.image('energy', 'assets/energy.gif');
		this.game.load.image('urchin', 'assets/urchin.png');

		this.game.load.image('doodad01', 'assets/background-doodad-01.png');
		this.game.load.image('doodad02', 'assets/background-doodad-02.png');
		this.game.load.image('doodad03', 'assets/background-doodad-03.png');
		this.game.load.image('doodad04', 'assets/background-doodad-04.png');
		this.game.load.image('doodad05', 'assets/background-doodad-05.png');
		this.game.load.image('doodad06', 'assets/background-doodad-06.png');
		this.game.load.image('doodad07', 'assets/background-doodad-07.png');
		this.game.load.image('doodad08', 'assets/background-doodad-08.png');
		
		this.game.load.spritesheet('mouth', 'assets/mouth-spritesheet.png', 87, 91);

		this.game.load.image('title', 'assets/title.png');
	}

	create() {

		this.game.add.tileSprite(0, 0, 1920, 1920, 'background');

		this.game.world.setBounds(0, 0, 1920, 1920);

		console.log(this.game.world.centerX, this.game.world.centerY);

		let spawnOffset = 300;

		this.mouthGod = this.game.add.sprite(spawnOffset, spawnOffset, 'mouth', 1);
		this.mouthGod.scale.set(2);

		this.mouthGodEatAnimation = this.mouthGod.animations.add('eat');

		let playerBodyScale = 0.65;
		let playerSpawnOffset = 150;
		this.playerBody = this.game.add.sprite(this.mouthGod.x + playerSpawnOffset, this.mouthGod.y + playerSpawnOffset, "segment");
		this.playerBody.scale.set(playerBodyScale); 


		this.foodEatenCount = 0;
		//add eyes
		// const eyeDistance = 1;
		// this.eyes = [];
		// for (var i = 0; i < 3; i++) {
		// 	// i eye captain
		// 	let x = Math.sin(2 * Math.PI * (i / 3) + 2 * Math.PI / 6) * eyeDistance;
{'fraction_non_alphanumeric': 0.16499947351795305, 'fraction_numerical': 0.031062440770769716, 'mean_word_length': 4.877475247524752, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3334968', 'n_tokens_mistral': 3890, 'n_tokens_neox': 3509, 'n_words': 586}