Can someone please sense check my logic

0 favourites
  • 4 posts
From the Asset Store
100 items casual and logic games. All icons are of a high quality.
  • Hi,

    I am making a simple quiz game for language learners to learn vocab.

    It reads a list of English words from one text file, and a list of the corresponding words in another language from another text file. Each set is placed into an array.

    The word in the foreign language is displayed

    The user is then given a choice of 4 possible answers in English (3 randomly chosen + right answer).

    Whenever they click an answer the quiz goes to the next question.

    I have it all working, except that when I add in the code to load a new question if the user selected the wrong answer, I seem to get random skipping of my questions, and the score keeping becomes erratic. If I remove that check, then there doesn't seem to be a problem.

    It seems to be that my function (DisplayQ) to display the next question seems to run more than once, but not always, and not be the same amount, sometimes it will skip 1 question, other times 2 questions.

    But I cant see for the life of me where it is going wrong - any help would be much appreciated

    http://www.filedropper.com/quiztry

  • https://www.dropbox.com/s/ill28s11g3b1f ... .capx?dl=0

    Fixed 4 things for you.

    1/ This one is just for the logic. In your case not an important one. But, when using Ajax, you should wait until all Ajax stuff is done before continuing the events. Fixed this with setting group "QUIZ".

    2/ Changed starting Qnum to - 1. Now it starts to display Qnum from zero, the array is zero based. That, or you got to rethink the moment that there is 1 added to Qnum.

    3/ Now the first question is displayed immediately (no click required) . And all texts stay invisible until Ajax is done loading for BOTH lists. It was not necessary so that first by Ajax loaded list also was the first list to be ready and usable. But loads happened at kinda the same time, and it is not really known which one is ready to use as last, and could call the display function.

    4/ The logic flaw you had. Actual your question.

    When you clicked the text field. It called the function, that function changed the rAssign value. So the next (supposed to be the opposite checking) condition got a different rAssign feeded (then the first condition).

    Solved it with a plain 'else'.

    I left the browser object in there. To show you how you can use it so eassssy to debug. You can delete it.

    Hope this helps you and learns you something.

  • [quote:2jss1dpf]1/ This one is just for the logic. In your case not an important one. But, when using Ajax, you should wait until all Ajax stuff is done before continuing the events. Fixed this with setting group "QUIZ".

    Thank you, I didn't know you could de-activate groups

    [quote:2jss1dpf]4/ The logic flaw you had. Actual your question.

    When you clicked the text field. It called the function, that function changed the rAssign value. So the next (supposed to be the opposite checking) condition got a different rAssign feeded (then the first condition).

    Solved it with a plain 'else'.

    Ah, OK I see, I did originally have an else statement in there but in a slightly different configuration, which explains why it didn't work for me. Thank you so much for this.

    [quote:2jss1dpf]Hope this helps you and learns you something.

    Yes definitely this has helped me a lot, thank you so much, you really didn't have to go to all that trouble!

    Kind Regards

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • No trouble, just happy someone shared a .capx.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)