Team:TU Eindhoven/the game
From 2014.igem.org
(Difference between revisions)
Line 1: | Line 1: | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
- | |||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" class=" js no-touch" style=""><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" class=" js no-touch" style=""><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
- | <title> | + | <title>The game: iGEM TU/e</title> |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
<script type="text/javascript" async="" src="https://2014.igem.org/Team:TU_Eindhoven/the_game/processing?action=raw&ctype=text/js"></script> | <script type="text/javascript" async="" src="https://2014.igem.org/Team:TU_Eindhoven/the_game/processing?action=raw&ctype=text/js"></script> | ||
<link href="https://2014.igem.org/Team:TU_Eindhoven/the_game/style?action=raw&ctype=text/css" rel="stylesheet" type="text/css"> | <link href="https://2014.igem.org/Team:TU_Eindhoven/the_game/style?action=raw&ctype=text/css" rel="stylesheet" type="text/css"> | ||
- | + | </head> | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
<body id="Examples" onload=""> | <body id="Examples" onload=""> | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
<div class="example"><script type="application/processing"> | <div class="example"><script type="application/processing"> | ||
// The next line is needed if running in JavaScript Mode with Processing.js | // The next line is needed if running in JavaScript Mode with Processing.js | ||
/* @pjs preload="http://i.imgur.com/gDccyRX.png, http://i.imgur.com/V6756WQ.png, http://i.imgur.com/qmz6Tqx.png, http://i.imgur.com/kTG3cjw.png, http://i.imgur.com/rXLfh0n.png, http://i.imgur.com/DF3iOQN.png, http://i.imgur.com/HsgqFiR.png, http://i.imgur.com/yt3xRrC.png, http://i.imgur.com/oqpG7r6.png, http://i.imgur.com/tVs8PA3.png, http://i.imgur.com/8TgXchE.png, http://i.imgur.com/k2JxEjl.png, http://i.imgur.com/87sB8SH.png, http://i.imgur.com/vWEOnlj.png, http://i.imgur.com/sua0hIH.png, http://i.imgur.com/o2V20If.png, http://i.imgur.com/V2v8JpM.png, http://i.imgur.com/7VmOmW1.png, http://i.imgur.com/NW22Blc.png, http://i.imgur.com/9uJagVU.png, http://i.imgur.com/C7xi9eF.png, http://i.imgur.com/V8Tyv9D.png, http://i.imgur.com/14eMBR8.png, http://i.imgur.com/rKe6hVf.png, http://i.imgur.com/i9jxTsO.png, http://i.imgur.com/i9jxTsO.png, http://i.imgur.com/EY7xXur.png, http://i.imgur.com/qiWx2fF.png, http://i.imgur.com/2YUI7lW.png, http://i.imgur.com/KQ0ZyBA.png, http://i.imgur.com/ermi0iK.png, http://i.imgur.com/EKrOZM8.png, http://i.imgur.com/8VAJ6Bt.png, http://i.imgur.com/t2kTiPr.png, http://i.imgur.com/UmJRy3m.png, http://i.imgur.com/nkWwyFH.png, http://i.imgur.com/klMOhVr.png, http://i.imgur.com/CfREnca.png, http://i.imgur.com/1Sk2HSE.png, http://i.imgur.com/ymhoulY.png, http://i.imgur.com/G7MdUHm.png, http://i.imgur.com/P5kUXSf.png, http://i.imgur.com/oW2kyrW.png, http://i.imgur.com/wrpjZ1g.png, http://i.imgur.com/oi4cINP.png, http://i.imgur.com/wyzfNAg.jpg"; */ | /* @pjs preload="http://i.imgur.com/gDccyRX.png, http://i.imgur.com/V6756WQ.png, http://i.imgur.com/qmz6Tqx.png, http://i.imgur.com/kTG3cjw.png, http://i.imgur.com/rXLfh0n.png, http://i.imgur.com/DF3iOQN.png, http://i.imgur.com/HsgqFiR.png, http://i.imgur.com/yt3xRrC.png, http://i.imgur.com/oqpG7r6.png, http://i.imgur.com/tVs8PA3.png, http://i.imgur.com/8TgXchE.png, http://i.imgur.com/k2JxEjl.png, http://i.imgur.com/87sB8SH.png, http://i.imgur.com/vWEOnlj.png, http://i.imgur.com/sua0hIH.png, http://i.imgur.com/o2V20If.png, http://i.imgur.com/V2v8JpM.png, http://i.imgur.com/7VmOmW1.png, http://i.imgur.com/NW22Blc.png, http://i.imgur.com/9uJagVU.png, http://i.imgur.com/C7xi9eF.png, http://i.imgur.com/V8Tyv9D.png, http://i.imgur.com/14eMBR8.png, http://i.imgur.com/rKe6hVf.png, http://i.imgur.com/i9jxTsO.png, http://i.imgur.com/i9jxTsO.png, http://i.imgur.com/EY7xXur.png, http://i.imgur.com/qiWx2fF.png, http://i.imgur.com/2YUI7lW.png, http://i.imgur.com/KQ0ZyBA.png, http://i.imgur.com/ermi0iK.png, http://i.imgur.com/EKrOZM8.png, http://i.imgur.com/8VAJ6Bt.png, http://i.imgur.com/t2kTiPr.png, http://i.imgur.com/UmJRy3m.png, http://i.imgur.com/nkWwyFH.png, http://i.imgur.com/klMOhVr.png, http://i.imgur.com/CfREnca.png, http://i.imgur.com/1Sk2HSE.png, http://i.imgur.com/ymhoulY.png, http://i.imgur.com/G7MdUHm.png, http://i.imgur.com/P5kUXSf.png, http://i.imgur.com/oW2kyrW.png, http://i.imgur.com/wrpjZ1g.png, http://i.imgur.com/oi4cINP.png, http://i.imgur.com/wyzfNAg.jpg"; */ | ||
+ | |||
int numberOfDNA; | int numberOfDNA; | ||
DNAPiece[] dna; | DNAPiece[] dna; | ||
Line 171: | Line 143: | ||
boolean thereIsInfoToShow = true; | boolean thereIsInfoToShow = true; | ||
- | |||
- | void setup() { | + | void setup(){ |
- | + | size(1000, 800); | |
- | + | ||
textAlign(CENTER); | textAlign(CENTER); | ||
//image's | //image's | ||
Line 272: | Line 242: | ||
theRealLevels[1] = new MasterLevel(level2, toBad, logo2_max, (width-stripRight)+10, 180); | theRealLevels[1] = new MasterLevel(level2, toBad, logo2_max, (width-stripRight)+10, 180); | ||
- | + | ||
- | + | ||
- | + | ||
} | } | ||
- | void draw() { | + | void draw(){ |
- | // | + | image(background, 0,0, width, height); |
- | image(img, mouseX, mouseY); | + | //background(0); |
- | // | + | fill(200, 50, 50, 200); |
- | image( | + | rect(0,0, stripLeft, height); |
+ | rect(width-stripRight,0, stripRight, height); | ||
+ | |||
+ | if(infoNumber != 0){ | ||
+ | showInfoBoard(infoNumber); | ||
+ | } else if(currentHelpScreen != 0){ | ||
+ | image(helpScreen[currentHelpScreen-1], 0,0, 920, 800); | ||
+ | helpButton.drawing(); | ||
+ | bin.drawing(); | ||
+ | for(int i = 0; i < theRealLevels.length; i++){ | ||
+ | theRealLevels[i].drawing(); | ||
+ | } | ||
+ | } else { | ||
+ | plasmide1.drawing(); | ||
+ | if(secondPlas) plasmide2.drawing(); | ||
+ | bin.drawing(); | ||
+ | helpButton.drawing(); | ||
+ | for(int i = 0; i < pieceOfDNAForUse; i++){ | ||
+ | dna[i].drawing(); | ||
+ | } | ||
+ | |||
+ | |||
+ | for(int i = 0; i < theRealLevels.length; i++){ | ||
+ | theRealLevels[i].drawing(); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | void mouseClicked(){ | ||
+ | |||
+ | if(thereIsInfoToShow == false){ | ||
+ | for(int i = 0; i < theRealLevels.length; i++){ | ||
+ | theRealLevels[i].allFalse(); | ||
+ | } | ||
+ | |||
+ | if((mouseX > (width - stripRight)) || (mouseX < stripLeft)){ | ||
+ | pickingUp(); | ||
+ | } else { | ||
+ | dropIt(); | ||
+ | handItInBitch(); | ||
+ | } | ||
+ | }else{ | ||
+ | thereIsInfoToShow = false; | ||
+ | infoNumber = 0; | ||
+ | helpDrawing(); | ||
+ | for(int i = 0; i < theRealLevels.length; i++){ | ||
+ | theRealLevels[i].allFalse(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | void helpDrawing(){ | ||
+ | if(helpButton.checkIfClicked()){ | ||
+ | currentHelpScreen=(currentHelpScreen + 1)%(maxNumberOfHelpScreens+1); | ||
+ | thereIsInfoToShow = true; | ||
+ | if(currentHelpScreen == 0){ | ||
+ | helpButton.isItOn = false; | ||
+ | }else{ | ||
+ | helpButton.isItOn = true; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | void pickingUp(){ | ||
+ | somethingOnMouse = false; | ||
+ | bin.check(false); | ||
+ | |||
+ | for(int i = 0; i < theRealLevels.length; i++){ | ||
+ | if(mouseX >(width - stripRight)) theRealLevels[i].checkButton(); | ||
+ | } | ||
+ | for(int i = 0; i < pieceOfDNAForUse; i++){ | ||
+ | if(dna[i].check(mouseX, mouseY)){ | ||
+ | itemOnMouse = i; | ||
+ | somethingOnMouse = true; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | void dropIt(){ | ||
+ | if(somethingOnMouse){ | ||
+ | plasmide1.check(dna[itemOnMouse].name, dna[itemOnMouse].colour); | ||
+ | if(secondPlas) plasmide2.check(dna[itemOnMouse].name, dna[itemOnMouse].colour); | ||
+ | }else if(bin.isItOn){ | ||
+ | plasmide1.removePiece(); | ||
+ | if(secondPlas) plasmide2.removePiece(); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | void showInfoBoard(int i){ | ||
+ | image(infoBoard[i], 0,0); | ||
+ | } | ||
+ | |||
+ | void handItInBitch(){ | ||
+ | for(int i = 0; i < theRealLevels.length; i++){ | ||
+ | theRealLevels[i].checkHandIn(); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | class DNAPiece{ | ||
+ | int posX; | ||
+ | int posY; | ||
+ | int sizeX = 60; | ||
+ | int sizeY = 60; | ||
+ | int sizeXinfo = 60; | ||
+ | int sizeYinfo = 60; | ||
+ | int posXinfo = 72; | ||
+ | int posYinfo = posY; | ||
+ | int infonumber; | ||
+ | String name; | ||
+ | boolean mouseHold = false; | ||
+ | PImage img; | ||
+ | color colour; | ||
+ | |||
+ | DNAPiece(int posXQ,int posYQ, PImage imgQ, String nameQ, int infonumberQ, color colourQ){ | ||
+ | posX = posXQ; | ||
+ | posY = posYQ; | ||
+ | posYinfo = posY; | ||
+ | posXinfo = int(posX+sizeX*1.2); | ||
+ | img = imgQ; | ||
+ | name = nameQ; | ||
+ | infonumber = infonumberQ; | ||
+ | colour = colourQ; | ||
+ | } | ||
+ | |||
+ | void drawing(){ | ||
+ | fill(colour); | ||
+ | if(mouseHold){ | ||
+ | image(img, mouseX-sizeX/2, mouseY-sizeY/2, sizeX, sizeY); | ||
+ | text(name, width/2, height/20); | ||
+ | }else{ | ||
+ | image(img, posX, posY, sizeX, sizeY); | ||
+ | } | ||
+ | image(info, posXinfo, posY, sizeX, sizeY); | ||
+ | } | ||
+ | |||
+ | boolean check(int XQ, int YQ){ | ||
+ | if((XQ <= (posX + sizeX)) && (XQ > posX) && (YQ <= (posY + sizeY)) && (YQ > posY) && (mouseHold == false)){ | ||
+ | mouseHold = true; | ||
+ | return true; | ||
+ | } else { | ||
+ | if((XQ <= (posXinfo + sizeXinfo)) && (XQ > posXinfo) && (YQ <= (posYinfo + sizeYinfo)) && (YQ > posYinfo) && (infoNumber == 0)) infoNumber = infonumber; thereIsInfoToShow = true;//do you click the infobutton? | ||
+ | mouseHold = false; | ||
+ | return false; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | class Button{ | ||
+ | PImage buttonOn; | ||
+ | PImage buttonOff; | ||
+ | boolean isItOn = false; | ||
+ | int posX; | ||
+ | int posY; | ||
+ | int sizeX = 60; | ||
+ | int sizeY = 60; | ||
+ | |||
+ | Button(int posXQ, int posYQ, PImage buttonOnQ, PImage buttonOffQ){ | ||
+ | posX = posXQ; | ||
+ | posY = posYQ; | ||
+ | buttonOn = buttonOnQ; | ||
+ | buttonOff = buttonOffQ; | ||
+ | } | ||
+ | |||
+ | Button(int posXQ, int posYQ, int sizeXQ, int sizeYQ, PImage buttonOnQ, PImage buttonOffQ){ | ||
+ | posX = posXQ; | ||
+ | posY = posYQ; | ||
+ | sizeX=sizeXQ; | ||
+ | sizeY=sizeYQ; | ||
+ | buttonOn = buttonOnQ; | ||
+ | buttonOff = buttonOffQ; | ||
+ | } | ||
+ | |||
+ | void drawing(){ | ||
+ | if(isItOn){ | ||
+ | image(buttonOn, posX, posY, sizeX, sizeY); | ||
+ | }else{ | ||
+ | image(buttonOff, posX, posY, sizeX, sizeY); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | void check(boolean infoQ){ | ||
+ | |||
+ | if((mouseX <= (posX + sizeX)) && (mouseX > posX) && (mouseY <= (posY + sizeY)) && (mouseY > posY) && (isItOn == false)){ | ||
+ | isItOn = true; | ||
+ | } else { | ||
+ | isItOn = false; | ||
+ | } | ||
+ | if(infoQ) thereIsInfoToShow = true; | ||
+ | } | ||
+ | |||
+ | boolean checkIfClicked(){ | ||
+ | if((mouseX <= (posX + sizeX)) && (mouseX > posX) && (mouseY <= (posY + sizeY)) && (mouseY > posY)){ | ||
+ | return true; | ||
+ | } else { | ||
+ | return false; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | class MasterLevel{ | ||
+ | SubLevel theLevels[]; | ||
+ | int currentLevel = 0; | ||
+ | int reward; | ||
+ | PImage toBad; | ||
+ | PImage maxLevel; | ||
+ | boolean showInfo = false; | ||
+ | boolean endLevel = false; | ||
+ | boolean doneWell; | ||
+ | Button handingIn; | ||
+ | //drawing the image's | ||
+ | int posX; | ||
+ | int posY; | ||
+ | |||
+ | int sizeX = 60; | ||
+ | int sizeY = 60; | ||
+ | int sizeXd = 920; | ||
+ | int sizeYd = 800; | ||
+ | |||
+ | MasterLevel(SubLevel[] theLevelsQ, PImage toBadQ, PImage maxLevelQ, int posXQ, int posYQ){ | ||
+ | theLevels = theLevelsQ; | ||
+ | maxLevel = maxLevelQ; | ||
+ | toBad = toBadQ; | ||
+ | posX = posXQ; | ||
+ | posY = posYQ; | ||
+ | handingIn = new Button(600, 650, 240, 60, handInDNA, handInDNA); | ||
+ | } | ||
+ | |||
+ | void drawing(){ | ||
+ | if(currentLevel < theLevels.length){ | ||
+ | fill(255,255,0); | ||
+ | if(showInfo) rect(posX-5,posY-5,sizeX+10,sizeY+10); | ||
+ | image(theLevels[currentLevel].logo, posX, posY, sizeX, sizeY); | ||
+ | } else{ | ||
+ | image(maxLevel, posX, posY, sizeX, sizeY); | ||
+ | } | ||
+ | if(showInfo){ | ||
+ | if(endLevel){ | ||
+ | if(doneWell){ | ||
+ | image(theLevels[currentLevel-1].wellDone, 0,0, sizeXd, sizeYd); | ||
+ | }else{ | ||
+ | image(toBad, 0,0, sizeXd, sizeYd); | ||
+ | } | ||
+ | }else{ | ||
+ | image(theLevels[currentLevel].description, 0,0, sizeXd, sizeYd); | ||
+ | handingIn.drawing(); | ||
+ | } | ||
+ | |||
+ | } | ||
+ | } | ||
+ | |||
+ | void checkButton(){ | ||
+ | if((mouseX <= (posX + sizeX)) && (mouseX > posX) && (mouseY <= (posY + sizeY)) && (mouseY > posY) && (showInfo == false) && (currentLevel < theLevels.length)){ | ||
+ | showInfo = true; | ||
+ | thereIsInfoToShow = true; | ||
+ | } else { | ||
+ | showInfo = false; | ||
+ | endLevel = false; | ||
+ | } | ||
+ | } | ||
+ | void checkHandIn(){ | ||
+ | if((showInfo) && (handingIn.checkIfClicked()) && (endLevel == false)){ | ||
+ | if((theLevels[currentLevel].check(plasmide1.hold) && theLevels[currentLevel].check2(plasmide2.hold))||(theLevels[currentLevel].check2(plasmide1.hold) && theLevels[currentLevel].check(plasmide2.hold))){ | ||
+ | endLevel = true; | ||
+ | doneWell = true; | ||
+ | theLevels[currentLevel].rewardThatShit(); | ||
+ | currentLevel++; | ||
+ | }else{ | ||
+ | endLevel = true; | ||
+ | doneWell = false; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | void allFalse(){ | ||
+ | if(!handingIn.checkIfClicked()){ | ||
+ | showInfo = false; | ||
+ | endLevel = false; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | class Plasmide{ | ||
+ | String hold[]; | ||
+ | color colour[]; | ||
+ | color emptyColour = color(125, 125, 125); | ||
+ | int posX; | ||
+ | int posY; | ||
+ | int sizeR; | ||
+ | int sizeR2; | ||
+ | int sizeR3; | ||
+ | int maxLength; | ||
+ | float sizeRone; | ||
+ | long lastRemove; | ||
+ | |||
+ | Plasmide(int posXQ,int posYQ,int sizeRQ, int sizeR2Q, int maxLengthQ){ | ||
+ | posX = posXQ; | ||
+ | posY = posYQ; | ||
+ | sizeR = sizeRQ; | ||
+ | sizeR2 = sizeR2Q; | ||
+ | sizeR3 = sizeR + 50; | ||
+ | maxLength = maxLengthQ; | ||
+ | sizeRone = (sizeR/maxLength); | ||
+ | hold = new String[0]; | ||
+ | colour = new color[0]; | ||
+ | } | ||
+ | |||
+ | void drawing(){ | ||
+ | fill(255, 100); | ||
+ | rect(posX, posY, sizeR, sizeR); | ||
+ | pushMatrix(); | ||
+ | float step = 0.1; | ||
+ | int lengthOfHold = hold.length; | ||
+ | translate(posX+sizeR/2, posY+sizeR/2); | ||
+ | fill(0); | ||
+ | text(maxLength,0,0); | ||
+ | noStroke(); | ||
+ | |||
+ | for(int i = 0; i < lengthOfHold; i++){ | ||
+ | beginShape(); | ||
+ | fill(colour[i]); | ||
+ | for(float u = i*TWO_PI/maxLength; u <= (i+1)*TWO_PI/maxLength; u += step){ | ||
+ | vertex(cos(u)*sizeR/2, sin(u)*sizeR/2); | ||
+ | } | ||
+ | vertex(cos((i+1)*TWO_PI/maxLength)*sizeR/2, sizeR/2*sin((i+1)*TWO_PI/maxLength)); | ||
+ | for(float u = (i+1)*TWO_PI/maxLength; u >= (i)*TWO_PI/maxLength; u -= step){ | ||
+ | vertex(cos(u)*sizeR2/2, sizeR2/2*sin(u)); | ||
+ | } | ||
+ | vertex(cos((i)*TWO_PI/maxLength)*sizeR2/2, sizeR2/2*sin((i)*TWO_PI/maxLength)); | ||
+ | endShape(); | ||
+ | fill(0); | ||
+ | text(hold[i], cos((i+0.5)*TWO_PI/maxLength)*sizeR2/2, sizeR2/2*sin((i+0.5)*TWO_PI/maxLength)); | ||
+ | } | ||
+ | |||
+ | fill(emptyColour); | ||
+ | noStroke(); | ||
+ | beginShape(); | ||
+ | for(float u = 0; u >= -(maxLength-lengthOfHold)*TWO_PI/maxLength; u -= step){ | ||
+ | vertex(cos(u)*sizeR/2, sin(u)*sizeR/2); | ||
+ | } | ||
+ | vertex(cos(-(maxLength-lengthOfHold)*TWO_PI/maxLength)*sizeR/2, sizeR/2*sin(-(maxLength-lengthOfHold)*TWO_PI/maxLength)); | ||
+ | for(float u = -(maxLength-lengthOfHold)*TWO_PI/maxLength; u <= 0; u += step){ | ||
+ | vertex(cos(u)*sizeR2/2, sin(u)*sizeR2/2); | ||
+ | } | ||
+ | vertex(sizeR2/2, 0); | ||
+ | endShape(); | ||
+ | popMatrix(); | ||
+ | } | ||
+ | |||
+ | void check(String holdQ, color colourQ){ | ||
+ | float angle = atan2((mouseY-posY-sizeR/2),( mouseX-posX-sizeR/2)); | ||
+ | if(angle < 0){ | ||
+ | angle = TWO_PI + angle; | ||
+ | } | ||
+ | int clickPiece = floor(angle/TWO_PI * maxLength); | ||
+ | if((mouseX <= (posX + sizeR)) && (mouseX > posX) && (mouseY <= (posY + sizeR)) && (mouseY > posY) && (hold.length < maxLength)){ | ||
+ | if((hold.length < maxLength) && (hold.length < clickPiece)){ | ||
+ | hold=append(hold, holdQ); | ||
+ | colour=append(colour, colourQ); | ||
+ | } else { | ||
+ | |||
+ | if((hold.length >= clickPiece) && (millis()-lastRemove > 100)){ | ||
+ | String[] holdQQ = subset(hold, clickPiece); | ||
+ | color[] colourQQ = subset(colour, clickPiece); | ||
+ | hold = append(subset(hold, 0, clickPiece), holdQ); | ||
+ | colour = append(subset(colour, 0, clickPiece), colourQ); | ||
+ | |||
+ | for(int i = 0; i < holdQQ.length; i++){ | ||
+ | hold=append(hold, holdQQ[i]); | ||
+ | colour=append(colour, colourQQ[i]); | ||
+ | } | ||
+ | lastRemove = millis(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | boolean removePiece(){ | ||
+ | float angle = atan2((mouseY-posY-sizeR/2),( mouseX-posX-sizeR/2)); | ||
+ | if(angle < 0){ | ||
+ | angle = TWO_PI + angle; | ||
+ | } | ||
+ | int clickPiece = floor(angle/TWO_PI * maxLength); | ||
+ | if((mouseX <= (posX + sizeR)) && (mouseX > posX) && (mouseY <= (posY + sizeR)) && (mouseY > posY) && (hold.length >= clickPiece) && (millis()-lastRemove > 100)){ | ||
+ | String[] holdQ = subset(hold, clickPiece); | ||
+ | color[] colourQ = subset(colour, clickPiece); | ||
+ | hold = subset(hold, 0, clickPiece); | ||
+ | colour = subset(colour, 0, clickPiece); | ||
+ | for(int i = 1; i < holdQ.length; i++){ | ||
+ | hold=append(hold, holdQ[i]); | ||
+ | colour=append(colour, colourQ[i]); | ||
+ | } | ||
+ | lastRemove = millis(); | ||
+ | return true; | ||
+ | } else{ | ||
+ | return false; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | class SubLevel{ | ||
+ | String demands[]; | ||
+ | String demands2[]; | ||
+ | PImage logo; | ||
+ | PImage description; | ||
+ | PImage wellDone; | ||
+ | boolean past = false; | ||
+ | boolean locked = true; | ||
+ | int masterPos; | ||
+ | int subPose; | ||
+ | |||
+ | SubLevel(String[] demandsQ, String[] demands2Q, PImage logoQ, PImage descQ, PImage wellDoneQ, int masterPosQ, int subPoseQ){ | ||
+ | demands = demandsQ; | ||
+ | demands2 = demands2Q; | ||
+ | logo = logoQ; | ||
+ | description = descQ; | ||
+ | wellDone = wellDoneQ; | ||
+ | masterPos = masterPosQ; | ||
+ | subPose = subPoseQ; | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | boolean check(String[] currentPlasQ){ | ||
+ | // past = true; | ||
+ | // | ||
+ | // if(currentPlasQ.length==demands.length){ | ||
+ | // for(int i = 0; i < demands.length; i++){ | ||
+ | // if(currentPlasQ[i] != demands[i]){ | ||
+ | // past = false; | ||
+ | // break; | ||
+ | // } | ||
+ | // } | ||
+ | // }else{ | ||
+ | // past = false; | ||
+ | // } | ||
+ | // | ||
+ | // return past; | ||
+ | past = true; | ||
+ | boolean firstCorrect = false; | ||
+ | int firstDNAPiece = 0; | ||
+ | String[] stringLine1; | ||
+ | String[] stringLine2; | ||
+ | if(demands.length!=0){ | ||
+ | for(int i = 0; i < currentPlasQ.length; i++){ | ||
+ | if(currentPlasQ[i] == demands[0]){ | ||
+ | firstCorrect = true; | ||
+ | firstDNAPiece = i; | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | stringLine1 = subset(currentPlasQ, firstDNAPiece, currentPlasQ.length-firstDNAPiece); | ||
+ | stringLine2 = subset(currentPlasQ, 0, firstDNAPiece); | ||
+ | |||
+ | for(int u = 0; u < stringLine2.length; u++){ | ||
+ | stringLine1 = append(stringLine1, stringLine2[u]); | ||
+ | } | ||
+ | |||
+ | currentPlasQ = stringLine1; | ||
+ | |||
+ | |||
+ | if((currentPlasQ.length==demands.length) && (firstCorrect)){ | ||
+ | for(int i = 0; i < demands.length; i++){ | ||
+ | if(currentPlasQ[i] != demands[i]){ | ||
+ | past = false; | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | }else{ | ||
+ | past = false; | ||
+ | } | ||
+ | }else{ | ||
+ | if(currentPlasQ.length==0){ past = true; }else{ past = false; } | ||
+ | } | ||
+ | return past; | ||
+ | } | ||
+ | |||
+ | boolean check2(String[] currentPlasQ){ | ||
+ | past = true; | ||
+ | boolean firstCorrect = false; | ||
+ | int firstDNAPiece = 0; | ||
+ | String[] stringLine1; | ||
+ | String[] stringLine2; | ||
+ | if(demands2.length!=0){ | ||
+ | for(int i = 0; i < currentPlasQ.length; i++){ | ||
+ | if(currentPlasQ[i] == demands2[0]){ | ||
+ | firstCorrect = true; | ||
+ | firstDNAPiece = i; | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | stringLine1 = subset(currentPlasQ, firstDNAPiece, currentPlasQ.length-firstDNAPiece); | ||
+ | stringLine2 = subset(currentPlasQ, 0, firstDNAPiece); | ||
+ | |||
+ | for(int u = 0; u < stringLine2.length; u++){ | ||
+ | stringLine1 = append(stringLine1, stringLine2[u]); | ||
+ | } | ||
+ | |||
+ | currentPlasQ = stringLine1; | ||
+ | |||
+ | |||
+ | if((currentPlasQ.length==demands2.length) && (firstCorrect)){ | ||
+ | for(int i = 0; i < demands2.length; i++){ | ||
+ | if(currentPlasQ[i] != demands2[i]){ | ||
+ | past = false; | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | }else{ | ||
+ | past = false; | ||
+ | } | ||
+ | }else{ | ||
+ | if(currentPlasQ.length==0){ past = true; }else{ past = false; } | ||
+ | } | ||
+ | return past; | ||
+ | } | ||
+ | |||
+ | void rewardThatShit(){ | ||
+ | reward(masterPos, subPose); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | void reward(int master, int sub){ | ||
+ | switch(master){ | ||
+ | |||
+ | case 1: | ||
+ | rewardSub1(sub); | ||
+ | break; | ||
+ | case 2: | ||
+ | rewardSub2(sub); | ||
+ | break; | ||
+ | case 3: | ||
+ | rewardSub3(sub); | ||
+ | break; | ||
+ | case 4: | ||
+ | rewardSub4(sub); | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | //pieceOfDNAForUse | ||
+ | //plasmide1.maxLength | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | void rewardSub1(int sub){ | ||
+ | |||
+ | switch(sub){ | ||
+ | case 1: | ||
+ | pieceOfDNAForUse += 1; | ||
+ | plasmide1.maxLength++; | ||
+ | break; | ||
+ | case 2: | ||
+ | pieceOfDNAForUse++; | ||
+ | plasmide1.maxLength++; | ||
+ | break; | ||
+ | case 3: | ||
+ | pieceOfDNAForUse++; | ||
+ | plasmide1.maxLength+=2; | ||
+ | break; | ||
+ | case 4: | ||
+ | |||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | void rewardSub2(int sub){ | ||
+ | switch(sub){ | ||
+ | case 1: | ||
+ | |||
+ | break; | ||
+ | |||
+ | case 2: | ||
+ | |||
+ | break; | ||
+ | case 3: | ||
+ | |||
+ | break; | ||
+ | case 4: | ||
+ | |||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | void rewardSub3(int sub){ | ||
+ | switch(sub){ | ||
+ | case 1: | ||
+ | |||
+ | break; | ||
+ | |||
+ | case 2: | ||
+ | |||
+ | break; | ||
+ | case 3: | ||
+ | |||
+ | break; | ||
+ | case 4: | ||
+ | |||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | void rewardSub4(int sub){ | ||
+ | switch(sub){ | ||
+ | case 1: | ||
+ | |||
+ | break; | ||
+ | |||
+ | case 2: | ||
+ | |||
+ | break; | ||
+ | case 3: | ||
+ | |||
+ | break; | ||
+ | case 4: | ||
+ | |||
+ | break; | ||
+ | } | ||
} | } | ||
</script><canvas width="640" height="360" tabindex="0" id="__processing0" style="image-rendering: -webkit-optimize-contrast !important;"></canvas> | </script><canvas width="640" height="360" tabindex="0" id="__processing0" style="image-rendering: -webkit-optimize-contrast !important;"></canvas> | ||
Line 287: | Line 873: | ||
</div> | </div> | ||
</div> | </div> | ||
- | |||
- | |||
- | |||
</div> | </div> | ||
Line 296: | Line 879: | ||
<script src="./Clock Examples Processing.org_files/processing.js" type="text/javascript"></script> | <script src="./Clock Examples Processing.org_files/processing.js" type="text/javascript"></script> | ||
<script src="./Clock Examples Processing.org_files/site.js" type="text/javascript"></script> | <script src="./Clock Examples Processing.org_files/site.js" type="text/javascript"></script> | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | + | </body></html> |
Revision as of 19:38, 17 July 2014
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">