Author |
Message |
chipanpriest

|
Posted: 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 thanks
Description: |
|
 Download |
Filename: |
Space Invaders.t |
Filesize: |
2.33 KB |
Downloaded: |
128 Time(s) |
Description: |
|
 Download |
Filename: |
Space Invaders.t |
Filesize: |
2.33 KB |
Downloaded: |
87 Time(s) |
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Aange10

|
Posted: 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)
|
|
|
|
|
 |
chipanpriest

|
Posted: 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
|
|
|
|
|
 |
Aange10

|
|
|
|
 |
Dreadnought
|
Posted: 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:
|
|
|
|
|
 |
chipanpriest

|
Posted: 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:
Turing: | var t : int := Time.Elapsed
if t = 5000 then
Ey - = 20 %first row of enemies moving down
Ey2 - = 20 %second row of enemies moving down
end if
|
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?
|
|
|
|
|
 |
Aange10

|
Posted: Fri Dec 30, 2011 12:03 pm Post subject: Re: Space invaders - speed of enemies |
|
|
Indeed, here is an example of a timer.
Description: |
|
 Download |
Filename: |
Reseting Time.T |
Filesize: |
495 Bytes |
Downloaded: |
65 Time(s) |
|
|
|
|
|
 |
chipanpriest

|
Posted: 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^?
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Aange10

|
Posted: 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?
|
|
|
|
|
 |
chipanpriest

|
Posted: Fri Dec 30, 2011 5:09 pm Post subject: RE:Space invaders - speed of enemies |
|
|
yea i got it thanks Ima upload it soon
|
|
|
|
|
 |
|