Computer Science Canada Help! How to Run a Timer and Other Commands at the Same Time? |
Author: | MatthewZMD [ Tue Jan 06, 2015 1:05 am ] | ||
Post subject: | Help! How to Run a Timer and Other Commands at the Same Time? | ||
What is it you are trying to achieve? I am making a game, I want to make the user click on an image for a number of times within a limited time. What is the problem you are having? I cannot make the timer and clicking image run at the same time. Describe what you have tried to solve this problem I tried to create a loop for the timer and then write the codes for clicking the button, but the program will run the timer first... I also tried to make everything into 1 loop, but the timer and the clicking button countdown decrease at the same pace... Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) <Answer Here>
Please specify what version of Turing you are using Open Turing newest version I suppose |
Author: | Tony [ Tue Jan 06, 2015 2:19 am ] | ||
Post subject: | RE:Help! How to Run a Timer and Other Commands at the Same Time? | ||
I love that you posted both of your attempts -- this is a question well asked! You are on the right path with your idea of putting both steps into a single loop. You want this loop to quickly check one of the steps, then another, then back to first. What you have getting in the way of the "quickly" part are "blocking calls" -- calling some functions that will block / wait. E.g. of something that will block a loop:
Because the loop stops and waits for a person to type in that input, asking for just one word from a 60 words-per-minute typist will make the game run no faster than 1 FPS. Unacceptable! Lucky, you can make some changes in your code: From buttonwait to Mouse.Where From delay(1000) to delay(much_smaller_number) |
Author: | MatthewZMD [ Sat Jan 10, 2015 3:43 am ] |
Post subject: | RE:Help! How to Run a Timer and Other Commands at the Same Time? |
Thank you! The problem is currently fixed now. ![]() |