Changes

Jump to: navigation, search

QFunction

1,109 bytes added, 09:12, 2 February 2018
Beispiel Code
var frameSetup = 0;
var bgc = 50;// backGroundColorvar mouseT = 0;var w = 384;var h = 640;// mouseTimeer
// var cList = [ [0,0,0], [0,0,0,0], [0,0,0,0] ]; // Checkbox-List - one can pre select here var cList = [ [undefined,undefined,undefined], [undefined,undefined,undefined,undefined], [undefined,undefined,undefined,undefined] ]; // Checkbox-List - one can pre select here var qList = [0,0,0];// Guestion-Vale-List var mouseUp = 0;
function setup() {
createCanvas(384, 640);
}
function draw() {
if( fullscreen() ){
if(frame == 0){
frame = 1;
}
}
background(bgc);
 
// Frame Conter Display
textSize(18);
text(frame, 10, 20);
textAlign(RIGHT);
text(cList, width - 10, 20);
text(qList, 150, 20);
 
if (frame == 1) {
if (frameSetup == 0) {
frameSetup = 1;
bgc = 100;
}
qBox(width/2, 30, 1, "Hallo was ist deine ganz", "persoehnliche Lieblingsfarbe", "an diesem Tag?");
cBox(width/2, 150, 1, 1, -2, "Wegen des Wetters mage ich ", "an heute ein tristes Grau.");
cBox(width/2, 200, 1, 2, 1, "Meine liblingsfabe ist Blau.", "");
cBox(width/2, 250, 1, 3, 3, "Ich mage heute Rot!", "");
qButton(1, 1);
}
 
if (frame == 2) {
if (frameSetup == 0) {
frameSetup = 1;
bgc = 120;
}
qBox(width/2, 30, 2, "Wie wuerdest Du deine Tages-", "Stimmung bezeichnen?", "");
cBox(width/2, 150, 2, 1, 1, "Ganz ok", "");
cBox(width/2, 200, 2, 2, 3, "Super!", "");
cBox(width/2, 250, 2, 3, 0, "So mittel...", "");
cBox(width/2, 300, 2, 4, -2, "Mir geht es heute nicht", "so gut.");
qButton(2, 1);
}
 
if (frame == 3) {
if (frameSetup == 0) {
frameSetup = 1;
bgc = 100;
}
qBox(width/2, 30, 3, "Hast Du gut geschlafen?", "", "");
cBox(width/2, 150, 3, 1, 2, "Ja", "");
cBox(width/2, 200, 3, 2, -2, "Nein", "");
cBox(width/2, 250, 3, 3, -3, "Ich konnte nicht schlafen", "");
cBox(width/2, 300, 3, 4, 3, "Ich habe mich gut ", "ausgeschlafen");
qButton(3, 1);
}
 
if (frame == 4) {
if (frameSetup == 0) {
frameSetup = 1;
bgc = 100;
}
textAlign(CENTER);
text("Emotionswert Frabe: " + qList[0], width / 2, 150);
text("Emotionswert Tagesstimmung: " + qList[1], width / 2, 200);
text("Emotionswert Schlaf: " + qList[2], width / 2, 250);
}
 
if (frame == 0) {
background(bgc);
textAlign(CENTER);
textSize(40);
text("Start-Screen", width / 2, height / 2);
 
} else {
// qButton(1, 1);
}
}
// x-Position, y-Position, Qusetion-Nr, Checkbox-Number, Answer-Value, Text-1-Line, Text-3-Linefunction cBox(cX, cY, qN, cN, cA, cT1, cT2){
if( (mouseIsPressed)&&(mouseUp == 0) ){
if( (mouseX>cX-150)&&(mouseX<cX+150)&&(mouseY>cY)&&(mouseY<cY+40) ){
mouseUp = 1;
if(cList[qN-1][cN-1] == 0undefined){ cList[qN-1][cN-1] = 1cA;
}else{
cList[qN-1][cN-1] = 0undefined;
}
}
}
 
if(mouseIsPressed == false){
noFill();
ellipse(cX - 130, cY+20, 25, 25);
if(cList[qN-1][cN-1] !== 1undefined){
fill(20);
ellipse(cX - 130, cY+20, 15, 15);
}
} // Evaluation  function draw() { qList[qN-1] = 0; iffor( fullscreen() var f=0; f<=cList.length; f++){ if(frame =cList[qN-1][f] != 0undefined){ frame qList[qN-1] = qList[qN-1] + cList[qN-1][f];
}
}
background(bgc);
// Frame Conter Display textSize(18); text(frame, 10, 20); fill(200); rect(0, height - 150, width, 150);}
// Guestion-Number, Minimum-Selectionfunction qButton(qN, qType){ if (frame (mouseIsPressed)&&(mouseUp == 10) ) { mouseUp = 1; if (frameSetup =(mouseY >= height - 150) && (frame > 0) && (frame <= 3)) { frameSetup var count = 0; for(var f=0; f<=cList.length; f++){ if(cList[qN-1][f] != undefined){ count = count + 1; } bgc } if(count > qType - 1){ frame = 100frame + 1; frameSetup = 0; }
}
qBox(width/2, 30, 1, "Hallo was ist deine ganz", "persoehnliche Lieblingsfarbe", "an diesem Tag?");
cBox(width/2, 150, 1, "Wegen des Wetters mage ich ", "an heute ein tristes Grau.");
cBox(width/2, 200, 2, "Meine liblingsfabe ist Blau.", "");
cBox(width/2, 250, 3, "Ich mage heute Rot!", "");
}
if fill(frame == 2200) { if (frameSetup == 0) { frameSetup = 1; bgc = 120; } qBox rect(width/210, 30, 2, "Wie wuerdest Du deine Tagesheight -"150, "Stimmung bezeichnen?", ""); cBox(width/2-20, 150-10, 4, "Ganz ok", ""20); cBox(width/2, 200, 5, "Super!", ""); cBox(width/2, 250, 6, "So mittel...", ""); cBox(width/2, 300, 7, "Mir geht es heute nicht", "so gut."); }
if (frame == 3) {
if (frameSetup == 0) {
frameSetup = 1;
bgc = 100;
}
qBox(width/2, 30, 3, "Hast Du gut geschlafen?", "", "");
cBox(width/2, 150, 8, "Ja", "");
cBox(width/2, 200, 9, "Nein", "");
cBox(width/2, 250, 10, "Ich konnte nicht schlafen", "");
cBox(width/2, 300, 11, "Ich habe mich gut ", "ausgeschlafen");
}
 
if (frame == 4) {
if (frameSetup == 0) {
frameSetup = 1;
bgc = 100;
}
text("Answer_A_1: " + Answer_A_1, w / 2, h / 2);
}
 
if (frame == 0) {
background(bgc);
textAlign(CENTER);
textSize(40);
text("Start-Screen", w / 2, h / 2);
 
} else {
nextButton();
}
}
 
function nextButton() {
textAlign(CENTER);
textSize(40);
fill(200);
noStroke();
// rect(0, height - 150, width, 150);
fill(0);
text("NEXT", w width / 2, h height - 75); 
}
function mousePressed() {
if (millis() > mouseT + 1000) {
mouseT = millis();
if ((mouseY >= height - 150) && (frame > 0) && (frame <= 3)) {
mouseT = millis();
frame = frame + 1;
frameSetup = 0;
}
}
if (frame == 0) {
fullscreen(true1);
}

Navigation menu