A clock

Just starting out? Need help? Post your questions and find answers here.
User avatar
SPH
Enthusiast
Enthusiast
Posts: 268
Joined: Tue Jan 04, 2011 6:21 pm

A clock

Post by SPH »

Hello all,

My contribution. Just for fun (use mouse) : :wink:

Code: Select all

; SPH(2021)
; PB573

InitSprite() 
InitMouse() 
InitKeyboard() 

;SetPriorityClass_ ( GetCurrentProcess_ (), #IDLE_PRIORITY_CLASS ) 

If ExamineDesktops()
   dw.w=DesktopWidth(0) 
   dh.w=DesktopHeight(0)
   do.b=DesktopDepth(0)
Else 
   dw.w=1024 
   dh.w=768
   do.b=32
EndIf 

OpenScreen(dw,dh,do,"Les horloges de SPH") 


xx=dw/2
yy=dh/2
pis.f=ATan(1)*12.1585
pim.f=ATan(1)*12.1585
pih.f=ATan(1)*2.4317
echp=yy/1.4
;echh=yy/2.4
echm=yy/1.5
col=RGB(33,33,33)
ii.f=Random(20)/100
uu.f=Random(20)/100
ii2.f=Random(20)/100
uu2.f=Random(20)/100

;;;;;;;;;;;
sphii.f=0
sphuu.f=0
sphii2.f=0
sphuu2.f=0
sphiii.f=Random(1000)/200000
sphuuu.f=Random(1000)/200000
sphiii2.f=Random(1000)/200000
sphuuu2.f=Random(1000)/200000
rayonx=dw/5
rayony=dh/6

;;;;;;;;;;;
;;;;;;;;;;;

MouseLocate(xx,yy)

Repeat ; Boucle principale

xxx=Cos(ii)*45+Sin(ii2)*40
yyy=Sin(uu)*45-Cos(uu2)*40
decx.f=Cos(ii)/18+Sin(uu2)/15

ExamineMouse()
x2mouse=MouseX()
y2mouse=MouseY()

xmouse=Cos(sphii)*rayonx+Sin(sphii2)*rayonx
ymouse=Sin(sphuu)*rayony+Cos(sphuu2)*rayony

xx2021=xmouse+x2mouse
yy2021=ymouse+y2mouse



If MouseButton(#PB_MouseButton_Left)<>0
s+1:If s>=60:s-60:m+1:EndIf:If m=60:m=0:h+1:EndIf:If h=12:h=0:EndIf
Else
h=Hour(Date()):m=Minute(Date()):s=Second(Date())
EndIf

If MouseButton(#PB_MouseButton_Right)<>0
sphiii.f=Random(1000)/200000
sphuuu.f=Random(1000)/200000
sphiii2.f=Random(1000)/200000
sphuuu2.f=Random(1000)/200000
EndIf


;*****
ClearScreen(0)
StartDrawing(ScreenOutput()) 
;;;;;;;;;;;
ss.f=decx+s/pis
mm.f=decx+(m+s/60)/pim
hh.f=decx+(h+m/60)/pih
For i=0 To 11
For u=1 To 5
If i=0 Or i=3 Or i=6 Or i=9
co=RGB(255,255,255)
Else
co=RGB(80,80,80)
EndIf

  sphx=xx2021+Sin(decx+i/pih)*(echp+xxx)+Random(6)-3 ;;;;;;;;;;;;xx
  sphy=yy2021-Cos(decx+i/pih)*(echp+yyy)+Random(6)-3 ;;;;;;;;;;;;yy
  
  If sphx<0
    co=RGB(00,80,00)
  sphx=(sphx*-1)/2
  EndIf
  If sphx>=dw
    co=RGB(00,80,00)
    sphx=dw-1-Abs(dw-sphx)/2
  EndIf
  
  If sphy<0
    co=RGB(00,80,00)
  sphy=(sphy*-1)/2
  EndIf
  If sphy>=dh
    co=RGB(00,80,00)
  sphy=dh-1-Abs(dh-sphy)/2
  EndIf
  
  Plot(sphx,sphy,co)
Next
Next


x1=Sin(mm)*(echm+xxx)
y1=-Cos(mm)*(echm+yyy)
;Line(xx,yy,x1,y1,RGB(200,200,0))
dist=Sqr(x1*x1+y1*y1)
xx1.f=x1/dist
yy1.f=y1/dist
xx2.f=xx2021;;;;;;;xx
yy2.f=yy2021;;;;;;;yy
u=0
;r=255;Random(255)
For i=0 To dist/3
  co=RGB(255,255,00)
  sphx=xx2-u/32+Random(u/16)
  sphy=yy2-u/32+Random(u/16)
  If sphx<0
    co=RGB(00,80,00)
  sphx=(sphx*-1)/2
  EndIf
  If sphx>=dw
    co=RGB(00,80,00)
    sphx=dw-1-Abs(dw-sphx)/2
  EndIf
  
  If sphy<0
    co=RGB(00,80,00)
  sphy=(sphy*-1)/2
  EndIf
  If sphy>=dh
    co=RGB(00,80,00)
    sphy=dh-1-Abs(dh-sphy)/2
  EndIf
  
Plot(sphx,sphy,co)
xx2+xx1
yy2+yy1
u+2
Next
;r=255;Random(255)
For i=0 To dist/2
  co=RGB(255,255,00)
  u-1
  sphx=xx2-u/32+Random(u/16)
  sphy=yy2-u/32+Random(u/16)
  If sphx<0
    co=RGB(00,80,00)
  sphx=(sphx*-1)/2
  EndIf
  If sphx>=dw
    co=RGB(00,80,00)
    sphx=dw-1-Abs(dw-sphx)/2
  EndIf
  
  If sphy<0
    co=RGB(00,80,00)
  sphy=(sphy*-1)/2
  EndIf
  If sphy>=dh
    co=RGB(00,80,00)
    sphy=dh-1-Abs(dh-sphy)/2
  EndIf
  
Plot(sphx,sphy,co)
xx2+xx1
yy2+yy1
Next


x1=Sin(hh)*(echm+xxx)
y1=-Cos(hh)*(echm+yyy)
dist=Sqr(x1*x1+y1*y1)
xx1.f=x1/dist
yy1.f=y1/dist
xx2.f=xx2021;;;;;;;xx
yy2.f=yy2021;;;;;;;yy
u=0
;r=255;Random(255)
For i=0 To dist/8
  co=RGB(255,20,86)
  sphx=xx2-u/8+Random(u/4)
  sphy=yy2-u/8+Random(u/4)
  If sphx<0
    co=RGB(00,80,00)
  sphx=(sphx*-1)/2
  EndIf
  If sphx>=dw
    co=RGB(00,80,00)
    sphx=dw-1-Abs(dw-sphx)/2
  EndIf
  
  If sphy<0
    co=RGB(00,80,00)
  sphy=(sphy*-1)/2
  EndIf
  If sphy>=dh
    co=RGB(00,80,00)
    sphy=dh-1-Abs(dh-sphy)/2
  EndIf
  
Plot(sphx,sphy,co)
xx2+xx1
yy2+yy1
u+2
Next
r=255;Random(255)
For i=0 To dist/4
  u-1
    co=RGB(255,20,86)
    sphx=xx2-u/8+Random(u/4)
  sphy=yy2-u/8+Random(u/4)
  If sphx<0
    co=RGB(00,80,00)
  sphx=(sphx*-1)/2
  EndIf
  If sphx>=dw
    co=RGB(00,80,00)
    sphx=dw-1-Abs(dw-sphx)/2
  EndIf
  
  If sphy<0
    co=RGB(00,80,00)
  sphy=(sphy*-1)/2
  EndIf
  If sphy>=dh
    co=RGB(00,80,00)
    sphy=dh-1-Abs(dh-sphy)/2
  EndIf
  
Plot(sphx,sphy,co)
xx2+xx1
yy2+yy1
Next

x1=Sin(ss)*(echm+xxx)
y1=-Cos(ss)*(echm+yyy)
dist=Sqr(x1*x1+y1*y1)
xx1.f=x1/dist
yy1.f=y1/dist
xx2.f=xx2021-2;;;;;;;xx-2
yy2.f=yy2021-2;;;;;;;yy-2
For i=0 To dist
  If Random(2)=1
    co=RGB(86,20,255)
    sphx=xx2+Random(4)
  sphy=yy2+Random(4)
  If sphx<0
    co=RGB(00,80,00)
  sphx=(sphx*-1)/2
  EndIf
  If sphx>=dw
    co=RGB(00,80,00)
    sphx=dw-1-Abs(dw-sphx)/2
  EndIf
  
  If sphy<0
    co=RGB(00,80,00)
  sphy=(sphy*-1)/2
  EndIf
  If sphy>=dh
    co=RGB(00,80,00)
    sphy=dh-1-Abs(dh-sphy)/2
  EndIf
  
Plot(sphx,sphy,co)
EndIf
xx2+xx1
yy2+yy1
Next

;ii+0.024
;uu+0.0189
;ii2+0.013
;uu2+0.021
ii+0.007
uu+0.0059
ii2+0.0043
uu2+0.0031

sphii.f+sphiii.f
sphuu.f+sphuuu.f
sphii2.f+sphiii2.f
sphuu2.f+sphuuu2.f

;Plot(xx,yy,RGB(255,255,255))

;;;;;;;;;;;
StopDrawing() 
;*****

FlipBuffers() 

Delay(1)

ExamineKeyboard() 
Until KeyboardPushed(#PB_Key_All) 
End 

http://HexaScrabble.com/
!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 5.73LTS - 32 bits
User avatar
Caronte3D
Addict
Addict
Posts: 1014
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: A clock

Post by Caronte3D »

Nice one!
btw: wrong forum :wink:
Post Reply