if (data.entity === this.parentEntity) { console.log('snail runner loaded'); } else { return; } /** * Custom Code Components */ this.beforeRender = GameLib.EntityManager.Instance.findComponentById('94xi7aitax'); this.mouseMove = GameLib.EntityManager.Instance.findComponentById('jz3qg0174l'); this.mouseDown = GameLib.EntityManager.Instance.findComponentById('8dntnb01wu'); this.mouseUp = GameLib.EntityManager.Instance.findComponentById('kx7drv1vqw'); this.keyDown = GameLib.EntityManager.Instance.findComponentById('ramgcjepp5'); this.keyUp = GameLib.EntityManager.Instance.findComponentById('4uie4sjqxd'); /** * Meshes */ this.snail = GameLib.EntityManager.Instance.findComponentById('z2izbq1hcz'); this.cloud = GameLib.EntityManager.Instance.findComponentById('jbvm17iwfx'); this.solar = GameLib.EntityManager.Instance.findComponentById('lq5xyiu8n4'); this.treesLeft = GameLib.EntityManager.Instance.findComponentById('lq0rxnjq3n'); this.treesRight = GameLib.EntityManager.Instance.findComponentById('oag0yr1rav'); this.road = GameLib.EntityManager.Instance.findComponentById('4furha3wst'); /** * Road Sections and Clouds */ this.sections = []; this.clouds = []; /** * Camera */ this.camera = GameLib.EntityManager.Instance.findComponentById('hd8dsn7o4c'); GameLib.CustomCode.prototype.spawnCloud = function() { var cloud = this.cloud.clone(); this.cloud.position.x = -155; this.cloud.position.z = (Math.random() * 25) - 12.5; this.cloud.updateInstance('position'); this.clouds.push(cloud); }.bind(this) GameLib.CustomCode.prototype.spawnRoadSections = function() { var cloneLeft = this.treesLeft.clone(); var cloneRoad = this.road.clone(); var cloneRight = this.treesRight.clone(); for (var i = 0; i < 17; i++) { this.sections.push({ left : cloneLeft, road : cloneRoad, right : cloneRight }) cloneLeft = cloneLeft.clone(); cloneRoad = cloneRoad.clone(); cloneRight = cloneRight.clone(); } this.sections.push({ left : cloneLeft, road : cloneRoad, right : cloneRight }) }.bind(this) GameLib.Event.Subscribe( GameLib.Event.GAME_START, function() { /** * Game Variables */ this.snail.position.z = 0; this.speed = 0; this.speedUp = false; this.clouds.map( function(cloud) { cloud.geometry = null; cloud.materials = null; cloud.remove(); } ); this.clouds = []; /** * Activate our custom code components */ this.beforeRender.entityLoaded = this; this.mouseMove.entityLoaded = this; this.mouseDown.entityLoaded = this; this.mouseUp.entityLoaded = this; this.keyDown.entityLoaded = this; this.keyUp.entityLoaded = this; }.bind(this) ); this.spawnRoadSections(); //@ sourceURL=entityLoaded.js