News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

FPS Question

Started by Big C., March 03, 2010, 02:49:43 PM

Previous topic - Next topic

Big C.

If I set the FPS fixed at 60 (SetFPS 60) how can I recognize that 30 ticks have past so I can start a event?

kevin

 if StartOfPeriod+30
     do Something
endif

Big C.

ok... I have more to explain...

SetFPS 60 means 60 frames per second... so I want allow the player to spawn two objects per second...

Is this the right way?


SetFPS 60

time = Timer()
 
  Do
     Cls RGB(0,0,0)
     
     Print "ScreenFPS: "+Str$(GetFPS())
     
     PastTime = Timer()-Time
     Print Pasttime
      If Pasttime >= 3000
        Print "Spawn!"
      ; set the variable time to the current time
        time = Timer()
     EndIf
     
     Sync
Loop
WaitKey

kevin


  That'll work..

Why do you keep logging in/out of the forums ?

Big C.

Quote from: kevin on March 03, 2010, 03:56:09 PM

Why do you keep logging in/out of the forums ?


Sry my english is not the best.. so what are you meaning with this?

stevmjon

to big c

from your example above, you realise you are spawning once every 3 seconds.
eg.    if pasttime>=3000  (3 seconds)
try:   if pasttime>=500  (1/2 second)

using this method won't matter what the framerate is, because you are using time, not frames.

if you want to use frames to count instead of time, then use a variable that inc's each loop. when it reaches it's value then spawn.
eg.  60 frames per sec / 2 sprites per sec = 30.

  stevmjon
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

Makeii Runoru

yea something like


setfps 60

respawn_time = 0
respawn_time_max = 30

do
   inc respawn_time

   if respawn_time >= respawn_time_max
      respawn_time = 0

      //---------------------------
      // enter any event code here     
      //---------------------------

   endif

loop
This signature is boring, and could be improved. However, the user of this signature doesn't need a fancy signature because he or she doesn't really care for one.