Developing a timer
Blitz3D Forums/Blitz3D Beginners Area/Developing a timer
| ||
Hey guys I have a little delimma and I haven't made any timers in Blitz before.In my FPS I have an enemy who is going to attack the player once he gets soo close, obviously. But I want to add time between the players health drains. Soo I was thinking is it possible to make a timer, maybe one that uses the frame rate or something to put in the delay between health drains?? |
| ||
Yes, you can do it several ways. I wouldn't use the framerate as a 'timer' though since everyones computers run at different frame rates. Just use the MilliSecs() command. draintimer = MilliSecs() + 1000 ;1 second . . . If MilliSecs() > draintimer Then ;do your drain health thing again |
| ||
Simple usage DamageTimer.ticker = ticker_Create( 1000 ) If ticker_HasTicked( DamageTimer ) Then DrainHealth() |
| ||
Jams your confusing me just a little, soo could you give me a little more indepth breakdown of the timer system?? -Also the enemy going twords the user is becoming a little frustrating to me as well here's some of my coding insight = EntityVisible(enemy\model,user\model) If insight = 1 And EntityDistance#(enemy\model,user\model) < 20 And crouch = 0 PointEntity enemy\model,playerhead follow() EndIf If enemy\health <= 0 HideEntity enemy\model EndIf Oh and the Follow function Function Follow() If EntityX#(user\model) > EntityX#(enemy\model) MoveEntity enemy\model,.03,0,0 ElseIf EntityZ#(user\model) > EntityZ#(enemy\model) MoveEntity enemy\model,0,0,.03 ElseIf EntityX#(user\model) < EntityX#(enemy\model) MoveEntity enemy\model,-.03,0,0 ElseIf EntityZ#(user\model) < EntityZ#(enemy\model) MoveEntity enemy\model,0,0,-.03 EndIf End Function Any help will be greatly appreciated!! |
| ||
Check the render loop, this may help: |