Author Topic: TimeBeginPeriode  (Read 1955 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
TimeBeginPeriode
« on: December 03, 2015, 08:53:16 AM »
Hello
An experimental Demo
Code: [Select]
include "asm.inc"
window 640,480,1

! timeGetTime     Lib "winmm.dll" () As Long
! timeBeginPeriod Lib "winmm.dll" (long uPeriod) As Long
! timeEndPeriod   Lib "winmm.dll" (long uPeriod  As Long
! Sleep           Lib "kernel32"  (long duration) As Long

LoadSprite "bmp/e5x.bmp",5

Sub Timed(sys Interval)
timeBeginPeriod (1)   
StartTime = timeGetTime
NextFrameTime = Interval + StartTime
while timeGetTime() < NextFrameTime
  if timeGetTime()+5 < NextFrameTime then
     Sleep NextFrameTime - (timeGetTime()+5)
  end if
wend
timeEndPeriod (1)
End Sub

int z[40], x[40], y[40]
for i=0 to <40
    z[i] = rand(0,4)
    x[i] = rand(0,512)
    y[i] = rand(0,352)
next

while key(27)=0
cls 0,0,0
for i=0 to <40
    Sprite 1,x[i],y[i],128,128,z[i]
next

for i=0 to <40
    z[i] +=1
    if z[i] = 5
       z[i] = 0
       x[i] = rand(0,512)
       y[i] = rand(0,352)
    end if
next   

text 210,16,15,"FRAMES " & GetFps()

z +=1
if z=5 then z=0
redraw
'SetFps (24)
Timed (32)

wend
winEnd


.
« Last Edit: December 03, 2015, 09:00:32 AM by Peter »

Mike Lobanovsky

  • Guest
Re: TimeBeginPeriode
« Reply #1 on: December 03, 2015, 11:19:12 AM »
Hi Peter,

It runs at 27FPS for me occasionally switching over to 28FPS. The program CPU is 6.5%.

Is that its intended behavior?

.

Peter

  • Guest
Re: TimeBeginPeriode
« Reply #2 on: December 03, 2015, 11:21:25 AM »
Quote
Is that its intended behavior?

Yes, that's the sense of it.