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">
-
<!-- saved from url=(0046)https://www.processing.org/examples/clock.html -->
 
<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>Clock \ Examples \ Processing.org</title>
+
<title>The game: iGEM TU/e</title>
-
+
-
<link rel="icon" href="https://www.processing.org/favicon.ico" type="image/x-icon">
+
-
+
-
+
-
<meta name="Author" content="Casey Reas &amp; Ben Fry">
+
-
<meta name="Publisher" content="Processing">
+
-
<meta name="Keywords" content="Processing, Processing, Interactive Media, Electronic Arts, Programming, Java, Ben Fry, Casey Reas">
+
-
<meta name="Description" content="Processing is an electronic sketchbook for developing
+
-
ideas. It is a context for learning fundamentals of computer programming
+
-
within the context of the electronic arts.">
+
-
<meta name="Copyright" content="All contents copyright Ben Fry, Casey Reas, MIT Media Laboratory">
+
     
     
    <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">
-
<style type="text/css">@font-face {
+
</head>
-
  font-family: "PjsEmptyFont";
+
-
  src: url('data:application/x-font-ttf;base64,AAEAAAAKAIAAAwAgT1MvMgAAAAAAAAEoAAAAVmNtYXAAAAAAAAABiAAAACxnbHlmAAAAAAAAAbwAAAAkaGVhZAAAAAAAAACsAAAAOGhoZWEAAAAAAAAA5AAAACRobXR4AAAAAAAAAYAAAAAGbG9jYQAAAAAAAAG0AAAABm1heHAAAAAAAAABCAAAACBuYW1lAAAAAAAAAeAAAAAgcG9zdAAAAAAAAAIAAAAAEAABAAAAAQAAAkgTY18PPPUACwAgAAAAALSRooAAAAAAyld0xgAAAAAAAQABAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAAACAAIAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACMAIwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAMAAQAAAAwABAAgAAAABAAEAAEAAABB//8AAABB////wAABAAAAAAAAAAgAEgAAAAEAAAAAAAAAAAAAAAAxAAABAAAAAAABAAEAAQAAMTcBAQAAAAAAAgAeAAMAAQQJAAEAAAAAAAMAAQQJAAIAAgAAAAAAAQAAAAAAAAAAAAAAAAAA')
+
-
      format('truetype');
+
-
}</style><style type="text/css"></style></head>
+
<body id="Examples" onload="">
<body id="Examples" onload="">
-
 
-
<!-- ==================================== PAGE ============================ -->
 
-
<div id="container">
 
-
 
-
<!-- ==================================== HEADER ============================ --><a id="TOP" name="TOP"></a>
 
-
 
-
<!-- ==================================== NAVIGATION ============================ -->
 
-
 
-
 
-
<!-- ==================================== CONTENT ============================ -->
 
-
<div class="content">
 
-
  <p class="ref-notice">&nbsp;</p>
 
-
 
<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;
-
PImage img;  // Declare variable "a" of type PImage
 
-
void setup() {
+
void setup(){
-
   size(640, 360);
+
   size(1000, 800);
-
  //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);
    
    
-
   // The image file must be in the data folder of the current sketch
+
    
-
   // to load successfully
+
    
-
  img = loadImage("http://i.imgur.com/wyzfNAg.jpg");  // Load the image into the program 
+
}
}
-
void draw() {
+
void draw(){
-
   // Displays the image at its actual size at point (0,0)
+
  image(background, 0,0, width, height);
-
   image(img, mouseX, mouseY);
+
   //background(0);
-
   // Displays the image at point (0, height/2) at half of its size
+
  fill(200, 50, 50, 200);
-
   image(img, 0, height/2, img.width/2, img.height/2);
+
  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 id="footer">
 
-
    <div id="copyright"></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>
-
 
-
<script type="text/javascript">
 
-
 
-
  var _gaq = _gaq || [];
 
-
  _gaq.push(['_setAccount', 'UA-40016511-1']);
 
-
  _gaq.push(['_setDomainName', 'processing.org']);
 
-
  _gaq.push(['_trackPageview']);
 
-
 
-
  (function() {
 
-
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
 
-
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
 
-
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
 
-
  })();
 
-
 
-
</script>
 
-
<span style="position: absolute; top: 0px; left: 0px; opacity: 0; font-family: PjsEmptyFont, fantasy;">AAAAAAAA</span></body></html>
+
</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"> The game: iGEM TU/e

Retrieved from "http://2014.igem.org/Team:TU_Eindhoven/the_game"