Computer Science Canada Space invaders - speed of enemies |
Author: | chipanpriest [ Thu Dec 29, 2011 1:59 pm ] |
Post subject: | Space invaders - speed of enemies |
Hey I was wondering if there is a way to make the enemies move down slower without having a delay in the game ![]() |
Author: | Aange10 [ Thu Dec 29, 2011 2:05 pm ] |
Post subject: | RE:Space invaders - speed of enemies |
A: You can lower their velocity. B: You can setup a timer. C: You could delay it but that'd be stupid. (However in this case, you should delay it to at least 60FPS ... Time.DelaySinceLast (17) |
Author: | chipanpriest [ Thu Dec 29, 2011 5:04 pm ] |
Post subject: | RE:Space invaders - speed of enemies |
So Time.DelaySinceLast is just a better version of delay?? cause ive always used delay before |
Author: | Aange10 [ Thu Dec 29, 2011 5:43 pm ] |
Post subject: | RE:Space invaders - speed of enemies |
Yes, read up on this post: http://compsci.ca/v3/viewtopic.php?t=30297 |
Author: | Dreadnought [ Thu Dec 29, 2011 7:57 pm ] | ||||
Post subject: | Re: Space invaders - speed of enemies | ||||
Time.DelaySinceLast is really useful in the common situation where you would like to regulate the frequency of a loop's repetition. But it shouldn't be a direct substitute for delay, since it does not really do what delay does. Take this example:
The "second delay" is almost non-existent. So the word "Done!" might not be seen by the user. However, using Time.Delay (2000) would have made a 2 second delay each time. The functionality is not identical. I doubt you would actually use this procedure in such a way, but I just wanted to clarify that although it is often more useful than delay, it should not be seen as a direct substitute. As a side note, you could actually implement it yourself if you wanted to. This is the code for Time.DelaySinceLast taken directly from the code for the Time module:
|
Author: | chipanpriest [ Fri Dec 30, 2011 10:52 am ] | ||
Post subject: | Re: Space invaders - speed of enemies | ||
This is another, kind of separate question but based on the same idea. Could i not do something like:
Would this work? And if so, could I somehow make it so it would move down every 5000 milliseconds without doing the code above multiple times? |
Author: | Aange10 [ Fri Dec 30, 2011 12:03 pm ] |
Post subject: | Re: Space invaders - speed of enemies |
Indeed, here is an example of a timer. |
Author: | chipanpriest [ Fri Dec 30, 2011 4:24 pm ] | ||
Post subject: | Re: Space invaders - speed of enemies | ||
But what I'm trying to say is, is there a way to make something happen in intervals with only one set of code? For example, It would be a pain to do this:
Would there be a way to make it so the y value decreases every 5000 milliseconds in just one set of code instead of doing that^? |
Author: | Aange10 [ Fri Dec 30, 2011 5:08 pm ] | ||
Post subject: | RE:Space invaders - speed of enemies | ||
Mhm.....
Now ever 5 seconds it moves down... Just like the code in the thing I uploaded. You could hard code it all if you wanted, but whats the point? |
Author: | chipanpriest [ Fri Dec 30, 2011 5:09 pm ] |
Post subject: | RE:Space invaders - speed of enemies |
yea i got it thanks ![]() |