We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello Everyone. I'm new to the course. My processing experience is limited and I need your help.
Here's what I want to do:
It is a simple game-type app, the user will have 2 options to answer a question. It will have 5 questions.
So here are my specs:
SCREEN 1 Splash screen, it will have a START button that will take you to SCREEN 2.
SCREEN 2 Instructions, it will have a CONTINUE button that will take you to SCREEN 3.
SCREEN 3 Question 1, once it is answered you will see SCREEN 4
SCREEN 4 Question 2, once it is answered you will see SCREEN 5
SCREEN 5 Question 3, once it is answered you will see SCREEN 6
SCREEN 6 Question 4, once it is answered you will see SCREEN 7
SCREEN 7 Question 5, once it is answered you will see SCREEN 8
SCREEN 8 Score
Each question will have 2 answers, one is correct, one is wrong. User will select the proper answer with the Arrow Keys.
Each question will have 3 seconds to be answered. I want the score of each question to depend on the time it takes to answer it. ie. A correct answer will have a full value of 100 points, but every second it will loose 33 points. If user spends more than 3 seconds only 1 point will be awarded.
SCREEN 8 will show the score of each question and a total score.
My problems:
So far, I've only done single screen applications. I know how to set up a button and give actions to it using the
//Define my background image variable
PImage StartUpBack;
void setup(){
//Screen Size
size(1280,720);
//Background Color
background(255);
//Background Image
StartUpBack = loadImage("StartUpBack.png");
}
void draw() {
//Can I have my mouseClicked function inside of draw? if so, I think I can make a single function with all my screens, since I hace a linear sequence.
}
//in the mouseClicked I was planning to give the START and CONTINUE buttons their functionality, but how can I chance //position of buttons depending on the screen I'm looking at?
void mouseClicked() {
}
}
Imagine this app as a more interactive power point presentation or what Macromedia Director used to be....
I will share the code once I have it ready.
Answers
google:
state site:processing.org
or
states site:processing.org
This should get you started : )
Thanks _Vk, I found a post regarding the best practices of the States, but then I go to the glossary and can't find any information regarding StartState or SetState.
I played a little bit with the code. I tried the noLoop() and loop() functions without success, I also tried changing the frame rate to 0 to pause, I thought that the mouseClicked could change it back to 60 frames per second and then change it again to 0 inside draw to pause it, didn't work.
Can I create each question as a separate processing sketch and then create one sketch to call them in sequence?
That post has a very specific question and approach. Try this instead
http://forum.processing.org/two/discussion/comment/27641#Comment_27641
Those are functions defined by the author...
Perhaps this online example can give ya some ideas too:
http://studio.processingtogether.com/sp/pad/export/ro.9eDRvB4LRmLrr/latest
Thanks a lot _VK, it is defenitely looking better....
I use the N key to jump from the Splash screen to the first question, I use the arrow keys to answer the first question but then, when I click N again, it does not move to question 2, I'm looking into this, Once I get it fixed I will work on the score. Thanks a lot.
GoToLoop thanks for the button examples. I'll see if I can implement them.
I just found a new problem to the way I have my code at this point... one the user clicks on the right or left keys to choose an answer, they can still change their answer afterwards, is there a way to kill the second option once the answer has been chosen?
Thanks!
After doing some clean up on the brackets I was able to make it work. The difference between the code below and the one I posted before is that
case 0 is my splash page (as before) case 1 is my question 1 case 2 instead of it being my question 2 as it used to, now it is the answer screen if Left case 3 answer screen if right case 4 question 2....I will complete the rest.
now, I need help with my score. I want to give the user 5 seconds to answer, each second the user will loose 4 points, so, if the user answers right away, 20 points will be awarded, if all 5 seconds have passed I want to give them 1 point, leaving 0 points only for wrong answers.
What can I use to count time?
I'm looking at millis() but how can I count how much time it passes from the moment the screen is displayed until the user answers?
Thanks in advance.