Analog Timer

Share your advanced PureBasic knowledge/code with the community.
LJ
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Apr 30, 2003 4:00 pm

Analog Timer

Post by LJ »

Code: Select all

; Analog Timer
; Modified Danilo code by Lance Jepsen

InitSprite() 
InitKeyboard() 

#ScreenWidth  = 800 
#ScreenHeight = 600 
#ScreenBits   = 32 
#MiddleX      = #ScreenWidth  / 2 
#MiddleY      = #ScreenHeight / 2 
#Radius       = 100 

Procedure.f GSin(winkel.f) 
   ProcedureReturn Sin(winkel*(2*3.14159265/360)) 
EndProcedure 

Procedure.f GCos(winkel.f) 
   ProcedureReturn Cos(winkel*(2*3.14159265/360)) 
EndProcedure 

If OpenScreen(800,600,32,"") 

   Repeat 
      FlipBuffers() 
      ClearScreen(0,0,0) 

      StartDrawing(ScreenOutput())
      Circle(#MiddleX, #MiddleY, 100, RGB(255,0,0))
      LineXY(#MiddleX,#MiddleY,#MiddleX+GSin(grad)*#Radius,#MiddleY+GCos(grad)*#Radius, RGB(0,255,0)) 
      StopDrawing()
      Delay(1000) 
      grad = grad - 6 
      If grad = -6 : grad = 359 : EndIf 

      ExamineKeyboard() 
   Until KeyboardPushed(#PB_KEY_ESCAPE) 

EndIf 
; ExecutableFormat=Windows
; EOF