Computer Science Canada Time.Elapsed vs process |
Author: | CyberStorm [ Wed May 04, 2011 4:14 pm ] | ||
Post subject: | Time.Elapsed vs process | ||
What is it you are trying to achieve? i am making a target practice game, and i got stuck on how to make the reload and fire rate delays work without stopping the whole program by using a regular delay statement What is the problem you are having? i have read many discouraging things about using processes, and i cant seem to figure out how to use Time.Elapsed statement, i wonder if there is a tutorial on how to use it in different situations... so my question is: how do i make the timing work without using processes? or is using processes not a big problem in this case and then is there a way to fix the simultaneous execution of both processes glitch in the game? Describe what you have tried to solve this problem i tried using processes for the fire rate and the reload, but they go weird if they are both running at the same time, which is achieved by holding down fire button while the gun reloads Post any relevant code
|
Author: | Raknarg [ Wed May 04, 2011 4:23 pm ] | ||
Post subject: | RE:Time.Elapsed vs process | ||
Simply use a counter. Every time the program runs throught the loop, add one to the counter. When the counter reaches a certain point, you give the the ability to shoot. WHen they shoot, reset the counter. So you could have something like this:
|
Author: | CyberStorm [ Wed May 04, 2011 5:17 pm ] | ||
Post subject: | Re: Time.Elapsed vs process | ||
so now i have this, but the problem is that when ammo goes down to 0, it reloads like it supposed to, but when i press the "R" button to manually reload, it disables your ability to shoot, but does not reset the ammo nor gives you back the ability to shoot after the set period of time
|