Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Timer based movement help

Author
Message
urgent help!
15
Years of Service
User Offline
Joined: 28th Sep 2010
Location:
Posted: 28th Oct 2010 20:08
So, I have enemies the chase me with a simple move code. However I also want enemies that stay still until my timer reaches a certain number. The code im using right now looks like this if MyTimer = 1300 then:point object 17,c1,c2,c3
if MyTimer = 1300 then:move object 17,0.4 `else move object 17,0
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 28th Oct 2010 20:12
You haven't shown how you calculate 'MyTimer'. Guessing that it's simply a difference between the current time and a previously captured time from the TIMER() function, then the problm is most probably because you are looking for an exact value, which is unlikely to happen. Perhaps you should try 'MyTimer >= 1300' instead?

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
CSL
17
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: USA
Posted: 29th Oct 2010 00:10 Edited at: 29th Oct 2010 00:13
The logic I use looks like this



The rateofmovement global variable specifies how many milliseconds to wait until the enemy moves again. The lower the value, the faster it moves. The movementtimer variable records the last time the enemy moved. The currenttimer is constantly compared against these during runtime.

CSL
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 29th Oct 2010 14:15
Kind of an interesting way to do timer based movement.

Unfortunately it just works like the sync command so if your framerate drops below the desired speed your movement will also slow down. Why not just use "sync" and "sync rate"?

KISTech gives a good example of timer based movement in his "decouple the display loop" thread which allows for dips in framerate.

Login to post a reply

Server time is: 2026-07-22 04:37:10
Your offset time is: 2026-07-22 04:37:10