Hidden Timer In A Sketch
Hi there! I'm a newbie at Processing, so please bear with me if I'm asking something that's painfully obvious.
I'm creating a game where, once the player first clicks on the screen, a hidden timer begins counting down how long it takes them to reach 87 or so clicks (every time the player clicks a different message appears to them on screen as the "game tutorial" taunts them). Once they reach the last click, the timer stops and the player is presented with how long it took them to reach the end.
My two questions are 1) how do I go about actually creating the timer, and 2) how would I fit it into my code? Below is what I have so far, and what I'm guessing is that I would need to make another array for the timer to put into mouseClicked.
Here's my code so far, including all of the terrible humor within it:
- int r, g, b;
- int fontSize = 25;
- int textIndex = 0;
- String[] theGodOfTheGame = {
- "\n\n [CLICK TO CONTINUE]",
- "Welcome to the game.\n You will now be taught how to play. \n\n [CLICK TO CONTINUE]",
- "In this game, you will click the mouse button to allow yourself to proceed through the game space. \n\n [CLICK TO CONTINUE]",
- "You will be timed on how long it takes you to travel through this space. \n\n [CLICK TO CONTINUE]",
- "Once you have reached your destination you will be informed as to how long it took you to reach it.\n\n [CLICK TO CONTINUE]",
- "To reach the end of the space you will need to continue clicking the mouse button.\n\n [CLICK TO CONTINUE]",
- "Oh, whoops, wait, we already said that you needed to click to proceed through the game space, didn't we?\n\n [CLICK TO CONTINUE]",
- "Nevermind. Sometimes it helps to repeat information.\n\n [CLICK TO CONTINUE]",
- "That way it's harder to forget what you should be doing.\n\n [CLICK TO CONTINUE]",
- "See? You've continued clicking! You didn't forget the controls yet. Good for you.\n\n [CLICK TO CONTINUE]",
- "Then again, by now clicking is becoming a rote action for you, huh?\n\n [CLICK TO CONTINUE]",
- "We'll take off the training wheels (i.e., the prompt at the bottom) and we'll see if you can continue to grasp the concept of clicking.\n\n [CLICK TO CONTINUE]",
- "There we go.",
- "Good job!",
- "Keep going!",
- "While you're playing the game,it will be important to continue clicking like this.",
- "The faster you complete the game, the happier you will be when you reach the end.",
- "You will be rewarded with many points.",
- "Oh so many points.",
- "And points are good!",
- "By the way, it takes the average player at least 1 minute and 46 seconds to complete this game.",
- "That's actually a pretty impressive time.",
- "Do you think you will be able to beat it?",
- "Is there anything else we're forgetting to tell you before you start?",
- "Hang on... uh...",
- "Okay, well, there is one more thing.",
- "If you click faster or slower during the game, you will gain or lose points.",
- "Easy to understand, right?",
- "Let's try it. \n \n Try continuously clicking very, very fast.",
- "Come on!",
- "Keep going!",
- "KEEP GOING!",
- "WHAT IS WRONG WITH YOU?!",
- "GO FASTER!",
- "YOU AREN'T GOING FAST ENOUGH!",
- "COME ON YOU WEAKLING",
- "DID YOUR FINGER ATROPHY OR WHAT?!",
- "GO!",
- "GO!!!!!!!",
- "GO!!!!!!!!!!!!!",
- "OKAY THAT'S ENOUGH!",
- "STOP!",
- "STOP!!!!!",
- "STOP!!!!!!!!",
- "Very good!",
- "See, when you click fast like that in the game, you will gain tons of points.",
- "Okay. Well.",
- "It seems like we've told you everything you need to know for you to continue through the game. \n\nThe tutorial is over.",
- "Good luck! \n\n[CLICK TO CONTINUE]",
- "",
- "",
- "",
- "",
- "",
- "Still here, huh?",
- "That's good.",
- "We're glad that you are continuing to follow the instructions we gave you.",
- "But is it REALLY worth it right now?",
- "Why are you still clicking?",
- "We thought that you would had thought that the game had broken.",
- "Well it has.",
- "It's broken.",
- "Bummer, isn't it?",
- "Guess you won't be able to play it.",
- "You should probably restart the game and redo the tutorial.",
- "Why are you still clicking, damnit?!",
- "You don't have to keep going, you know.",
- "Everyone else who found out that the game broke didn't keep clicking.",
- "No one ever just keeps going forward.",
- "You don't have to keep going about this so... linearly.",
- "What is wrong with you?",
- "Man, are you stupid or what?",
- "...or maybe...",
- "Maybe you aren't.",
- "Maybe you've wised up.",
- "Maybe now you understand the point to all of this clicking.",
- "You're a tough egg to crack.",
- "It would be nice if we could see your reaction.",
- "And see if you're getting frustrated or finally understanding the point.",
- "Of course, we lied about the game being broken.",
- "If you hadn't already figured it out, you genius, you.",
- "But that's the only thing we lied about.",
- "You HAVE been traveling through the game space.",
- "You HAVE been timed on how long it's taken.",
- "And you will recieve your points soon.",
- "We hope you got a lot.",
- "We're going to miss you."
- };
- void setup() {
- size(800,800);
- PFont font;
- font = loadFont("04b-30-48.vlw");
- textFont(font, fontSize);
- }
- void draw() {
- background(80);
- textAlign(CENTER);
- text(theGodOfTheGame[textIndex], 10, width/3, width-20, 500);
- fill(r, g, b);
- }
- void mouseClicked() {
- if (textIndex >= 38 && textIndex <= 41) {
- r = 255;
- g = 0;
- b = 0;
- }
- else {
- r = 200;
- g = 200;
- b = 200;
- }
- textIndex = textIndex + 1;
- if (textIndex >= 87) {
- textIndex = 0;
- //Instead of looping back to the first string in the testIndex array like I have written here, this is where I would like the timer to stop and display how long it took to reach the 87th click.
- }
- }
