Making nicer button behaviors on trivia game

So I've managed to put together a basic trivia game. Having some trouble getting the buttons to work just how I want them, hoping some fresh perspective will help.

Ideally, when an answer is selected, if it is the correct one, turn the button green and the rest red for one second before changing the question/answers, if wrong, turn the correct one green and the rest red, just the same. This doesn't seem like it should be too difficult, but the things that seemed obvious to me aren't cutting it.

For awhile, I was having a lot of trouble with selecting an answer, and then when the game goes to select the next question, it would quickly flash up the color green on the correct one before going back to inactive gray, which totally gives away the answer. After a good bit of finagling, I got it to stop doing that after completely rebuilding the game, and have it depending on how I have it clicked.

Problem -
If I set it to 'when touch is pressed', it only brings up the color on the button clicked for as long as it is clicked, regardless of timers saying to keep it there for a full second.

If I set it to 'when touch released', it keeps it there for a full second, but then when it changes, it still has the color on it when the question changes, giving away the answer on the next question.

If using the 'mouse' commands, if I make it use 'when mouse button is up', it looks really nice, all of the buttons light up when you click, and everything seems to work swimmingly... until you realize that if you click anywhere else on the screen, it will throw up the answers and not actually select any of them.

Right now it's parked on just lighting the button up as long as your finger is on it, which would not be a tragedy, but it's not my first choice.

My favorite thing would be to have it all light up like the 'when touch released' rule is being used, but have it only work when you hit the buttons, but I would not be upset to settle for just the answer selected lighting up green or red as appropriate.

Also - this is the first time I've ever made a trivia game, and I haven't seen any of the templates anyone else has used, but have read a bit about them. I have a table that copies into a blank at the beginning, and then after the question is answered, it turns that table row[question#] col1 to 0 (so it doesn't repeat the questions). Then I have a timer ever .01 second checking that the currentquestion it's on does not =0, and if it does, roll it again. I've noticed that when my table was still small, or if I wasn't regulating the round length, after awhile it would start hitting 0s more often, then flipping through things until it found one that was not 0. Is this what is to be expected, or am I doing something wrong? My table will be pretty big by the time I'm done, and round lengths will be set to not get anywhere close to how many are on the table, so it may not matter by the time it's done. Just want to see if I'm doing something blatantly wrong that anyone might notice.

And about my tables - I had my first one set up to have the question in col1, answers in 2-5, then the correct answer in 6 in the form of the number of the column containing the correct answer. At the time, I was having trouble with things not changing reliably (likely fixed when I deleted the repeat questions), so I changed column 6 to text answers instead of the index indicating the column of the correct answer. Is there one way that is preferred over the other? Are text attributes heavier on resources, or is that alright?


Comments

  • EverwildEverwild Member Posts: 48
    Never mind about the buttons. Got it to work smooth with an extra boolean.

    Questions about the tables still stand though.
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    I don't know about resource but I would put the column number for the correct answer in column 6 and not the text version of the correct answer.
  • EverwildEverwild Member Posts: 48
    Any particular reason other than just the ease of plugging it in there?

    When I had it like that, it would occasionally spazz out and would change the correctanswer# and the currentquestion#, but would for some reason not change the question text or the text on the answer button reliably, so you'd get wrong answers on things that should have been correct, though those texts were constrained to columns and rows indicated by the currentquestion attribute. It was intermittent, but happened more often when a question was repeated, that was the only thing happening at the time I could attribute it to. That was before I shelved my first version and completely rebuilt it.

    Wondering if there are solid benefits of one over the other. Before I go making vast tables, then finding out I should have done the other thing. Even if it worked fine the way I have it, knowing that I should have done it the other way would drive me nuts, until I eventually gave in and went back and fixed it. Fixing spreadsheets... could be all there is to Hell, and it would still be just as scary.
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    No reason other than it's tidier and easier to manage. If you need to change a typo in one of the 4 options you don't need to also change the answer column when it's a number. I would imagine the code would be tidier too, but that's just a guess.

    There shouldn't be any reason for your game to act differently between a text value in that column or an integer, but if you're finding the text version is working, and the number version isn't then stick with text.
Sign In or Register to comment.