diff --git a/editor/Old_Game.js b/editor/Old_Game.js deleted file mode 100644 index 9eeab52..0000000 --- a/editor/Old_Game.js +++ /dev/null @@ -1,563 +0,0 @@ -Math.TAU = Math.PI*2; - -var canvas = document.getElementById("canvas");// || document.createElement("canvas"); -canvas.style.cursor = "none"; -var ctx = canvas.getContext('2d'); - -var peeps = []; -var connections = []; -var drawing = new Drawing(); -var cursor = new Cursor(); - -var clearNetwork = function(){ - peeps = []; - connections = []; -}; -var loadNetwork = function(data){ - - // Clear! - clearNetwork(); - - // Peeps - data.peeps.forEach(function(p){ - addPeep(p[0], p[1], p[2]); - }); - - // Connections - data.connections.forEach(function(c){ - var from = peeps[c[0]]; - var to = peeps[c[1]]; - addConnection(from, to); - }); - -} -var saveNetwork = function(){ - var data = { - peeps: [], - connections: [] - }; - peeps.forEach(function(peep){ - data.peeps.push([peep.x, peep.y, peep.state]); - }); - connections.forEach(function(c){ - var fromIndex = peeps.indexOf(c.from); - var toIndex = peeps.indexOf(c.to); - data.connections.push([fromIndex, toIndex]); - }); - return data; -} - -var DRAW_STATE = 0; // 0-nothing | 1-connecting | 2-erasing -var DRAW_CONNECT_FROM = null; -var CONNECT_FROM_BUFFER = 15; -var CONNECT_TO_BUFFER = 25; - -function update(){ - - // Mouse logic... - if(Mouse.justPressed && DRAW_STATE===0){ - - // Clicked on a peep? - var peepClicked = _mouseOverPeep(CONNECT_FROM_BUFFER); // buffer of 20px - if(peepClicked){ - DRAW_CONNECT_FROM = peepClicked; - DRAW_STATE = 1; // START CONNECTING - drawing.startConnect(peepClicked); // Drawing logic - }else{ - DRAW_STATE = 2; // START ERASING - } - - } - if(DRAW_STATE==2){ // ERASE - - // Intersect with any connections? - var line = [Mouse.lastX, Mouse.lastY, Mouse.x, Mouse.y]; - for(var i=connections.length-1; i>=0; i--){ // going BACKWARDS coz killing - var c = connections[i]; - if(c.hitTest(line)) connections.splice(i,1); - } - drawing.startErase(); // Drawing logic - - } - if(Mouse.justReleased && DRAW_STATE!==0){ - - // Connecting peeps, and released on a peep? - if(DRAW_STATE==1){ - var peepReleased = _mouseOverPeep(CONNECT_TO_BUFFER); // buffer of 20px - if(peepReleased){ // connect 'em! - addConnection(DRAW_CONNECT_FROM, peepReleased); - DRAW_CONNECT_FROM = null; - } - drawing.endConnect(); // Drawing logic - }else if(DRAW_STATE==2){ - drawing.endErase(); // Drawing logic - } - DRAW_STATE = 0; // back to normal - - } - Mouse.update(); - - // Cursor Logic - if(DRAW_STATE==0){ - var peepHovered = _mouseOverPeep(CONNECT_FROM_BUFFER); // buffer of 20px - if(peepHovered){ - cursor.setMode(Cursor.CONNECT); - }else{ - cursor.setMode(Cursor.NORMAL); - } - } - if(DRAW_STATE==1){ - cursor.setMode(Cursor.CONNECT); - } - if(DRAW_STATE==2){ - cursor.setMode(Cursor.ERASE); - } - - // Update Logic - connections.forEach(function(connection){ - connection.update(ctx); - }); - drawing.update(); - peeps.forEach(function(peep){ - peep.update(); - }); - cursor.update(); - - // Draw Logic - ctx.clearRect(0, 0, canvas.width, canvas.height); - ctx.fillStyle = "#fff"; - ctx.fillRect(0, 0, canvas.width, canvas.height); - ctx.save(); - ctx.scale(2,2); - _preUpdate(); - //ctx.translate(0,100); - - connections.forEach(function(connection){ - connection.draw(ctx); - }); - drawing.draw(ctx); - peeps.forEach(function(peep){ - peep.draw(ctx); - }); - cursor.draw(ctx); - - _onUpdate(); - ctx.restore(); - - // RAF - requestAnimationFrame(update); - -} -function _preUpdate(){ - // TO IMPLEMENT -} -function _onUpdate(){ - // TO IMPLEMENT -} - -function Peep(config){ - - var self = this; - - // Properties - self.x = config.x; - self.y = config.y; - self.state = config.state; - - // Update: - self.numFriends = 0; - self.numInfectedFriends = 0; - self.faceX = 0; - self.faceY = 0; - self.faceBlink = 0; - self.isMajority = false; - var _faceFollow = 0.75+(Math.random()*0.1); - self.update = function(){ - - // Face position! - var faceVector = { - x: (Mouse.x-self.x)/5, - y: (Mouse.y-self.y)/5 - }; - faceVector.mag = Math.sqrt(faceVector.x*faceVector.x + faceVector.y*faceVector.y); - var max_distance = 5; - if(faceVector.mag>max_distance){ - faceVector.x = faceVector.x * (max_distance/faceVector.mag); - faceVector.y = faceVector.y * (max_distance/faceVector.mag); - } - self.faceX = self.faceX*_faceFollow + faceVector.x*(1-_faceFollow); - self.faceY = self.faceY*_faceFollow + faceVector.y*(1-_faceFollow); - - // Blink? - if(!self.faceBlink){ - if(Math.random()<0.002) self.faceBlink=true; - }else{ - if(Math.random()<0.09) self.faceBlink=false; - } - - // Friends connected... or infected - var friends = getConnected(self); - self.numFriends = friends.length; - self.numInfectedFriends = 0; - friends.forEach(function(friend){ - if(friend.state==2) self.numInfectedFriends++; - }); - - }; - - // Draw - var radius = 20; - var bubbleScale = 1; - var bubbleScaleVel = 0; - self.draw = function(ctx){ - - ctx.save(); - ctx.translate(self.x, self.y); - - // Circle - ctx.fillStyle = (self.state==1) ? "#ccc" : "#dd4040"; //"#ffdf00"; - ctx.beginPath(); - ctx.arc(0, 0, radius, 0, Math.TAU, false); - ctx.fill(); - - // Face - ctx.save(); - ctx.translate(self.faceX, self.faceY); - ctx.fillStyle = "rgba(0,0,0,0.5)"; - if(self.faceBlink){ - ctx.beginPath(); - ctx.rect(-14, -1, 8, 2); - ctx.fill(); - ctx.beginPath(); - ctx.rect(6, -1, 8, 2); - ctx.fill(); - }else{ - ctx.beginPath(); - ctx.arc(-10, -1, 3, 0, Math.TAU, false); - ctx.fill(); - ctx.beginPath(); - ctx.arc(10, -1, 3, 0, Math.TAU, false); - ctx.fill(); - } - ctx.beginPath(); - ctx.rect(-7, 4, 14, 2); - ctx.fill(); - ctx.restore(); - - // Say: Infected/Friends - var label = self.numInfectedFriends + "/" + self.numFriends; - ctx.font = '12px sans-serif'; - ctx.fillStyle = "#000"; - ctx.textAlign = "center"; - ctx.textBaseline = "middle"; - ctx.fontWeight = "bold"; - ctx.fillText(label, 0, -27); - - ctx.restore(); - - }; - - // Hit Test - self.hitTest = function(x,y,buffer){ - if(buffer===undefined) buffer=0; - var dx = self.x-x; - var dy = self.y-y; - var dist2 = dx*dx+dy*dy; - var r = radius+buffer; - return (dist2= 0 && s <= 1 && t >= 0 && t <= 1); - - }; - -} -function addConnection(from, to){ - - // Don't allow connect if connecting to same... - if(from==to) return; - - // ...or if already exists, in either direction - for(var i=0; i=0; i--){ // backwards index coz we're deleting - var c = connections[i]; - if(c.from==peep || c.to==peep){ // in either direction - connections.splice(i,1); // remove! - } - } -} - -function Drawing(){ - - var self = this; - - // Update! - self.update = function(){ - - // Connection - if(self.connectFrom){ - // Over any peeps? Connect to THAT! Else, connect to Mouse - var peepHovered = _mouseOverPeep(CONNECT_TO_BUFFER); // buffer of 20px - if(peepHovered==self.connectFrom) peepHovered=null; // if same, nah - self.connectTo = peepHovered ? peepHovered : Mouse; - } - - // Erase - if(self.isErasing){ - self.eraseTrail.unshift([Mouse.x,Mouse.y]); // add to start - if(self.eraseTrail.length>10){ - self.eraseTrail.pop(); // remove from end - } - }else{ - self.eraseTrail.pop(); // remove from end - } - - }; - - // Connection! - self.connectFrom = null; - self.connectTo = null; - self.startConnect = function(from){ - self.connectFrom = from; - }; - self.endConnect = function(){ - self.connectFrom = null; - }; - - // Erase! - self.isErasing = false; - self.eraseTrail = []; - self.startErase = function(){ - self.isErasing = true; - }; - self.endErase = function(){ - self.isErasing = false; - }; - - // Draw - self.draw = function(ctx){ - - // Connecting... - if(self.connectFrom){ - ctx.strokeStyle = "#666"; - ctx.lineWidth = 3; - ctx.beginPath(); - ctx.moveTo(self.connectFrom.x, self.connectFrom.y); - ctx.lineTo(self.connectTo.x, self.connectTo.y); - ctx.stroke(); - } - - // Erase - if(self.eraseTrail.length>0){ - ctx.strokeStyle = "#dd4040"; - ctx.lineWidth = 1; - ctx.beginPath(); - ctx.moveTo(self.eraseTrail[0][0], self.eraseTrail[0][1]); - for(var i=1; i - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/editor/editor.js b/editor/editor.js deleted file mode 100644 index 06acdbe..0000000 --- a/editor/editor.js +++ /dev/null @@ -1,209 +0,0 @@ -window.onload = function(){ - init(); -} - -canvas.style.width = 500; -canvas.style.height = 500; -canvas.width = parseInt(canvas.style.width)*2; -canvas.height = parseInt(canvas.style.height)*2; - -var initData; -if(window.location.hash){ - initData = JSON.parse(window.location.hash.substr(1)); -}else{ - initData = { - "goal": "herp derp", - "contagion": contagionThreshold, - "peeps": [ [200,200], [300,300] ], - "connections": [ [0,1] ] - }; -} - -function init(){ - - // Add peeps! - _loadData(initData); - - // Update - update(); - -} - -// KEYS TO ADD & REMOVE PEEPS -window.addEventListener("keydown", function(event){ - - // "S" for SAVE - if(event.keyCode==83){ - event.cancelBubble = true; - event.stopPropagation(); - event.preventDefault(); - _save(); - } - - // "1" to "2" TO ADD A PEEP - var keybase = 48; - if(event.keyCode>=keybase+1 && event.keyCode<=keybase+2){ - // Am I hovering over a peep (no buffer)? - var peepHovered = _mouseOverPeep(0); - if(peepHovered){ - removePeep(peepHovered); // If so, DELETE IT - }else{ - var state = event.keyCode-keybase; - addPeep(Mouse.x, Mouse.y, state); // If not, ADD ONE - } - } - -}); - -// SPACE TO MOVE PEEPS -var movingPeep = null; -var movingPeepOffset = {x:0,y:0} -function _preUpdate(){ - if(movingPeep){ - movingPeep.x = Mouse.x - movingPeepOffset.x; - movingPeep.y = Mouse.y - movingPeepOffset.y; - } -} -window.addEventListener("keydown", function(event){ - if(event.keyCode==32){ - var peepHovered = _mouseOverPeep(0); - if(peepHovered){ - movingPeep = peepHovered; - movingPeepOffset.x = Mouse.x - movingPeep.x; - movingPeepOffset.y = Mouse.y - movingPeep.y; - } - } -}); -window.addEventListener("keyup", function(event){ - if(event.keyCode==32){ - movingPeep = null; - } -}); - -// BUTTONS: SAVE / LOAD / CLEAR -var dataTextbox = $("#data"); -var _saveData = function(){ - var network = saveNetwork(); - return { - goal: $("#goal").value, - contagion: contagionThreshold, - peeps: network.peeps, - connections: network.connections - } -} -var _save = function(){ - var newData; - if(SIM_IS_RUNNING){ - newData = initData; - }else{ - newData = _saveData(); - } - dataTextbox.value = JSON.stringify(newData); - dataTextbox.select(); - window.location.hash = dataTextbox.value; -}; -$("#buttonSave").onclick = _save; -var _loadData = function(data){ - loadNetwork(data); - $("#goal").value = data.goal; - $("#contagionSlider").value = Math.round(data.contagion*12); - _getThreshold(); -} -$("#buttonLoad").onclick = function(){ - try{ - var data = JSON.parse(dataTextbox.value); - _loadData(data); - dataTextbox.value = "loaded!"; - }catch(e){ - alert("DATA AIN'T PROPER JSON, YO"); - } -}; -$("#buttonClear").onclick = function(){ - clearNetwork(); -}; - -// Editing the Mission Goal statement: DON'T PROPAGATE KEYS -$("#goal").addEventListener("keydown", function(event){ - event.cancelBubble = true; - event.stopPropagation(); -}); - - - -///////////////////////////////////////// -//// RUN THE SIMULATION, YO ///////////// -///////////////////////////////////////// - -var SIM_IS_RUNNING = false; -var SIM_STEP = 0; -var _updateSimRunningUI = function(){ - if(SIM_IS_RUNNING){ - $("#simIsNotRunning").style.display = "none"; - $("#simIsRunning").style.display = "inline"; - document.body.style.background = "#777"; - $("#sim_step").innerHTML = SIM_STEP; - }else{ - $("#simIsNotRunning").style.display = "inline"; - $("#simIsRunning").style.display = "none"; - document.body.style.background = ""; - } -}; -_updateSimRunningUI(); -$("#simStart").onclick = function(){ - SIM_STEP = 0; - SIM_IS_RUNNING = true; - initData = _saveData(); - _updateSimRunningUI(); -}; -$("#simStop").onclick = function(){ - SIM_IS_RUNNING = false; - _loadData(initData); - update(); - _updateSimRunningUI(); -}; - -var contagionThreshold = 0; -var _getThreshold = function(){ - contagionThreshold = $("#contagionSlider").value/12; - $("#contagionLabel").innerHTML = Math.floor(contagionThreshold*100)+"%"; -} -$("#contagionSlider").oninput = _getThreshold; -_getThreshold(); - -function stepSimulation(){ - - // Consider all peeps, and their friends - var toInfect = []; - peeps.forEach(function(peep){ - - // How many infected friends? - if(peep.numFriends==0) return; // No friends? NVM. - var ratioOfInfectedFriends = peep.numInfectedFriends/peep.numFriends; - - // Passed threshold? - if(contagionThreshold==0){ // simple contagion, just ANY friend - if(peep.numInfectedFriends>0) toInfect.push(peep); - }else{ - // greater OR EQUALS (fuzz coz floating point) - if(ratioOfInfectedFriends>=contagionThreshold-0.0001){ - toInfect.push(peep); - } - } - - }); - - // "Infect" the peeps who need to get infected - toInfect.forEach(function(peep){ - peep.state = 2; - }); - -} -$("#simNext").onclick = function(){ - SIM_STEP++; - _updateSimRunningUI(); - stepSimulation(); -}; - -function $(query){ - return document.querySelector(query); -} diff --git a/slides/index.css b/index.css similarity index 100% rename from slides/index.css rename to index.css diff --git a/slides/index.html b/index.html similarity index 100% rename from slides/index.html rename to index.html diff --git a/slides/js/chapters/0_Introduction.js b/js/chapters/0_Introduction.js similarity index 100% rename from slides/js/chapters/0_Introduction.js rename to js/chapters/0_Introduction.js diff --git a/slides/js/chapters/1_Networks.js b/js/chapters/1_Networks.js similarity index 100% rename from slides/js/chapters/1_Networks.js rename to js/chapters/1_Networks.js diff --git a/slides/js/chapters/2_Simple_Contagion.js b/js/chapters/2_Simple_Contagion.js similarity index 100% rename from slides/js/chapters/2_Simple_Contagion.js rename to js/chapters/2_Simple_Contagion.js diff --git a/slides/js/chapters/3_Complex_Contagion.js b/js/chapters/3_Complex_Contagion.js similarity index 100% rename from slides/js/chapters/3_Complex_Contagion.js rename to js/chapters/3_Complex_Contagion.js diff --git a/slides/js/chapters/4_Bonding_And_Bridging.js b/js/chapters/4_Bonding_And_Bridging.js similarity index 100% rename from slides/js/chapters/4_Bonding_And_Bridging.js rename to js/chapters/4_Bonding_And_Bridging.js diff --git a/slides/js/chapters/5_Sandbox.js b/js/chapters/5_Sandbox.js similarity index 100% rename from slides/js/chapters/5_Sandbox.js rename to js/chapters/5_Sandbox.js diff --git a/slides/js/chapters/6_Conclusion.js b/js/chapters/6_Conclusion.js similarity index 100% rename from slides/js/chapters/6_Conclusion.js rename to js/chapters/6_Conclusion.js diff --git a/slides/js/chapters/7_Credits.js b/js/chapters/7_Credits.js similarity index 100% rename from slides/js/chapters/7_Credits.js rename to js/chapters/7_Credits.js diff --git a/slides/js/lib/Key.js b/js/lib/Key.js similarity index 100% rename from slides/js/lib/Key.js rename to js/lib/Key.js diff --git a/slides/js/lib/Mouse.js b/js/lib/Mouse.js similarity index 100% rename from slides/js/lib/Mouse.js rename to js/lib/Mouse.js diff --git a/slides/js/lib/Sprite.js b/js/lib/Sprite.js similarity index 100% rename from slides/js/lib/Sprite.js rename to js/lib/Sprite.js diff --git a/slides/js/lib/helpers.js b/js/lib/helpers.js similarity index 100% rename from slides/js/lib/helpers.js rename to js/lib/helpers.js diff --git a/slides/js/lib/minpubsub.src.js b/js/lib/minpubsub.src.js similarity index 100% rename from slides/js/lib/minpubsub.src.js rename to js/lib/minpubsub.src.js diff --git a/slides/js/main.js b/js/main.js similarity index 100% rename from slides/js/main.js rename to js/main.js diff --git a/slides/js/sim/Connection.js b/js/sim/Connection.js similarity index 100% rename from slides/js/sim/Connection.js rename to js/sim/Connection.js diff --git a/slides/js/sim/ConnectorCutter.js b/js/sim/ConnectorCutter.js similarity index 100% rename from slides/js/sim/ConnectorCutter.js rename to js/sim/ConnectorCutter.js diff --git a/slides/js/sim/Peep.js b/js/sim/Peep.js similarity index 100% rename from slides/js/sim/Peep.js rename to js/sim/Peep.js diff --git a/slides/js/sim/Simulations.js b/js/sim/Simulations.js similarity index 100% rename from slides/js/sim/Simulations.js rename to js/sim/Simulations.js diff --git a/slides/js/sim/_Game.js b/js/sim/_Game.js similarity index 100% rename from slides/js/sim/_Game.js rename to js/sim/_Game.js diff --git a/slides/js/slideshow/Boxes.js b/js/slideshow/Boxes.js similarity index 100% rename from slides/js/slideshow/Boxes.js rename to js/slideshow/Boxes.js diff --git a/slides/js/slideshow/Navigation.js b/js/slideshow/Navigation.js similarity index 100% rename from slides/js/slideshow/Navigation.js rename to js/slideshow/Navigation.js diff --git a/slides/js/slideshow/Pencil.js b/js/slideshow/Pencil.js similarity index 100% rename from slides/js/slideshow/Pencil.js rename to js/slideshow/Pencil.js diff --git a/slides/js/slideshow/SandboxUI.js b/js/slideshow/SandboxUI.js similarity index 100% rename from slides/js/slideshow/SandboxUI.js rename to js/slideshow/SandboxUI.js diff --git a/slides/js/slideshow/Scratch.js b/js/slideshow/Scratch.js similarity index 100% rename from slides/js/slideshow/Scratch.js rename to js/slideshow/Scratch.js diff --git a/slides/js/slideshow/Slideshow.js b/js/slideshow/Slideshow.js similarity index 100% rename from slides/js/slideshow/Slideshow.js rename to js/slideshow/Slideshow.js diff --git a/puzzle/game/game.html b/puzzle/game/game.html deleted file mode 100644 index a14847d..0000000 --- a/puzzle/game/game.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - -
- simulation: - - (not running) -
- -
- - (running! step ) -
- - -
-
- - - - - - - - - - - \ No newline at end of file diff --git a/puzzle/game/img/cursor.png b/puzzle/game/img/cursor.png deleted file mode 100644 index 89c1a6b..0000000 Binary files a/puzzle/game/img/cursor.png and /dev/null differ diff --git a/puzzle/game/img/instruction_connect.png b/puzzle/game/img/instruction_connect.png deleted file mode 100644 index 6c6be53..0000000 Binary files a/puzzle/game/img/instruction_connect.png and /dev/null differ diff --git a/puzzle/game/img/instruction_disconnect.png b/puzzle/game/img/instruction_disconnect.png deleted file mode 100644 index 49ab70f..0000000 Binary files a/puzzle/game/img/instruction_disconnect.png and /dev/null differ diff --git a/puzzle/game/img/testing.png b/puzzle/game/img/testing.png deleted file mode 100644 index 1896cbb..0000000 Binary files a/puzzle/game/img/testing.png and /dev/null differ diff --git a/puzzle/game/img/winner.png b/puzzle/game/img/winner.png deleted file mode 100644 index 41304d3..0000000 Binary files a/puzzle/game/img/winner.png and /dev/null differ diff --git a/puzzle/game/js/Connection.js b/puzzle/game/js/Connection.js deleted file mode 100644 index 7c2d9b3..0000000 --- a/puzzle/game/js/Connection.js +++ /dev/null @@ -1,92 +0,0 @@ -function Connection(config){ - - var self = this; - - // Properties - self.from = config.from; - self.to = config.to; - self.uncuttable = config.uncuttable || false; - - // Update - self.update = function(){ - }; - - // Draw - self.draw = function(ctx){ - ctx.strokeStyle = self.uncuttable ? "#000" : "#888"; - ctx.lineWidth = 2; //self.uncuttable ? 3 : 2; - ctx.beginPath(); - ctx.moveTo(self.from.x, self.from.y); - ctx.lineTo(self.to.x, self.to.y); - ctx.stroke(); - }; - - // Hit Test with a LINE SEGMENT - // code adapted from https://gist.github.com/Joncom/e8e8d18ebe7fe55c3894 - self.hitTest = function(line){ - - var p0_x, p0_y, p1_x, p1_y, p2_x, p2_y, p3_x, p3_y; - p0_x = line[0]; - p0_y = line[1]; - p1_x = line[2]; - p1_y = line[3]; - p2_x = self.from.x; - p2_y = self.from.y; - p3_x = self.to.x; - p3_y = self.to.y; - - var s1_x, s1_y, s2_x, s2_y; - s1_x = p1_x - p0_x; - s1_y = p1_y - p0_y; - s2_x = p3_x - p2_x; - s2_y = p3_y - p2_y; - var s, t; - s = (-s1_y * (p0_x - p2_x) + s1_x * (p0_y - p2_y)) / (-s2_x * s1_y + s1_x * s2_y); - t = ( s2_x * (p0_y - p2_y) - s2_y * (p0_x - p2_x)) / (-s2_x * s1_y + s1_x * s2_y); - - return (s >= 0 && s <= 1 && t >= 0 && t <= 1); - - }; - -} -function addConnection(from, to, uncuttable){ - - // Don't allow connect if connecting to same... - if(from==to) return; - - // ...or if already exists, in either direction - for(var i=0; i=0; i--){ // backwards index coz we're deleting - var c = connections[i]; - if(c.from==peep || c.to==peep){ // in either direction - connections.splice(i,1); // remove! - } - } -} -function _makeUncuttable(arrayOfConnections){ - for(var i=0; i10){ - self.eraseTrail.pop(); // remove from end - } - }else{ - self.eraseTrail.pop(); // remove from end - } - - }; - - // Connection! - self.connectFrom = null; - self.connectTo = null; - self.startConnect = function(from){ - self.connectFrom = from; - }; - self.endConnect = function(){ - self.connectFrom = null; - }; - - // Erase! - self.isErasing = false; - self.eraseTrail = []; - self.startErase = function(){ - self.isErasing = true; - }; - self.endErase = function(){ - self.isErasing = false; - }; - - // Draw - self.draw = function(ctx){ - - // Connecting... - if(self.connectFrom){ - ctx.strokeStyle = "#ccc"; - ctx.lineWidth = 1; - ctx.beginPath(); - ctx.moveTo(self.connectFrom.x, self.connectFrom.y); - ctx.lineTo(self.connectTo.x, self.connectTo.y); - ctx.stroke(); - } - - // Erase - if(self.eraseTrail.length>0){ - ctx.strokeStyle = "#dd4040"; - ctx.lineWidth = 1; - ctx.beginPath(); - ctx.moveTo(self.eraseTrail[0][0], self.eraseTrail[0][1]); - for(var i=1; i=0; i--){ // going BACKWARDS coz killing - var c = connections[i]; - if(c.uncuttable) continue; // don't touch the UNCUTTABLES - if(c.hitTest(line)) connections.splice(i,1); - } - drawing.startErase(); // Drawing logic - - } - if(Mouse.justReleased && DRAW_STATE!==0){ - - // Connecting peeps, and released on a peep? - if(DRAW_STATE==1){ - var peepReleased = _mouseOverPeep(CONNECT_TO_BUFFER); // buffer of 20px - if(peepReleased){ // connect 'em! - addConnection(DRAW_CONNECT_FROM, peepReleased); - DRAW_CONNECT_FROM = null; - } - drawing.endConnect(); // Drawing logic - }else if(DRAW_STATE==2){ - drawing.endErase(); // Drawing logic - } - DRAW_STATE = 0; // back to normal - - } - Mouse.update(); - - // Cursor Logic - if(DRAW_STATE==0){ - var peepHovered = _mouseOverPeep(CONNECT_FROM_BUFFER); // buffer of 20px - if(peepHovered){ - cursor.setMode(Cursor.CONNECT); - }else{ - cursor.setMode(Cursor.NORMAL); - } - } - if(DRAW_STATE==1){ - cursor.setMode(Cursor.CONNECT); - } - if(DRAW_STATE==2){ - cursor.setMode(Cursor.ERASE); - } - - } - - // Update Logic - connections.forEach(function(connection){ - connection.update(ctx); - }); - drawing.update(); - peeps.forEach(function(peep){ - peep.update(); - }); - cursor.update(); - - // Draw Logic - ctx.clearRect(0, 0, canvas.width, canvas.height); - ctx.fillStyle = SIM_IS_RUNNING ? "#eee" : "#fff"; - ctx.fillRect(0, 0, canvas.width, canvas.height); - ctx.save(); - ctx.scale(2,2); - _preUpdate(); - //ctx.translate(0,100); - - connections.forEach(function(connection){ - connection.draw(ctx); - }); - drawing.draw(ctx); - peeps.forEach(function(peep){ - peep.draw(ctx); - }); - cursor.draw(ctx); - - _onUpdate(); - if(YOU_ARE_WINNER){ - ctx.drawImage(winnerImage, 0, 0, 500, 500); - } - ctx.restore(); - - // RAF - requestAnimationFrame(update); - -} -function _preUpdate(){ - // TO IMPLEMENT -} -function _onUpdate(){ - // TO IMPLEMENT -} - -/////////////////////////////////////// -// CONTAGION UI, WHY NOT HMMMM //////// -/////////////////////////////////////// - -function $(query){ - return document.querySelector(query); -} - -function showContagionUI(){ - - // Just display the div - $("#sim_ui").style.display = "block"; - _updateSimRunningUI(); - -} - -var SIM_IS_RUNNING = false; -var SIM_STEP = 0; -var _updateSimRunningUI = function(){ - if(SIM_IS_RUNNING){ - $("#sim_is_not_running").style.display = "none"; - $("#sim_is_running").style.display = "inline"; - //document.body.style.background = "#777"; - $("#sim_step").innerHTML = SIM_STEP; - }else{ - $("#sim_is_not_running").style.display = "inline"; - $("#sim_is_running").style.display = "none"; - //document.body.style.background = ""; - } -}; - - -var _networkBeforeSimulationStarted = null; -function _startSim(){ - SIM_STEP = 0; - SIM_IS_RUNNING = true; - _networkBeforeSimulationStarted = saveNetwork(); - _updateSimRunningUI(); - _startSimulation(); -}; -$("#sim_start").onclick = _startSim; -function _stopSim(){ - SIM_IS_RUNNING = false; - _resetToBeforeSimStarted(); - _updateSimRunningUI(); - _stopSimulation(); -}; -$("#sim_stop").onclick = _stopSim; -function _simNext(){ - SIM_STEP++; - _updateSimRunningUI(); - _stepSimulation(); -}; -$("#sim_next").onclick = _simNext; - -function _resetToBeforeSimStarted(){ - loadNetwork(_networkBeforeSimulationStarted); -} -function _startSimulation(){ - // To Implement -} -function _stopSimulation(){ - // To Implement -} -function _stepSimulation(){ - _infectPeople(); -} - -function _infectPeople(){ - - // Consider all peeps, and their friends - var toInfect = []; - peeps.forEach(function(peep){ - - // How many infected friends? - if(peep.numFriends==0) return; // No friends? NVM. - var ratioOfInfectedFriends = peep.numInfectedFriends/peep.numFriends; - - // Passed threshold? - if(CONTAGION_THRESHOLD==0){ // simple contagion, just ANY friend - if(peep.numInfectedFriends>0) toInfect.push(peep); - }else{ - // greater OR EQUALS (fuzz coz floating point) - if(ratioOfInfectedFriends>=CONTAGION_THRESHOLD-0.0001){ - toInfect.push(peep); - } - } - - }); - - // "Infect" the peeps who need to get infected - toInfect.forEach(function(peep){ - peep.infect(); - }); - -} - diff --git a/puzzle/game/js/Mouse.js b/puzzle/game/js/Mouse.js deleted file mode 100644 index b7e0b73..0000000 --- a/puzzle/game/js/Mouse.js +++ /dev/null @@ -1,53 +0,0 @@ -///////////////////////////// -// MOUSE //////////////////// -///////////////////////////// - -var Mouse = { - x:0, y:0, - pressed:false -}; -Mouse.ondown = function(event){ - cursor.show(); - Mouse.pressed = true; - Mouse.onmove(event); -}; -Mouse.onmove = function(event){ - cursor.show(); - Mouse.x = event.offsetX; - Mouse.y = event.offsetY; -}; -Mouse.onup = function(event){ - Mouse.pressed = false; -}; -Mouse.update = function(){ - - // Just pressed, or just released (one frame ago) - Mouse.justPressed = (!Mouse.lastPressed && Mouse.pressed); - Mouse.justReleased = (Mouse.lastPressed && !Mouse.pressed); - - // The last frame's stuff - Mouse.lastX = Mouse.x; - Mouse.lastY = Mouse.y; - Mouse.lastPressed = Mouse.pressed; - -}; -canvas.addEventListener("mousedown", Mouse.ondown); -canvas.addEventListener("mousemove", Mouse.onmove); -window.addEventListener("mouseup", Mouse.onup); - -// TOUCH. -function _touchWrapper(callback){ - return function(event){ - var _event = {}; - _event.offsetX = event.changedTouches[0].clientX; - _event.offsetY = event.changedTouches[0].clientY; - event.preventDefault(); - callback(_event); - }; -} -canvas.addEventListener("touchstart", _touchWrapper(Mouse.ondown), false); -canvas.addEventListener("touchmove", _touchWrapper(Mouse.onmove), false); -document.body.addEventListener("touchend", function(){ - cursor.hide(); - Mouse.onup(); -}, false); \ No newline at end of file diff --git a/puzzle/game/js/Peep.js b/puzzle/game/js/Peep.js deleted file mode 100644 index 44a1fba..0000000 --- a/puzzle/game/js/Peep.js +++ /dev/null @@ -1,221 +0,0 @@ -var PEEP_STATE_COLORS = { - 1: "#ccc", - 2: "#dd4040" -}; - -function Peep(config){ - - var self = this; - - // Properties - self.x = config.x; - self.y = config.y; - self.state = config.state; - - // Update: - self.numFriends = 0; - self.numInfectedFriends = 0; - self.faceX = 0; - self.faceY = 0; - self.faceBlink = 0; - self.isMajority = false; - var _faceFollow = 0.75+(Math.random()*0.1); - self.update = function(){ - - // Face position! - var faceVector = { - x: (Mouse.x-self.x)/5, - y: (Mouse.y-self.y)/5 - }; - faceVector.mag = Math.sqrt(faceVector.x*faceVector.x + faceVector.y*faceVector.y); - var max_distance = 5; - if(faceVector.mag>max_distance){ - faceVector.x = faceVector.x * (max_distance/faceVector.mag); - faceVector.y = faceVector.y * (max_distance/faceVector.mag); - } - self.faceX = self.faceX*_faceFollow + faceVector.x*(1-_faceFollow); - self.faceY = self.faceY*_faceFollow + faceVector.y*(1-_faceFollow); - - // Blink? - if(!self.faceBlink){ - if(Math.random()<0.002) self.faceBlink=true; - }else{ - if(Math.random()<0.09) self.faceBlink=false; - } - - // Friends connected... or infected - var friends = self.sim.getConnected(self); - self.numFriends = friends.length; - self.numInfectedFriends = 0; - friends.forEach(function(friend){ - if(friend.state==2) self.numInfectedFriends++; - }); - - }; - - // Draw - var radius = 20; - var barWidth = 30; - var barHeight = 10; - self.draw = function(ctx){ - - ctx.save(); - ctx.translate(self.x, self.y); - - // Circle - //ctx.fillStyle = (self.state==1) ? "#ccc" : "#dd4040"; //"#ffdf00"; - var myColor = PEEP_STATE_COLORS[self.state]; - ctx.fillStyle = myColor; - ctx.beginPath(); - ctx.arc(0, 0, radius, 0, Math.TAU, false); - ctx.fill(); - - // INFECT ON NEXT TURN? - /*var infectOnNextTurn = (self.numFriends>0 && self.numInfectedFriends/self.numFriends>=CONTAGION_THRESHOLD); - if(infectOnNextTurn){ - ctx.strokeStyle = PEEP_STATE_COLORS[2]; - ctx.lineWidth = 2; - ctx.stroke(); - }*/ - - // Face - ctx.save(); - ctx.translate(self.faceX, self.faceY); - ctx.fillStyle = "rgba(0,0,0,0.5)"; - if(self.faceBlink){ - ctx.beginPath(); - ctx.rect(-14, -1, 8, 2); - ctx.fill(); - ctx.beginPath(); - ctx.rect(6, -1, 8, 2); - ctx.fill(); - }else{ - ctx.beginPath(); - ctx.arc(-10, -1, 3, 0, Math.TAU, false); - ctx.fill(); - ctx.beginPath(); - ctx.arc(10, -1, 3, 0, Math.TAU, false); - ctx.fill(); - } - ctx.beginPath(); - ctx.rect(-7, 4, 14, 2); - ctx.fill(); - ctx.restore(); - - ////////////////////////////////////////////////////////// - // LABEL FOR INFECTED/FRIENDS, BAR, AND CONTAGION LEVEL // - ////////////////////////////////////////////////////////// - - //if(!_hack_HIDE_BARS && !self._hack_TESTED){ - - ctx.save(); - - // Say: Infected/Friends - ctx.translate(0,-42); - var labelNum = self.numInfectedFriends+"/"+self.numFriends; - var labelPercent = ""; - if(self.numFriends>0){ - labelPercent = Math.round(100*(self.numInfectedFriends/self.numFriends)) + "%"; - } - ctx.font = '12px sans-serif'; - ctx.fillStyle = myColor; - ctx.textAlign = "center"; - ctx.textBaseline = "middle"; - ctx.fontWeight = "bold"; - ctx.fillText(labelNum, 0, 0); - - // A nice bar - ctx.translate(0,12); - ctx.lineWidth = 1; - - // the white fill - ctx.fillStyle = "#fff"; - ctx.beginPath(); - ctx.rect(-barWidth/2, -barHeight/2, barWidth, barHeight); - ctx.fill(); - - // The color fills - if(self.numFriends>0){ - ctx.fillStyle = PEEP_STATE_COLORS[2]; // state = 2 infected - ctx.beginPath(); - ctx.rect(-barWidth/2, -barHeight/2, barWidth*(self.numInfectedFriends/self.numFriends), barHeight); - ctx.fill(); - } - - // The outline - ctx.strokeStyle = myColor; - ctx.beginPath(); - if(self.numFriends>0){ - ctx.rect(-barWidth/2, -barHeight/2, barWidth, barHeight); - }else{ - ctx.rect(-barWidth/2, 0, barWidth, 0); - } - ctx.stroke(); - - // a pointer for contagion level - ctx.translate(0, barHeight/2+2); - self._drawThreshold(ctx, CONTAGION_THRESHOLD); - - // Percent - ctx.font = '8px sans-serif'; - ctx.fillStyle = "rgba(0,0,0,0.8)"; - ctx.textAlign = "center"; - ctx.textBaseline = "middle"; - ctx.fontWeight = "bold"; - ctx.fillText(labelPercent, 0, -6); - - ctx.restore(); - - } - - ctx.restore(); - - }; - self._drawThreshold = function(ctx, threshold){ - ctx.save(); - ctx.translate(barWidth*threshold - barWidth/2, 0); - - ctx.strokeStyle = "#000"; //PEEP_STATE_COLORS[2]; - ctx.lineWidth = 1; - ctx.beginPath(); - ctx.moveTo(0,0); - ctx.lineTo(0,-14); - ctx.stroke(); - - ctx.restore(); - } - - // Hit Test - self.hitTest = function(x,y,buffer){ - if(buffer===undefined) buffer=0; - var dx = self.x-x; - var dy = self.y-y; - var dist2 = dx*dx+dy*dy; - var r = radius+buffer; - return (dist20 &&peep.numInfectedFriends/peep.numFriends>=0.5){ - progress++; - } - }); - YOU_ARE_WINNER = (progress==9); - - // Progress... - var label = "FOOLED: "+progress+" out of 9 peeps"; - ctx.font = '14px sans-serif'; - ctx.fillStyle = PEEP_STATE_COLORS[2]; - ctx.textAlign = "center"; - ctx.fillText(label, 250, 465); - - ctx.lineWidth = 1; - ctx.strokeStyle = PEEP_STATE_COLORS[2]; - - ctx.beginPath(); - ctx.rect(160, 470, 180, 10); - ctx.stroke(); - ctx.beginPath(); - ctx.rect(160, 470, 180*(progress/9), 10); - ctx.fill(); - -} \ No newline at end of file diff --git a/puzzle/levels/2a_sim.js b/puzzle/levels/2a_sim.js deleted file mode 100644 index 0d84e98..0000000 --- a/puzzle/levels/2a_sim.js +++ /dev/null @@ -1,33 +0,0 @@ -_hack_HIDE_BARS = true; - -canvas.style.width = 500; -canvas.style.height = 500; -canvas.width = parseInt(canvas.style.width)*2; -canvas.height = parseInt(canvas.style.height)*2; - -var initData = { - "contagion":0, - "peeps":[[50,263,2],[141,274,1],[204,353,1],[452,264,1],[301,341,1],[364,271,1],[204,195,1],[301,206,1]], - "connections":[[0,1],[1,2],[1,6],[6,7],[7,5],[5,3],[5,4],[4,2]] -} -_makeUncuttable(initData.connections); - -// Add peeps! -loadNetwork(initData); - -// Update -update(); - -// SHOW CONTAGION UI -showContagionUI(); - -function _onUpdate(){ - - // Winner iff EVERYONE is infected! - var everyoneIsInfected = true; - peeps.forEach(function(peep){ - if(peep.state!=2) everyoneIsInfected=false; - }); - YOU_ARE_WINNER = everyoneIsInfected; - -} \ No newline at end of file diff --git a/puzzle/levels/2b_simple_cascade.js b/puzzle/levels/2b_simple_cascade.js deleted file mode 100644 index 57ec60d..0000000 --- a/puzzle/levels/2b_simple_cascade.js +++ /dev/null @@ -1,33 +0,0 @@ -_hack_HIDE_BARS = true; - -canvas.style.width = 500; -canvas.style.height = 500; -canvas.width = parseInt(canvas.style.width)*2; -canvas.height = parseInt(canvas.style.height)*2; - -var initData = { - "contagion":0, - "peeps":[[57,72,2],[454,371,1],[418,438,1],[338,408,1],[333,340,1],[406,304,1],[269,116,1],[234,172,1],[305,173,1],[141,88,1],[143,243,1],[82,304,1],[124,366,1],[200,353,1],[215,276,1]], - "connections":[[6,7],[4,1],[5,4],[4,3],[3,1],[1,2],[1,5],[5,2],[3,5],[4,2],[3,2],[8,6],[8,7],[9,0],[14,10],[10,11],[11,12],[12,13],[13,14],[14,11],[10,12],[13,10],[11,13],[12,14]] -} -_makeUncuttable(initData.connections); - -// Add peeps! -loadNetwork(initData); - -// Update -update(); - -// SHOW CONTAGION UI -showContagionUI(); - -function _onUpdate(){ - - // Winner iff EVERYONE is infected! - var everyoneIsInfected = true; - peeps.forEach(function(peep){ - if(peep.state!=2) everyoneIsInfected=false; - }); - YOU_ARE_WINNER = everyoneIsInfected; - -} \ No newline at end of file diff --git a/puzzle/levels/3a_complex.js b/puzzle/levels/3a_complex.js deleted file mode 100644 index acf2af8..0000000 --- a/puzzle/levels/3a_complex.js +++ /dev/null @@ -1,21 +0,0 @@ -canvas.style.width = 500; -canvas.style.height = 500; -canvas.width = parseInt(canvas.style.width)*2; -canvas.height = parseInt(canvas.style.height)*2; - -PEEP_STATE_COLORS[2] = "#8b9dc3"; - -var initData = { - "contagion":0.25, - "peeps":[[147,69,2],[77,117,1],[77,185,1],[140,226,1],[402,140,1],[143,307,2],[95,340,1],[68,389,1],[90,436,1],[151,465,1],[398,391,1]], - "connections":[[0,4],[1,4],[2,4],[3,4],[5,10],[6,10],[7,10],[8,10],[9,10]] -} - -// Add peeps! -loadNetwork(initData); - -// Update -update(); - -// SHOW CONTAGION UI -showContagionUI(); diff --git a/puzzle/levels/3b_complex_cascade.js b/puzzle/levels/3b_complex_cascade.js deleted file mode 100644 index 777d023..0000000 --- a/puzzle/levels/3b_complex_cascade.js +++ /dev/null @@ -1,33 +0,0 @@ -canvas.style.width = 500; -canvas.style.height = 500; -canvas.width = parseInt(canvas.style.width)*2; -canvas.height = parseInt(canvas.style.height)*2; - -PEEP_STATE_COLORS[2] = "#8b9dc3"; - -var initData = { - "contagion":0.25, // DIFFERENT - "peeps":[[57,72,2],[454,371,1],[418,438,1],[338,408,1],[333,340,1],[406,304,1],[269,116,1],[234,172,1],[305,173,1],[141,88,1],[143,243,1],[82,304,1],[124,366,1],[200,353,1],[215,276,1]], - "connections":[[6,7],[4,1],[5,4],[4,3],[3,1],[1,2],[1,5],[5,2],[3,5],[4,2],[3,2],[8,6],[8,7],[9,0],[14,10],[10,11],[11,12],[12,13],[13,14],[14,11],[10,12],[13,10],[11,13],[12,14]] -} -_makeUncuttable(initData.connections); - -// Add peeps! -loadNetwork(initData); - -// Update -update(); - -// SHOW CONTAGION UI -showContagionUI(); - -function _onUpdate(){ - - // Winner iff EVERYONE is infected! - var everyoneIsInfected = true; - peeps.forEach(function(peep){ - if(peep.state!=2) everyoneIsInfected=false; - }); - YOU_ARE_WINNER = everyoneIsInfected; - -} \ No newline at end of file diff --git a/puzzle/levels/3c_extinguish.js b/puzzle/levels/3c_extinguish.js deleted file mode 100644 index c615e21..0000000 --- a/puzzle/levels/3c_extinguish.js +++ /dev/null @@ -1,22 +0,0 @@ -canvas.style.width = 500; -canvas.style.height = 500; -canvas.width = parseInt(canvas.style.width)*2; -canvas.height = parseInt(canvas.style.height)*2; - -PEEP_STATE_COLORS[2] = "#8b9dc3"; - -var initData = { - "contagion":1/4, - "peeps":[[50,263,2],[141,274,1],[204,353,1],[452,264,1],[301,341,1],[364,271,1],[204,195,1],[301,206,1]], - "connections":[[0,1],[1,2],[1,6],[6,7],[7,5],[5,3],[5,4],[4,2]] -} -_makeUncuttable(initData.connections); - -// Add peeps! -loadNetwork(initData); - -// Update -update(); - -// SHOW CONTAGION UI -showContagionUI(); diff --git a/puzzle/levels/4a_sweet_spot.js b/puzzle/levels/4a_sweet_spot.js deleted file mode 100644 index 1677592..0000000 --- a/puzzle/levels/4a_sweet_spot.js +++ /dev/null @@ -1,22 +0,0 @@ -canvas.style.width = 500; -canvas.style.height = 500; -canvas.width = parseInt(canvas.style.width)*2; -canvas.height = parseInt(canvas.style.height)*2; - -PEEP_STATE_COLORS[2] = "#8b9dc3"; - -var initData = { - "contagion":0.25, - "peeps":[[46,145,1],[91,79,2],[201,146,1],[168,211,1],[75,215,1],[168,79,1],[325,82,2],[402,78,1],[279,144,1],[320,212,1],[406,215,1],[443,143,1],[197,294,2],[150,353,1],[279,292,1],[320,349,1],[283,419,1],[196,420,1]], - "connections":[[1,5],[8,6],[6,7],[7,11],[11,10],[10,9],[9,8],[8,7],[11,6],[8,11],[7,9],[9,6],[10,8],[9,11],[0,4],[3,2],[10,6],[10,7]] -} -_makeUncuttable(initData.connections); - -// Add peeps! -loadNetwork(initData); - -// Update -update(); - -// SHOW CONTAGION UI -showContagionUI(); diff --git a/puzzle/levels/4b_bridge.js b/puzzle/levels/4b_bridge.js deleted file mode 100644 index 8ce0639..0000000 --- a/puzzle/levels/4b_bridge.js +++ /dev/null @@ -1,22 +0,0 @@ -canvas.style.width = 500; -canvas.style.height = 500; -canvas.width = parseInt(canvas.style.width)*2; -canvas.height = parseInt(canvas.style.height)*2; - -PEEP_STATE_COLORS[2] = "#8b9dc3"; - -var initData = { - "contagion":0.25, - "peeps":[[109,87,2],[186,106,1],[219,177,1],[158,251,1],[73,230,1],[46,152,1],[271,302,1],[316,234,1],[410,229,1],[454,318,1],[401,396,1],[307,388,1]], - "connections":[[11,6],[11,10],[10,9],[9,8],[8,7],[7,6],[6,9],[8,11],[10,7],[7,11],[10,8],[9,11],[6,10],[9,7],[6,8],[3,2],[5,4],[1,0]] -} -_makeUncuttable(initData.connections); - -// Add peeps! -loadNetwork(initData); - -// Update -update(); - -// SHOW CONTAGION UI -showContagionUI(); \ No newline at end of file diff --git a/puzzle/levels/4c_small_world.js b/puzzle/levels/4c_small_world.js deleted file mode 100644 index 019388a..0000000 --- a/puzzle/levels/4c_small_world.js +++ /dev/null @@ -1,22 +0,0 @@ -canvas.style.width = 500; -canvas.style.height = 500; -canvas.width = parseInt(canvas.style.width)*2; -canvas.height = parseInt(canvas.style.height)*2; - -PEEP_STATE_COLORS[2] = "#8b9dc3"; - -var initData = { - "contagion":0.25, - "peeps":[[190,80,2],[267,70,1],[152,147,1],[316,116,1],[60,300,1],[138,293,1],[40,382,1],[90,449,1],[169,433,1],[194,362,1],[199,206,1],[293,197,1],[346,288,1],[412,311,1],[286,333,1],[433,386,1],[372,437,1],[299,408,1]], - "connections":[[0,1],[2,10],[11,3],[14,17],[13,12],[16,15],[8,9],[5,4],[6,7]] -} -_makeUncuttable(initData.connections); - -// Add peeps! -loadNetwork(initData); - -// Update -update(); - -// SHOW CONTAGION UI -showContagionUI(); diff --git a/puzzle/levels_old/0_draw_whatever.js b/puzzle/levels_old/0_draw_whatever.js deleted file mode 100644 index a919502..0000000 --- a/puzzle/levels_old/0_draw_whatever.js +++ /dev/null @@ -1,40 +0,0 @@ -_hack_HIDE_BARS = true; - -canvas.style.width = 500; -canvas.style.height = 500; -canvas.width = parseInt(canvas.style.width)*2; -canvas.height = parseInt(canvas.style.height)*2; - -var initData = { - "goal": "herp derp", - "contagion": 0, - "peeps": [ - [27+20,154],[30+20,263],[39+10,444],[73+10,63],[88+10,367], - [125,210], - [125,290], // 6 - [140+10,470],[195+5,128],[215+5,358], - [221,38],[295,450],[332,121], - [375,290], // 13 - [375,210], - [378,397],[429,52],[451,183],[445,459],[461,323] - ], - "connections": [[6,13]] -}; - -// Add peeps! -loadNetwork(initData); - - -var instruction1 = new Image(); -instruction1.src = "img/instruction_connect.png"; -var instruction2 = new Image(); -instruction2.src = "img/instruction_disconnect.png"; -function _preUpdate(){ - ctx.drawImage(instruction1, 0, 0, 500, 500); - ctx.drawImage(instruction2, 0, 0, 500, 500); -} - - - -// Update -update(); \ No newline at end of file diff --git a/puzzle/levels_old/1_majority.js b/puzzle/levels_old/1_majority.js deleted file mode 100644 index 3f45013..0000000 --- a/puzzle/levels_old/1_majority.js +++ /dev/null @@ -1,48 +0,0 @@ -PEEP_STATE_COLORS[2] = "#eebb55"; - -canvas.style.width = 500; -canvas.style.height = 500; -canvas.width = parseInt(canvas.style.width)*2; -canvas.height = parseInt(canvas.style.height)*2; - -var initData = { - "contagion":0.5, - "peeps":[[128,122,2],[239,84,2],[356,131,2],[74,224,1],[95,333,1],[170,401,1],[286,411,1],[376,342,1],[403,236,1]], - "connections":[] -} - -// Add peeps! -loadNetwork(initData); - -// Update -update(); - -function _onUpdate(){ - - // WINNER? Only if ALL peeps think drinking is in the majority - var progress = 0; - peeps.forEach(function(peep){ - if(peep.numFriends>0 &&peep.numInfectedFriends/peep.numFriends>=0.5){ - progress++; - } - }); - YOU_ARE_WINNER = (progress==9); - - // Progress... - var label = "FOOLED: "+progress+" out of 9 peeps"; - ctx.font = '14px sans-serif'; - ctx.fillStyle = PEEP_STATE_COLORS[2]; - ctx.textAlign = "center"; - ctx.fillText(label, 250, 465); - - ctx.lineWidth = 1; - ctx.strokeStyle = PEEP_STATE_COLORS[2]; - - ctx.beginPath(); - ctx.rect(160, 470, 180, 10); - ctx.stroke(); - ctx.beginPath(); - ctx.rect(160, 470, 180*(progress/9), 10); - ctx.fill(); - -} \ No newline at end of file diff --git a/puzzle/levels_old/2_simple_contagion.js b/puzzle/levels_old/2_simple_contagion.js deleted file mode 100644 index 2f821d5..0000000 --- a/puzzle/levels_old/2_simple_contagion.js +++ /dev/null @@ -1,31 +0,0 @@ -canvas.style.width = 500; -canvas.style.height = 500; -canvas.width = parseInt(canvas.style.width)*2; -canvas.height = parseInt(canvas.style.height)*2; - -var initData = { - "contagion":0, - "peeps":[[72,85,2],[335,203,1],[417,256,1],[442,344,1],[374,421,1],[272,416,1],[205,330,1],[243,246,1],[111,232,1],[214,112,1]], - "connections":[[8,9],[7,2],[2,6],[6,1],[7,6],[6,5],[5,1],[1,4],[3,1],[2,1],[1,7],[7,3],[7,4],[5,7],[6,3],[6,4],[5,2],[5,3],[5,4],[4,2],[4,3],[3,2]] -} -_makeUncuttable(initData.connections); - -// Add peeps! -loadNetwork(initData); - -// Update -update(); - -// SHOW CONTAGION UI -showContagionUI(); - -function _onUpdate(){ - - // Winner iff EVERYONE is infected! - var everyoneIsInfected = true; - peeps.forEach(function(peep){ - if(peep.state!=2) everyoneIsInfected=false; - }); - YOU_ARE_WINNER = everyoneIsInfected; - -} \ No newline at end of file diff --git a/puzzle/levels_old/3_complex_contagion.js b/puzzle/levels_old/3_complex_contagion.js deleted file mode 100644 index 3b90da7..0000000 --- a/puzzle/levels_old/3_complex_contagion.js +++ /dev/null @@ -1,31 +0,0 @@ -canvas.style.width = 500; -canvas.style.height = 500; -canvas.width = parseInt(canvas.style.width)*2; -canvas.height = parseInt(canvas.style.height)*2; - -var initData = { - "contagion":1/3, // DIFFERENT - "peeps":[[72,85,2],[335,203,1],[417,256,1],[442,344,1],[374,421,1],[272,416,1],[205,330,1],[243,246,1],[111,232,1],[214,112,1]], - "connections":[[8,9],[7,2],[2,6],[6,1],[7,6],[6,5],[5,1],[1,4],[3,1],[2,1],[1,7],[7,3],[7,4],[5,7],[6,3],[6,4],[5,2],[5,3],[5,4],[4,2],[4,3],[3,2]] -} -_makeUncuttable(initData.connections); - -// Add peeps! -loadNetwork(initData); - -// Update -update(); - -// SHOW CONTAGION UI -showContagionUI(); - -function _onUpdate(){ - - // Winner iff EVERYONE is infected! - var everyoneIsInfected = true; - peeps.forEach(function(peep){ - if(peep.state!=2) everyoneIsInfected=false; - }); - YOU_ARE_WINNER = everyoneIsInfected; - -} \ No newline at end of file diff --git a/puzzle/levels_old/4_simple_group.js b/puzzle/levels_old/4_simple_group.js deleted file mode 100644 index ab57b27..0000000 --- a/puzzle/levels_old/4_simple_group.js +++ /dev/null @@ -1,87 +0,0 @@ -canvas.style.width = 500; -canvas.style.height = 500; -canvas.width = parseInt(canvas.style.width)*2; -canvas.height = parseInt(canvas.style.height)*2; - -PEEP_STATE_COLORS[2] = "#8b9dc3"; - -/*var initData = { - "contagion":0, - "peeps":[[199,165,1],[292,165,1],[146,251,1],[347,251,1],[202,333,1],[297,334,1]], - "connections":[] -}*/ -var initData = { - "contagion":0, - "peeps":[[199,165,1],[292,165,1],[146,251,1],[347,251,1],[202,333,1],[297,334,1]], - "connections":[[4,2],[2,0],[0,1],[1,3],[3,5],[5,4]] -}; -_makeUncuttable(initData.connections); - -// Add peeps! -loadNetwork(initData); - -// Update -update(); - -// SHOW CONTAGION UI -showContagionUI(); - -///////////////////// -// TEST EVERY PEEP // -///////////////////// - -var PEEP_TO_INFECT = 0; -function _startSimulation(){ - PEEP_TO_INFECT = 0; - var peep = peeps[PEEP_TO_INFECT]; - peep.infect(); - peep._hack_TESTED = true; -} -function _stopSimulation(){ - peeps.forEach(function(peep){ - peep._hack_TESTED = false; - }); -} -function _stepSimulation(){ - - // Everyone infected? - var everyoneIsInfected = _isEveryoneInfected(); - - // If everyone infected, reset! and increment. - if(everyoneIsInfected){ - PEEP_TO_INFECT++; - if(peeps[PEEP_TO_INFECT]){ - SIM_STEP = 0; - _resetToBeforeSimStarted(); - var peep = peeps[PEEP_TO_INFECT]; - peep.infect(); - peep._hack_TESTED = true; - }else{ - YOU_ARE_WINNER = true; - } - }else{ - - // Otherwise, keep on infecting. - _infectPeople(); - - // If didn't infect in single step, you MESSED UP. - everyoneIsInfected = _isEveryoneInfected(); - if(!everyoneIsInfected){ - setTimeout(function(){ - alert("Alas, you did not infect everyone in a SINGLE step!"); - _stopSim(); - },500); - } - - } - - -} - -function _isEveryoneInfected(){ - var everyoneIsInfected = true; - peeps.forEach(function(peep){ - if(peep.state!=2) everyoneIsInfected=false; - }); - return everyoneIsInfected; -} \ No newline at end of file diff --git a/puzzle/levels_old/5_complex_group.js b/puzzle/levels_old/5_complex_group.js deleted file mode 100644 index 74ae206..0000000 --- a/puzzle/levels_old/5_complex_group.js +++ /dev/null @@ -1,84 +0,0 @@ -canvas.style.width = 500; -canvas.style.height = 500; -canvas.width = parseInt(canvas.style.width)*2; -canvas.height = parseInt(canvas.style.height)*2; - -PEEP_STATE_COLORS[2] = "#8b9dc3"; - -var initData = { - "contagion":1/4, - "peeps":[[199,165,1],[292,165,1],[146,251,1],[347,251,1],[202,333,1],[297,334,1]], - "connections":[[4,2],[2,0],[0,1],[1,3],[3,5],[5,4]] -} -_makeUncuttable(initData.connections); - -// Add peeps! -loadNetwork(initData); - -// Update -update(); - -// SHOW CONTAGION UI -showContagionUI(); - -///////////////////// -// TEST EVERY PEEP // -///////////////////// - -var PEEP_TO_INFECT = 0; -var lastCount = 0; -function _startSimulation(){ - PEEP_TO_INFECT = 0; - peeps[PEEP_TO_INFECT].infect(); - peeps[PEEP_TO_INFECT]._hack_TESTED = true; - lastCount = 1; -} -function _stopSimulation(){ - peeps.forEach(function(peep){ - peep._hack_TESTED = false; - }); -} -function _stepSimulation(){ - - _infectPeople(); - - // Did count stay the same? - var countStayedTheSame = (lastCount == _numPeopleInfected()); - lastCount = _numPeopleInfected(); - - // If so, yay, next round - if(countStayedTheSame){ - PEEP_TO_INFECT++; - lastCount = 1; - if(peeps[PEEP_TO_INFECT]){ - SIM_STEP = 0; - _resetToBeforeSimStarted(); - var peep = peeps[PEEP_TO_INFECT]; - peep.infect(); - peep._hack_TESTED = true; - }else{ - YOU_ARE_WINNER = true; - } - }else{ - - // If everyone's infected, FAIL. - var everyoneIsInfected = (_numPeopleInfected()==6); - if(everyoneIsInfected){ - setTimeout(function(){ - alert("Alas, everyone's infected!"); - _stopSim(); - },500); - } - - } - -} - -function _numPeopleInfected(){ - var count = 0; - peeps.forEach(function(peep){ - if(peep.state==2) count++; - }); - return count; -} - diff --git a/puzzle/levels_old/6_depolarization.js b/puzzle/levels_old/6_depolarization.js deleted file mode 100644 index 4ab50bf..0000000 --- a/puzzle/levels_old/6_depolarization.js +++ /dev/null @@ -1,58 +0,0 @@ -canvas.style.width = 500; -canvas.style.height = 500; -canvas.width = parseInt(canvas.style.width)*2; -canvas.height = parseInt(canvas.style.height)*2; - -PEEP_STATE_COLORS[1] = "#BF5FFF"; // purple -PEEP_STATE_COLORS[2] = "#83F52C"; // green -_hack_SHOW_BOTH_STATES = true; - -var initData = { - "contagion":0.75, - "contagion2":0.95, - "peeps":[[162,99,1],[70,183,1],[70,301,1],[141,408,1],[357,100,2],[439,183,2],[432,305,2],[358,408,2]], - "connections":[[0,1],[1,2],[2,3],[7,6],[6,5],[5,4]] -} -_makeUncuttable(initData.connections); - -// Add peeps! -loadNetwork(initData); - -// Update -update(); - -function _onUpdate(){ - - // WINNER? Only if ratio of SAME friends is 3/4<=x<1 - var progress = 0; - peeps.forEach(function(peep){ - var sameFriendCount = 0; - var friends = getConnected(peep); - friends.forEach(function(friend){ - if(friend.state==peep.state) sameFriendCount++; - }); - var sameFriendRatio = sameFriendCount/friends.length; - if(0.75<=sameFriendRatio && sameFriendRatio<=0.95){ - progress++; - } - }); - YOU_ARE_WINNER = (progress==8); - - // Progress... - var label = "SOLVED: "+progress+" out of 8 peeps"; - ctx.font = '14px sans-serif'; - ctx.fillStyle = "#888"; - ctx.textAlign = "center"; - ctx.fillText(label, 250, 465); - - ctx.lineWidth = 1; - ctx.strokeStyle = "#888"; - - ctx.beginPath(); - ctx.rect(160, 470, 180, 10); - ctx.stroke(); - ctx.beginPath(); - ctx.rect(160, 470, 180*(progress/8), 10); - ctx.fill(); - -} \ No newline at end of file diff --git a/puzzle/levels_old/7_reintegrate.js b/puzzle/levels_old/7_reintegrate.js deleted file mode 100644 index eda59b0..0000000 --- a/puzzle/levels_old/7_reintegrate.js +++ /dev/null @@ -1,67 +0,0 @@ -PEEP_STATE_COLORS[2] = "#eebb55"; // yellow -_hack_SHOW_BOTH_STATES = true; -_hack_REINTEGRATION_PUZZLE = true; - -canvas.style.width = 500; -canvas.style.height = 500; -canvas.width = parseInt(canvas.style.width)*2; -canvas.height = parseInt(canvas.style.height)*2; - -var initData = { - "contagion":1/3, - "peeps":[[237,70,1],[67,125,1],[172,189,1],[315,185,1],[432,119,1],[249,342,2],[160,381,2],[335,396,2]], - "connections":[[5,6],[2,0],[0,1],[0,3],[4,0],[5,7]] -}; -_makeUncuttable(initData.connections); - -// Add peeps! -loadNetwork(initData); - -// Update -update(); - -// SHOW CONTAGION UI -showContagionUI(); - -function _onUpdate(){ - - // Winner iff NO ONE is infected! - var nooneIsInfected = true; - peeps.forEach(function(peep){ - if(peep.state==2) nooneIsInfected=false; - }); - YOU_ARE_WINNER = nooneIsInfected; - -} - -function _infectPeople(){ - - // Consider all peeps, and their friends - peeps.forEach(function(peep){ - - // How many infected friends? - if(peep.numFriends==0) return; // No friends? NVM. - var ratioOfInfectedFriends = peep.numInfectedFriends/peep.numFriends; - - // If susceptible, if %>=1/3 of friends infected, get infected - // If infected, if %<1/3 of friends not infected, get not infected - peep._NEXT_STATE = peep.state; // default - if(peep.state==1){ - if(ratioOfInfectedFriends>=1/3){ - peep._NEXT_STATE = 2; - } - } - if(peep.state==2){ - if(ratioOfInfectedFriends<=1/3){ - peep._NEXT_STATE = 1; - } - } - - }); - - // "Infect" the peeps who need to get infected - peeps.forEach(function(peep){ - peep.state = peep._NEXT_STATE; - }); - -} \ No newline at end of file diff --git a/puzzle/levels_old/8_complex_filter.js b/puzzle/levels_old/8_complex_filter.js deleted file mode 100644 index d321c93..0000000 --- a/puzzle/levels_old/8_complex_filter.js +++ /dev/null @@ -1,124 +0,0 @@ -canvas.style.width = 500; -canvas.style.height = 500; -canvas.width = parseInt(canvas.style.width)*2; -canvas.height = parseInt(canvas.style.height)*2; - -var initData = { - "contagion":1/4, - "peeps":[[174,87,1],[319,84,1],[195,183,1],[297,178,1],[143,268,1],[60,315,1],[113,404,1],[196,342,1],[299,327,1],[341,250,1],[443,296,1],[378,394,1]], - "connections":[[2,0],[0,1],[1,3],[3,2],[0,3],[2,1]] -} -_makeUncuttable(initData.connections); - -// Add peeps! -loadNetwork(initData); - -// Update -update(); - -// SHOW CONTAGION UI -showContagionUI(); - -///////////////////// -// TEST EVERY PEEP // -///////////////////// - -var _ticker = 0; -var TEST_STAGE = 1; -var TESTS_PASSED = 0; -var infectedLastCount = 1; -function _onUpdate(){ - - if(TEST_STAGE==1){ - PEEP_STATE_COLORS[2] = "#8b9dc3"; // cobalt - } - if(TEST_STAGE==2){ - PEEP_STATE_COLORS[2] = "#dd4040"; // red - } - - if(SIM_IS_RUNNING){ - _ticker++; - if(_ticker>7){ - - // Infect people - _ticker = 0; - _infectPeople(); - var countChanged = (infectedLastCount<_numPeopleInfected()); - infectedLastCount = _numPeopleInfected(); - - // If Test Stage = 1 (25% contagion) it SHOULD infect everyone - // pass only when it does - if(TEST_STAGE==1){ - if(_numPeopleInfected()==peeps.length){ - TESTS_PASSED++; - _nextPeepTest(); - if(TESTS_PASSED==peeps.length){ - alert("Okay... now testing 33% contagion threshold..."); - TEST_STAGE=2; // NEXT STAGE - CONTAGION_THRESHOLD = 1/3; // it's 33% THRESHOLD NOW - TESTS_PASSED = 0; - PEEP_TO_INFECT = 0; - _nextPeepTest(); - } - }else if(!countChanged){ - alert("Alas! You did NOT infect everyone at 25% contagion threshold"); - _stopSim(); - } - } - - // If Test Stage = 2 (33% contagion) it SHOULD NOT infect everyone - // pass only when it stays the same - if(TEST_STAGE==2){ - if(!countChanged){ - TESTS_PASSED++; - _nextPeepTest(); - if(TESTS_PASSED==peeps.length){ - alert("WIN!"); - YOU_ARE_WINNER = true; - _stopSim(); - } - }else if(_numPeopleInfected()==peeps.length){ - alert("Alas! You've infected everyone at 33% contagion threshold"); - _stopSim(); - } - } - - } - } -} - -var PEEP_TO_INFECT = 0; -var _nextPeepTest = function(){ - _resetToBeforeSimStarted(); - if(TEST_STAGE==2) CONTAGION_THRESHOLD=1/3; // hack - var peep = peeps[PEEP_TO_INFECT]; - if(!peep) return false; - peep.infect(); - peep._hack_TESTED = true; - PEEP_TO_INFECT++; - infectedLastCount = 1; - return true; -}; - -// at 25% contagion, it SHOULD infect everyone -// at 33% contagion, it SHOULD NOT infect everyone - -var lastCount = 0; -function _startSimulation(){ - CONTAGION_THRESHOLD = 1/4; - TEST_STAGE = 1; - TESTS_PASSED = 0; - PEEP_TO_INFECT = 0; - _nextPeepTest(); -} -function _stopSimulation(){ - CONTAGION_THRESHOLD = 1/4; -} - -function _numPeopleInfected(){ - var count = 0; - peeps.forEach(function(peep){ - if(peep.state==2) count++; - }); - return count; -} \ No newline at end of file diff --git a/puzzle/puzzle.css b/puzzle/puzzle.css deleted file mode 100644 index b2cac28..0000000 --- a/puzzle/puzzle.css +++ /dev/null @@ -1,46 +0,0 @@ -body{ - margin: 25px; - background: #eee; - - font-family: sans-serif; - font-size: 19px; - font-weight: 100; - line-height: 1.4em; -} - -h2, h3{ - margin-top: 0; -} - -#content{ - width:850px; - height:530px; - position: absolute; - margin: auto; - top:0; left:0; right:0; bottom:0; -} -#content_puzzle{ - display: block; - float: right; - border:none; - /*border: 1px solid #ddd;*/ -} -#content_words{ - width: 325px; - float: left; -} -#next{ - position: absolute; - width: 325px; - left:0; bottom:30px; - text-align: right; - font-size: 15px; -} -.icon{ - height: 1em; - transform: translate(0,3px) scale(1.5, 1.5); -} - -slide{ - display:none; -} \ No newline at end of file diff --git a/puzzle/puzzle.html b/puzzle/puzzle.html deleted file mode 100644 index fba357f..0000000 --- a/puzzle/puzzle.html +++ /dev/null @@ -1,418 +0,0 @@ - - - - - - - - -
-
- - -
- - - - - -

THE WISDOM and/or MADNESS of the CROWDS

- Why is it that the same people, in different groups, can be kind, cruel, smart, stupid? - In this explorable explanation, - I'll show how the network of a group itself can shape the people caught in its web. -
-
- - Draw a network of friends! → - When you're done playing around, press "next" ↘ - -
- - An example. On the right, - - represent binge-drinkers, and - - represent non-binge-drinkers. - People look to their network of peers, to get a sense of how many of their friends do something. -

- (the number over their heads show what % of their friends, not counting themselves, - are binge-drinkers. #binge_drinking_friends/#friends) -

- - Play around to get a feel of this! - Connect & disconnect people, and see how that changes their perception - of how many people do X → - -
- - As important as friendships are, networks can fool people. - A 1991 study showed that “virtually all students reported that their friends drank more than they did”. (which, if you think about it, is logically impossible!) - In fact, it's possible to fool everyone that a majority of people do X, even if people who do X are in a minority: -

- - Puzzle! Fool everyone into thinking 50% OR MORE of their - friends are binge-drinkers → - -
- - But of course, networks don't just fool people, they also change people. - "Contagions", like beliefs and behaviors, spread from person to person through a network. -

- On the right, we start with one person - - who believes a rumor. "Fake news", as the cool kids say. - Every day, that person will pass the lie on to their friends. - And they pass it on to their friends. - And so on. -

- - Click START SIM to see the "contagion" spread - (note: for now, a person adopts a contagion if AT LEAST ONE - FRIEND does. we'll see other possibilities later) → - - -
- - Now, we have a bunch of small, separate communities. -

- - Try to infect everyone with the rumor over time! - (Feel free to just hit "start sim" and try out many different networks again and again) - → - - (note: you can't cut the pre-existing connections) -
- - (someting something compounding cascade effect, something something knocking 'em down - like ever-bigger dominos) -

- (something something about spread of madness through crowds, like - 2008 financial crisis or mass speculation or mobs or riots or whatever) -
- - When an idea/behavior just needs a minimum of one friends to spread, - it's called a "simple contagion". - However, some ideas are harder to grasp, some behaviors need more encouragement, - and so these need multiple friends to spread — - these are called "complex contagions". -

- A false rumor may be a simple contagion, - but the complicated truth is - a complex contagion. - (head shows #infected_friends/#friends) -

- On the right, a complex contagion that needs 25% OR MORE friends to spread. - Play around to get a feel for it → - -
- - - Puzzle! Same as before, but now you have to spread a complex idea. - - (a person needs AT LEAST 25% of their friends to adopt the idea, before they do too) - Try "infecting" everyone now! - → - - (again, feel free to hit "start sim" and just try a solution, as many times as you want) - - - So, is that the way to spread more complex ideas/behaviors? - Just add more connections? -

- Well, no. While more connections can never hurt a simple contagion, - they can hurt complex contagions! -

- - Puzzle! Same as before, but now, try to add to the network so it - prevents the spread of a complex contagion! - -
- - (something something about groupthink, how too many connections squashes - complex contagions due to conformity pressure. example: NASA and Challenger explosion) - - - (something something about how if you have too FEW connections, - people are isolated and ideas can't spread - but if you have too MANY connections, - people are pressured by conformity and ideas can't grow.) -

- Top-left: too few connections, complex contagion doesn't spread to everyone. - Top-right: too many connections, complex contagion can't spread to everyone. -

- - Make a small group network that's the sweet spot inbetween, and spreads the complex contagion - - to everyone → - -
- - Within-group friendships are called "bonding social capital". - And you discovered, there's a sweet spot where people are connected enough - to spread a complex idea, but not so much conformity squashes it. - But how do ideas spread between groups? - Between-group friendships are called "bridging social capital", - and, likewise, there's a sweet spot. -

- - Create a group in the top-left (remember your sweet spot?) - and then create a bridge to spread the complex contagion to the other - group → - -
- - FINAL PUZZLE! Now, do both! Create a bunch of bonded communities and - the bridges between them. → - - - (something someting Small World Network, - something something "unity AND diversity", "e pluribus unum", - etc etc) -

- (happy ending or whatever) -
- - - - -
- - - - \ No newline at end of file diff --git a/puzzle/puzzle.js b/puzzle/puzzle.js deleted file mode 100644 index c26f556..0000000 --- a/puzzle/puzzle.js +++ /dev/null @@ -1,29 +0,0 @@ -var currentSlide = 0; - -function loadSlide(index){ - - var slide = $("slides").children[index]; - if(!slide) return; - - if(slide.getAttribute("level")){ - var iframe = $("#content_puzzle"); - iframe.src = "game/game.html?level="+slide.getAttribute("level"); - //iframe.width = slide.getAttribute("width"); - //iframe.height = slide.getAttribute("height"); - } - - var words = $("#content_words"); - words.innerHTML = slide.innerHTML; - -} - -function $(query){ - return document.querySelector(query); -} - -function nextLevel(){ - currentSlide++; - loadSlide(currentSlide); -} - -loadSlide(currentSlide); \ No newline at end of file diff --git a/slides/sprites/button_large.png b/sprites/button_large.png similarity index 100% rename from slides/sprites/button_large.png rename to sprites/button_large.png diff --git a/slides/sprites/line.png b/sprites/line.png similarity index 100% rename from slides/sprites/line.png rename to sprites/line.png diff --git a/slides/sprites/peeps.png b/sprites/peeps.png similarity index 100% rename from slides/sprites/peeps.png rename to sprites/peeps.png diff --git a/slides/sprites/pencil.png b/sprites/pencil.png similarity index 100% rename from slides/sprites/pencil.png rename to sprites/pencil.png diff --git a/slides/sprites/scratch.png b/sprites/scratch.png similarity index 100% rename from slides/sprites/scratch.png rename to sprites/scratch.png diff --git a/slides/sprites/tutorial_connect.png b/sprites/tutorial_connect.png similarity index 100% rename from slides/sprites/tutorial_connect.png rename to sprites/tutorial_connect.png diff --git a/slides/sprites/tutorial_disconnect.png b/sprites/tutorial_disconnect.png similarity index 100% rename from slides/sprites/tutorial_disconnect.png rename to sprites/tutorial_disconnect.png