Timer Library

Share your advanced PureBasic knowledge/code with the community.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Timer Library

Post by BackupUser »

Code updated for 5.20+

Restored from previous forum. Originally posted by Danilo.

Question:
How do i use the commands from the Timer-Library ??

Answer:

---------------

Code: Select all

;EXAMPLE USAGE NOTE:
;this example requires the use of the PBOSL_Timer library from
;the PureBasic OpenSource Libraries (PBOSL) set, which can be
;downloaded from http://pbosl.purearea.net/index.php?site=Libs
;and should be copied to the \PureLibraries\UserLibraries folder

#ScreenBits = 32
#ScreenWidth = 640
#ScreenHeight = 480
Define y, size, flag, color

Procedure Timer()
  Shared y, size, flag, color
  y + #ScreenHeight / 200
  If y > #ScreenHeight
    y = 0 
  EndIf
  color = (size << 3) - 1
  If size < 32 And flag = 0
    size + 1
  Else
    flag = 1 
    size - 1 
    If size = 0 
      flag = 0 
    EndIf
  EndIf
EndProcedure

If InitSprite() And InitKeyboard()
  If OpenScreen(#ScreenWidth, #ScreenHeight, #ScreenBits, "Timer Test")
    StartTimer(0, 15, @Timer())   ;function of PBOSL_Timer library
    Repeat
      ExamineKeyboard()
      FlipBuffers() 
      ClearScreen(RGB(0, 0, 0))
      StartDrawing(ScreenOutput())
        FrontColor(RGB(color, color, 0))
        Box((#ScreenWidth / 2) - size, y, size, size) 
      StopDrawing()
    Until KeyboardPushed(#PB_Key_Escape)
    EndTimer(0)
  Else
    MessageRequester("ERROR", "Can't initialize DirectX 7 or later.", 0)
  EndIf
Else
  MessageRequester("ERROR", "Can't open DirectX screen.", 0)
EndIf
---------------

cya,
...Danilo
(registered PureBasic user)

Edited by - Danilo on 16 April 2002 08:17:07
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.
Question:
How do i use the commands from the Timer-Library ??
Answer: Without a Timer Library, I don't know...

Hey Danilo, "Back from the future?"



Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

After the update to PB 3.0 you should have this
Lib in "UserLibraries". Its included in the Update.

Did you actually try this code ??

cya,
...Danilo

(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

That's why I didn't find it.
Under
PureBasic\PureLibraries\UserLibraries
I found

HighResTimer

I suppose this is the file.

After I found the lib I executed the examples. (as one file...)

Example #2 crashes after starting it (not always...) and I didn't figure out why.
Sometimes I see some colored boxes dropping down but after that it stops.
The only way (thanks to Windows) to get the OS back is to press the reset button.
Don't have time yet, so I dive into it another time.
Sorry


Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by DarkUni.

Now if we can only get a MILLISECS() function vice GETTIMERTICK_() (er, whatever the WinAPI equiv is) I could jump up and down ... :)



Shane R. Monroe, Dark Unicorn Productions
Pure Basic Basement
http://pb.darkunicornproductions.com
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by El_Choni.

There is GetTickCount_() in Windows, but I don't know if it returns milliseconds.

Bye,

El_Choni
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> There is GetTickCount_() in Windows, but I don't know if it returns milliseconds.

Yes, it does: "The GetTickCount function retrieves the number of milliseconds
that have elapsed since Windows was started."


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

>After I found the lib I executed the examples. (as one file...)

"as one file" ??
Both examples together in 1 file ??

>Example #2 crashes after starting it (not always...)
>and I didn't figure out why.
>Sometimes I see some colored boxes dropping down but
>after that it stops.
>The only way (thanks to Windows) to get the OS back
>is to press the reset button.

This is simple and easy code and should
work on all systems.
I think so =>> but with win9x you never know...

cya,
...Danilo

(registered PureBasic user)
Post Reply