diff --git a/assets/images/snake.png b/assets/images/snake.png deleted file mode 100644 index 00a72a9..0000000 Binary files a/assets/images/snake.png and /dev/null differ diff --git a/assets/js/icecoder.js b/assets/js/icecoder.js index 6fecb11..3490146 100644 --- a/assets/js/icecoder.js +++ b/assets/js/icecoder.js @@ -4599,44 +4599,6 @@ var ICEcoder = { // Reset the auto-logout timer this.resetAutoLogoutTimer(); - // Detect if we type s,n,a,k,e keys with content saved, if so start snake game - if (!this.last5Keys) {this.last5Keys = [];} - this.last5Keys.push(key); - if (this.last5Keys.length == 6) { - this.last5Keys.shift(); - } - if (this.last5Keys.join() == "83,78,65,75,69") { - setTimeout(function(ic) { - // Undo back to pre 'snake' word - cM = ic.getcMInstance(); - var undoCounts = 0; - var startCG = cM.changeGeneration(); - while (cM.changeGeneration() > startCG-5) { - cM.undo(); - undoCounts++; - } - // If we have content saved - if (ic.savedPoints[ic.selectedTab-1] == cM.changeGeneration()) { - // Start snake game - ic.startSnake(); - // If we don't, redo snake word - } else { - for (var i=1; i<=undoCounts; i++) { - cM.redo(); - } - } - },0,this); - } - - // Detect arrow keys if playing snake - if (this.snakePlaying) { - if (key==37) {this.snakeDir = 'left'} - if (key==39) {this.snakeDir = 'right'} - if (key==38) {this.snakeDir = 'up'} - if (key==40) {this.snakeDir = 'down'} - return false; - } - // Mac command key handling (224 = Moz, 91/93 = Webkit Left/Right Apple) if (key==224 || key==91 || key==93) { this.cmdKey = true; @@ -5181,143 +5143,4 @@ var ICEcoder = { get("infoMessage").innerHTML = '
' + steps[step].title + '
' + steps[step].message + '

' + steps[step].button + '
'; }, - // Snart snake - startSnake: function() { - this.snakePlaying = true; - this.showHide('show',get('blackMask')); - get('mediaContainer').innerHTML = 'Let\'s play
snake


Use arrow keys to eat your code

(it returns afterwards of course) :-)
'; - setTimeout(function(ic) { - ic.showHide('hide',get('blackMask')); - get('mediaContainer').innerHTML = ''; - ic.playSnake(); - },2000,this); - }, - - // Play snake - playSnake: function() { - var cM; - - cM = this.getcMInstance(); - cM.setOption('readOnly', 'nocursor'); - cM.focus(); - - // Get state of editor at present - this.snakePreHistory = cM.getHistory(); - this.snakePreContent = cM.getValue(); - this.snakePreCursor = cM.getCursor(); - - // Pick a random point for snake to come in and set head and 4 body parts off screen - var randPos = Math.floor(Math.random()*50); - this.snakePos = [ - [randPos,0], - [randPos,-1], - [randPos,-2], - [randPos,-3], - [randPos,-4] - ]; - - // Show game layer, set direction and do 1st frame of snake - this.content.contentWindow.document.getElementById('game').style.display = 'block'; - this.snakeDir = "down"; - this.doSnake(); - - // Every 0.1s, move snake - this.snakeInt = setInterval(function(ic) { - // Set new head X & Y pos according to direction - var newHead = []; - newHead[0] = ic.snakePos[0][0]+(ic.snakeDir == "right" ? 1 : ic.snakeDir == "left" ? -1 : 0); - newHead[1] = ic.snakePos[0][1]+(ic.snakeDir == "down" ? 1 : ic.snakeDir == "up" ? -1 : 0); - // Add new head and remove tail - ic.snakePos.unshift(newHead); - ic.snakePos.pop(); - // Do next frame of snake - ic.doSnake(); - },100,this); - }, - - doSnake: function() { - var cM, cW, cH, newInnerHTML, lineData, lineContent, spaceReplaceChars, collision, scrollInfo; - - // Get CodeMirror instance, plus char width and height - cM = this.getcMInstance(); - cW = cM.defaultCharWidth(); - cH = cM.defaultTextHeight(); - - // Clear content of game layer - this.content.contentWindow.document.getElementById('game').innerHTML = ""; - // Start a new set of contents - newInnerHTML = ""; - // For every part of snake, draw it's block in position - for (var i=0; i'; - } - // Set new content in game layer - this.content.contentWindow.document.getElementById('game').innerHTML = newInnerHTML; - - // Get line & ch value under snake head then line content - lineData = cM.coordsChar({top: ((this.snakePos[0][1]*cH)+4), left: ((this.snakePos[0][0]*cW)+60)}); - lineContent = cM.getLine(lineData.line); - - // If not the last char on the line - if (this.snakePos[0][0]-1 <= lineContent.length-2) { - spaceReplaceChars = ""; - // If char under snake head is a tab, replace string contains spaces of same width - if (lineContent.substr(lineData.ch,1) === "\t") { - for (var i=0; i= 5) { - this.snakePos.pop(); - } - } - // Detect if snake head has collided into itself - collision = false; - for (var i=1; i scrollInfo.clientWidth || ((this.snakePos[0][1]*cH)+4) > scrollInfo.clientHeight || - collision - ) { - // Clear interval and hide game layer - clearInterval(this.snakeInt); - this.content.contentWindow.document.getElementById('game').style.display = 'none'; - // Set content, saved point, saved contents and history back to what they were pre game - cM.setValue(this.snakePreContent); - this.savedPoints[this.selectedTab-1] = cM.changeGeneration(); - this.savedContents[this.selectedTab-1] = this.snakePreContent; - cM.setHistory(this.snakePreHistory); - // Redo changes indicator in title tag and tab highlight save indicator also to what they are now (pre game state) - this.indicateChanges(); - this.redoTabHighlight(this.selectedTab); - // Set editor to be editable again - cM.setOption('readOnly', false); - // Set cursor back to what it was pre game and focus on editor - cM.setCursor(this.snakePreCursor); - cM.focus(); - // State we are no longer playing snake - this.snakePlaying = false; - } - - } };