From 60496c9fb02ef913eb569b573b2af5b2cdb2eda9 Mon Sep 17 00:00:00 2001 From: mattpass Date: Sat, 26 Sep 2020 08:43:12 +0100 Subject: [PATCH] Remove Snake game --- assets/images/snake.png | Bin 1505 -> 0 bytes assets/js/icecoder.js | 177 ---------------------------------------- 2 files changed, 177 deletions(-) delete mode 100644 assets/images/snake.png diff --git a/assets/images/snake.png b/assets/images/snake.png deleted file mode 100644 index 00a72a96740d6956ce8610c1a0d045e9a9587a12..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1505 zcma)6TWAwm7#^#Lt5)$vvBK_gidtQhnWRn98Jm@MCb6+5TauI(6x->{X*0AlXPh}T z(-0PM_d)HOFQN}3`r-wwK8UU>mFkMO7Ztpq7Np`0L{U~~%kIWAX;OV?wDWLo^L^j{ z{r~xA_BO{hmCvu3Pf=8Pq*07hR9QP&ADTCtj7Oe~%p%ir9BRV})P>WM38{JobwUu) zq;438lG4B9Caj~V*{juL8*Ynk;bo+`B?sfSHG{Azs&1ogNOBLvpc8hhdXRqq*JT>0 zN|0{#McJq!z?9mUF<~MTOUjuZnN#SEzkoWMCjuJ860o&i-Qw*ao!8~b+Bs%ukcZ%& zAU$cSE!qqOWJ2I``&}~YsR04b?eX~oTwp!$l0C!LGG5lja=fpaXT6~C&?K6vbn$U9 zT!=+>K{|!8!81%copz_I-N@`_JRHX{te5e6T?FB>`gJVXF5RjuDu~dMP1V3E(t)EW zb)r5Tq>0nX6f|Q>R<{aeA_Ze?$zVKg)=8-dj7Gl=)wC(Jh2!vx-)V)dWWNEKIJ8io zDU*xqs&qmbykJ5JBQuFmZ?THaDTI-gLIx0oeAPfztEwv~ZLQ67qESAgTUgR%7!iXs zQE{uP!uy2UaJApl5Ei+B#}o2%qCeaasI9H35yGK*)?eg`Nbb|1j*DF73s)$~b=pBQ zNMsS3>Q1PHO{9T*+PqrY3s+LFz*S0nsV~W8h#AJY+^;UXctkqLSx&Vs*-SM*)Jeyi zq_rb!_8%ml#oXpC$xtr;v}8Z^l9MtVk0o-{i}UPevhhU3`lS8%?bEyESHZ&2-7~p+ zBOpF!ac|~bS;woY@e>mZ@4x9Ed@laDu08wV+JUjr0cL1yw27>jwNF3g0RxN!$nKqf zA_@fcHvxQDHT|?b8%)3l7hfzoHcY?Nvx+fEDTFVCC~@}l>r=yxTi>x0uA^6<<&Dm0 zIM^7m>pyFg{2xxT-;U(ZR}rKku~u{zKEmzHOs7uCL0> za|-69_}yXn)Oc=i!Ed?m0*hJ?xs}~X6XNshrjNcMeYCTRn?g#H~w{gx{**!Jl)W-`!oI=Wa|I` 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; - } - - } };