From 9cd7546e15702acb3273f7fbc988f8b881335559 Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Tue, 20 Mar 2018 14:34:55 +0100 Subject: [PATCH] Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 545 bytes modified --- 21g30t1e75.js | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/21g30t1e75.js b/21g30t1e75.js index 5efc7f2..a5aee9e 100644 --- a/21g30t1e75.js +++ b/21g30t1e75.js @@ -75,6 +75,34 @@ this.state = { flip : 0 }; +GameLib.CustomCode.prototype.visualizeGrid = function (color) { + + if (this.starsMesh) { + this.scene.instance.remove(this.starsMesh); + } + + this.starsGeometry = new THREE.Geometry(); + + for (var y = 0; y < this.grid.length; y++) { + for (var x = 0; x < this.grid[y].length; x++) { + this.starsGeometry.vertices.push( + new THREE.Vector3( + x, + y, + 5 + ) + ); + } + } + + var starsMaterial = new THREE.PointsMaterial({color: color, size: 0.1}); + + this.starsMesh = new THREE.Points(this.starsGeometry, starsMaterial); + + this.scene.instance.add(this.starsMesh); + +}.bind(this) + GameLib.CustomCode.prototype.createMaterial = function(image) { var diffuseMap = new GameLib.D3.Texture.Image( this.runtime.graphics, @@ -404,7 +432,7 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) { }.bind(this); -/* + GameLib.CustomCode.prototype.initializeGrid = function() { this.grid = []; @@ -413,17 +441,13 @@ GameLib.CustomCode.prototype.initializeGrid = function() { this.grid[x] = []; for (var y = 0; y < GameLib.CustomCode.GRID_HEIGHT; y++) { this.grid[x][y] = { - mesh : null, - direction : { - x : 0, - y : 0 - } + mesh : null } } } }.bind(this); -*/ + GameLib.Event.Subscribe( GameLib.Event.GAME_START, @@ -512,9 +536,10 @@ function(y) { ); } ); - - this.initializeGrid(); - */ +*/ + + this.initializeGrid(); + this.visualizeGrid(); /** * Other Settings