Computer Science Canada Why are the players speeding up when shooting? |
Author: | STLearning [ Sat Jun 12, 2010 2:03 pm ] | ||
Post subject: | Why are the players speeding up when shooting? | ||
What is it you are trying to achieve? I am trying to ensure speeds stay the same even if they are shooting. What is the problem you are having? When the opposing player shoots, the other player slows down. However when the player shoots and moves at the same time, they go incredibly fast. When both players are shooting at the same time, and moving as well, it seems to go back to normal speeds. Describe what you have tried to solve this problem I've tried tinkering with delays and just about everything I could think of to make it normal, but I just can't get it right. (I also have no idea why its occurring.) I've also tried to get rid of the processes in general, since I have a feeling that is what causing the randomness, but I completely failed at figuring out a method of doing that without bugging the entire code. Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Please specify what version of Turing you are using 4.11 ![]() ![]() |
Author: | USEC_OFFICER [ Sat Jun 12, 2010 2:06 pm ] |
Post subject: | RE:Why are the players speeding up when shooing? |
It may have something to do with the fact the processes are messy. Having two processes run at the same time does not mean that they will run the same number of times. Try to redo your program without processes. |
Author: | STLearning [ Sat Jun 12, 2010 2:09 pm ] |
Post subject: | RE:Why are the players speeding up when shooting? |
Ah, could I please get a hint of how to do that? I've tried leading the two movement procedures into each other, but it completely messes up the shooting code =/ |
Author: | USEC_OFFICER [ Sat Jun 12, 2010 2:14 pm ] |
Post subject: | RE:Why are the players speeding up when shooting? |
Frankly, the easiest way would be to move all the movement-related code into the main loop. |
Author: | Unnamed.t [ Sat Jun 12, 2010 9:23 pm ] |
Post subject: | Re: Why are the players speeding up when shooting? |
My suggestion is to change your two body procs. I'm not entirely sure, but rather than having a separate if structure for each input (e.g. KEY_UP_ARROW) use elsif to merge everything in one control flow statement. This should help the shooting and moving coordination a great deal. Even though this may help, still experiencing minor problems like having an increase of speed randomly should be expected because of the weak capabilities Turing has. |
Author: | Cezna [ Sun Jun 13, 2010 9:31 am ] | ||||
Post subject: | RE:Why are the players speeding up when shooting? | ||||
I would recommend that instead of using:
You use:
This will ensure similar performance across computers with varying speeds. For an explanation of how Time.DelaySinceLast works, you can click on the word in the code box above. Also, I would recommend avoiding processes, as they are inherently unpredictable and random in Turing. |
Author: | Kharybdis [ Mon Jun 14, 2010 8:34 am ] |
Post subject: | RE:Why are the players speeding up when shooting? |
It has to do with frame rate and memory usage, if you want to get really technical about it ![]() |
Author: | USEC_OFFICER [ Mon Jun 14, 2010 12:00 pm ] |
Post subject: | RE:Why are the players speeding up when shooting? |
Which is a result of using Turing Processes. So don't use them. |
Author: | chrisbrown [ Mon Jun 14, 2010 12:47 pm ] |
Post subject: | Re: Why are the players speeding up when shooting? |
Unnamed.t @ Sat Jun 12, 2010 9:23 pm wrote: still experiencing minor problems like having an increase of speed randomly should be expected because of the weak capabilities Turing has.
So very untrue. Turing may have its flaws, but it does exactly what it is instructed to do. "Unexpected behaviour" invariably stems from the assumptions, oversights, faulty logic and/or inexperience of the programmer. |
Author: | andrew. [ Mon Jun 14, 2010 6:18 pm ] | ||
Post subject: | RE:Why are the players speeding up when shooting? | ||
The problem in your code is that you're using processes. NEVER use processes. Instead, make them procedures and call them from within your loop. e.g.
This may not be exactly how you want to do it, but it's a general outline of how the main loop in a game works. Oh and if you're wondering how it does 2 things at once, well, it doesn't. The computer processes it so fast that it appears to do it at once. I hope this clears up your problem. |