Here I use Processing for programming. Take every question as a 2 branch tree, store the question and answers in the Array, and do some controller work after every mouse click.
The following is the main code for it:
String questions[] = {"Is one part of your body wider than another?",
"Is your stomach your widest part?",
"Do you have a clearly defined waist?",
"Is your waist long and sweeping?",
"Are you tall and slender?",
"Are you a plus size?",
"Is your bottom half your widest part?",
"Do you have a short waist?",
"Do you have saddlebags?",
"Is your top half your widest part?",
"Do your have big breast or soft middle?",
"Are your tall and slender?"
};
String shapes[] = {"Apple", "Brick", "Column", "Cello", "hourglass",
"Bell", "Vase", "Cornet", "Pear", "Skittle", "Lollipop", "Goblet"
};
public void mouseClicked() {
if(currentQ < 12) {
if(mouseY >= 360 || mouseY <= 380) {
if(mouseX >= 510 && mouseX <= 595) {
currentR = true;
nextQuestion();
redraw();
}
else if(mouseX >= 630 && mouseX <= 710) {
currentR = false;
nextQuestion();
redraw();
}
}
}
}
int nextQuestion() {
switch(currentQ) {
case 0:
if(currentR) {
currentQ = 1;
}
else {
currentQ = 2;
}
break;
case 1:
if(currentR) {
currentQ = 12;
shape = 0;
}
else {
currentQ = 6;
}
break;
case 2:
if(currentR) {
currentQ = 3;
}
else {
currentQ = 4;
}
break;
case 3:
if(currentR) {
currentQ = 12;
shape = 6;
}
else {
currentQ = 5;
}
break;
case 4:
if(currentR) {
currentQ = 12;
shape = 2;
}
else {
currentQ = 12;
shape = 1;
}
break;
case 5:
if(currentR) {
currentQ = 12;
shape = 3;
}
else {
currentQ = 12;
shape = 4;
}
break;
case 6:
if(currentR) {
currentQ = 7;
}
else {
currentQ = 9;
}
break;
case 7:
if(currentR) {
currentQ = 12;
shape = 5;
}
else {
currentQ = 8;
}
break;
case 8:
if(currentR) {
currentQ = 12;
shape = 8;
}
else {
currentQ = 12;
shape = 9;
}
break;
case 9:
if(currentR) {
currentQ = 10;
}
break;
case 10:
if(currentR) {
currentQ = 11;
}
else {
currentQ = 12;
shape = 7;
}
break;
case 11:
if(currentR) {
currentQ = 12;
shape = 10;
}
else {
currentQ = 12;
shape = 11;
}
break;
}
return currentQ;
}
I also add some dynamic on it which is for the magic visual effect of the mirror.
Bodyshape Quizz with the Magic Mirror |
Reference:
1. What Trinny and Susannah Body Shape Am I?(Lisa) [Online] Available from: http://bodyshapestyle.com/2011/03/11/what-trinny-and-susannah-body-shape-am-i/ [Accessed 16st May. 2012].
No comments:
Post a Comment