December 04, 2020, 10:45:24 AM

Author Topic: [bb] Watch by Mr. Bean [ 1+ years ago ]  (Read 381 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Watch by Mr. Bean [ 1+ years ago ]
« on: June 29, 2017, 12:28:39 AM »
Title : Watch
Author : Mr. Bean
Posted : 1+ years ago

Description : a simple watch-animation

Code :
Code: BlitzBasic
  1. Graphics 640,480
  2. I =360/2
  3. I1=360/2
  4. I2=360/2
  5. v=Input("Speed (1=Normal)  ")
  6.  
  7. If v<1 v=1
  8. If v>101 v=100
  9. SEC=1000 /v
  10. MIN=SEC*60
  11. STD=MIN*60
  12. tim =MilliSecs()
  13. tim1=tim
  14. tim2=tim
  15.  
  16. C=0
  17. C1=0
  18. C2=0
  19.  
  20. Repeat
  21. Color 180,180,180
  22. If C Or C1 Or C2 Cls
  23. Oval 320-100,240-100,200,200,0
  24. Oval 320-130,240-130,260,260,0
  25. Text 320,240-115,"XII",1,1
  26. Text 320+115,240,"III",1,1
  27. Text 320,240+115,"VI",1,1
  28. Text 320-115,240,"IX",1,1
  29.  
  30. LX= Sin(150)*109+320
  31. LY= Cos(150)*109+240
  32. LX1=Sin(150)*121+320
  33. LY1=Cos(150)*121+240
  34. Line LX,LY,LX1,LY1
  35.  
  36. LX= Sin(120)*109+320
  37. LY= Cos(120)*109+240
  38. LX1=Sin(120)*121+320
  39. LY1=Cos(120)*121+240
  40. Line LX,LY,LX1,LY1
  41.  
  42. LX= Sin(60)*109+320
  43. LY= Cos(60)*109+240
  44. LX1=Sin(60)*121+320
  45. LY1=Cos(60)*121+240
  46. Line LX,LY,LX1,LY1
  47.  
  48. LX= Sin(30)*109+320
  49. LY= Cos(30)*109+240
  50. LX1=Sin(30)*121+320
  51. LY1=Cos(30)*121+240
  52. Line LX,LY,LX1,LY1
  53.  
  54. LX= Sin(210)*109+320
  55. LY= Cos(210)*109+240
  56. LX1=Sin(210)*121+320
  57. LY1=Cos(210)*121+240
  58. Line LX,LY,LX1,LY1
  59.  
  60. LX= Sin(240)*109+320
  61. LY= Cos(240)*109+240
  62. LX1=Sin(240)*121+320
  63. LY1=Cos(240)*121+240
  64. Line LX,LY,LX1,LY1
  65.  
  66. LX= Sin(300)*109+320
  67. LY= Cos(300)*109+240
  68. LX1=Sin(300)*121+320
  69. LY1=Cos(300)*121+240
  70. Line LX,LY,LX1,LY1
  71.  
  72. LX= Sin(330)*109+320
  73. LY= Cos(330)*109+240
  74. LX1=Sin(330)*121+320
  75. LY1=Cos(330)*121+240
  76. Line LX,LY,LX1,LY1
  77.  
  78.  
  79. If MilliSecs()-tim>SEC Then
  80. tim=MilliSecs()
  81. I=I-6
  82. If I=0 I=360
  83. C=1
  84. Else
  85. C=0
  86. EndIf
  87.  
  88. If MilliSecs()-tim1>MIN Then
  89. tim1=MilliSecs()
  90. I1=I1-6
  91. If I1=0 I1=360
  92. C1=1
  93. Else
  94. C1=0
  95. EndIf
  96.  
  97. If MilliSecs()-tim2>STD Then
  98. tim2=MilliSecs()
  99. I2=I2-6
  100. If I2=0 I2=360
  101. C2=1
  102. Else
  103. C2=0
  104. EndIf
  105.  
  106.  
  107.  
  108.  
  109.  
  110. Color 100,100,100
  111. X=Sin(I)*85
  112. Y=Cos(I)*85  
  113. X=X+320      
  114. Y=Y+240
  115. Line X,Y,320,240
  116.  
  117. Color 150,150,150
  118. X1=Sin(I1)*80
  119. Y1=Cos(I1)*80  
  120. X1=X1+320      
  121. Y1=Y1+240
  122. Line X1,Y1,320,240
  123.  
  124. Color 255,255,255
  125. X2=Sin(I2)*65
  126. Y2=Cos(I2)*65  
  127. X2=X2+320      
  128. Y2=Y2+240
  129. Line X2,Y2,320,240
  130.  
  131.  
  132.  
  133.  
  134. Until KeyHit(1)
  135.  
  136. WaitKey
  137. End


Comments :


bytecode77(Posted 1+ years ago)

 when using the backbuffer it wouldnt flicker so much...ps: it would be nice to see the real time! and not just 12:00oh and by the way: "engagement" is the best way to make the code clear!


Mr. Bean(Posted 1+ years ago)

 
Code: [Select]
Graphics 640,480
I =360/2
I1=360/2
I2=360/2
v=Input("Speed (1=Normal)  ")

If v<1 v=1
If v>101 v=100
SEC=1000 /v
MIN=SEC*60
STD=MIN*60
tim =MilliSecs()
tim1=tim
tim2=tim

C=0
C1=0
C2=0

SetBuffer BackBuffer()
Repeat
Color 180,180,180
If C Or C1 Or C2 Cls
Oval 320-100,240-100,200,200,0
Oval 320-130,240-130,260,260,0
Text 320,240-115,"XII",1,1
Text 320+115,240,"III",1,1
Text 320,240+115,"VI",1,1
Text 320-115,240,"IX",1,1

LX= Sin(150)*109+320
LY= Cos(150)*109+240
LX1=Sin(150)*121+320
LY1=Cos(150)*121+240
Line LX,LY,LX1,LY1

LX= Sin(120)*109+320
LY= Cos(120)*109+240
LX1=Sin(120)*121+320
LY1=Cos(120)*121+240
Line LX,LY,LX1,LY1

LX= Sin(60)*109+320
LY= Cos(60)*109+240
LX1=Sin(60)*121+320
LY1=Cos(60)*121+240
Line LX,LY,LX1,LY1

LX= Sin(30)*109+320
LY= Cos(30)*109+240
LX1=Sin(30)*121+320
LY1=Cos(30)*121+240
Line LX,LY,LX1,LY1

LX= Sin(210)*109+320
LY= Cos(210)*109+240
LX1=Sin(210)*121+320
LY1=Cos(210)*121+240
Line LX,LY,LX1,LY1

LX= Sin(240)*109+320
LY= Cos(240)*109+240
LX1=Sin(240)*121+320
LY1=Cos(240)*121+240
Line LX,LY,LX1,LY1

LX= Sin(300)*109+320
LY= Cos(300)*109+240
LX1=Sin(300)*121+320
LY1=Cos(300)*121+240
Line LX,LY,LX1,LY1

LX= Sin(330)*109+320
LY= Cos(330)*109+240
LX1=Sin(330)*121+320
LY1=Cos(330)*121+240
Line LX,LY,LX1,LY1


If MilliSecs()-tim>SEC Then
tim=MilliSecs()
I=I-6
If I=0 I=360
C=1
Else
C=0
EndIf

If MilliSecs()-tim1>MIN Then
tim1=MilliSecs()
I1=I1-6
If I1=0 I1=360
C1=1
Else
C1=0
EndIf

If MilliSecs()-tim2>STD Then
tim2=MilliSecs()
I2=I2-6
If I2=0 I2=360
C2=1
Else
C2=0
EndIf





Color 100,100,100
X=Sin(I)*85
Y=Cos(I)*85  
X=X+320      
Y=Y+240
Line X,Y,320,240

Color 150,150,150
X1=Sin(I1)*80
Y1=Cos(I1)*80  
X1=X1+320      
Y1=Y1+240
Line X1,Y1,320,240

Color 255,255,255
X2=Sin(I2)*65
Y2=Cos(I2)*65  
X2=X2+320      
Y2=Y2+240
Line X2,Y2,320,240



Flip
Until KeyHit(1)

WaitKey
End



Now with Backbuffer


GfK(Posted 1+ years ago)

 The 'minute' hand moves a second too early.  I'd hazard a guess that the 'hour' hand has the same problem, but I didn't want to watch it for an hour to find out.You should use CurrentTime() to make it show the correct time, also.


Mr. Bean(Posted 1+ years ago)

 Maybe I'll try later. But there's no time now!Thanks


jfk EO-11110(Posted 1+ years ago)

 You may have a look at the watch I made some years ago, somewhere here in the archives. It may give you an idea on how to use the systems date and time.


Mr. Bean(Posted 1+ years ago)

 Thanks,but the reason for doing that was mainly to demonstrate how to use Sine and Cosine.There isn't any time to improve the code, SryCS [/i]

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal