I'm struggling, trying to re-build the original source codes. Do you understand the concept of a cone of light, as clearly as the original code? Me no... I'm struggling...
Code: Select all
Structure gui
w.i
h.i
color.i
mouseSprite.i
mdw.i
mx.i
my.i
widget.i[256]
lap.i
lapIni.i
scale.d
EndStructure
Structure clock
sprite.i
x.i
y.i
w.i
h.i
time.d[2]
*gui.gui
EndStructure
Procedure.d getDistance(x0.d, y0.d, x.d, y.d)
x - x0
y - y0
x * x
y * y
ProcedureReturn Sqr(x + y)
EndProcedure
Procedure clockCreate(x, y, c, coef.d, excess, *gui)
Protected *this.clock = AllocateMemory(SizeOf(clock) )
With *this
\sprite = CreateSprite(#PB_Any, 64, 64, #PB_Sprite_AlphaBlending)
\x = x
\y = y
\time[0] = ElapsedMilliseconds()
\time[1] = coef
\gui = *gui
StartDrawing(SpriteOutput(\sprite) )
DrawingMode(#PB_2DDrawing_AllChannels)
Box(0, 0, 64, 64, RGBA(0, 0, 0, 0) )
Circle(32, 32, 30, c)
Circle(31, 31, 28, RGBA(0, 0, 0, 0) )
Box(31, 0, 2, 32 + excess, c)
StopDrawing()
EndWith
ProcedureReturn *this
EndProcedure
Procedure guiCreate()
Protected *this.gui = AllocateMemory(SizeOf(gui) )
Protected img
With *this
InitializeStructure(*this, gui)
InitSprite()
InitKeyboard()
InitMouse()
ExamineDesktops()
OpenScreen(DesktopWidth(0), DesktopHeight(0), 32, "", #PB_Screen_SmartSynchronization, DesktopFrequency(0) )
\w = ScreenWidth()
\h = ScreenHeight()
\color = RGB(64, 128, 255)
\mouseSprite = CreateSprite(#PB_Any, 64, 64, #PB_Sprite_AlphaBlending)
img = CreateImage(#PB_Any, 64, 64, 32, RGBA(0, 0, 0, 0) )
StartDrawing(ImageOutput(img) )
DrawingMode(#PB_2DDrawing_AllChannels)
Box(0, 0, 64, 64, RGBA(0, 0, 0, 0) )
StopDrawing()
StartVectorDrawing(ImageVectorOutput(img) )
VectorSourceColor(RGBA(0, 0, 0, 255))
MovePathCursor(4, 4, #PB_Path_Relative)
AddPathLine(32, 32, #PB_Path_Relative)
AddPathLine(-18, 0, #PB_Path_Relative)
AddPathLine(-14, 14, #PB_Path_Relative)
ClosePath()
StrokePath(3)
VectorSourceColor(RGBA(255, 255, 255, 255))
MovePathCursor(6, 8, #PB_Path_Relative)
ScaleCoordinates(0.8, 0.8)
AddPathLine(32, 32, #PB_Path_Relative)
AddPathLine(-18, 0, #PB_Path_Relative)
AddPathLine(-14, 14, #PB_Path_Relative)
ClosePath()
StrokePath(5, #PB_Path_Preserve)
FillPath()
StopVectorDrawing()
StartDrawing(SpriteOutput(\mouseSprite) )
DrawingMode(#PB_2DDrawing_AllChannels)
Box(0, 0, 64, 64, RGBA(0, 0, 0, 0) )
DrawAlphaImage(ImageID(img), 0, 0)
StopDrawing()
FreeImage(img)
EndWith
ProcedureReturn *this
EndProcedure
Procedure guiDisplay(*this.gui)
Protected *that.clock
Protected.d r, dirt
With *this
ClearScreen(\color)
For i = 0 To 255
*that = \widget[i]
If *that
DisplayTransparentSprite(*that\sprite, *that\x, *that\y)
r = getDistance(\mx - 32, \my - 32, *that\x, *that\y) * \scale
dirt = \lap
dirt / 1000
dirt * 360
r + dirt
RotateSprite(*that\sprite, r * *that\time[1], #PB_Absolute)
EndIf
Next
DisplayTransparentSprite(\mouseSprite, \mx, \my)
EndWith
EndProcedure
Procedure guiGetDevice(*this.gui)
With *this
ExamineKeyboard()
ExamineMouse()
\mdw = MouseWheel()
\mx = MouseX()
\my = MouseY()
If \mdw > 0
\scale * 1.1
EndIf
If \mdw < 0
\scale * 0.9
EndIf
EndWith
EndProcedure
Procedure guiRepeatWhileAnything(*this.gui)
Repeat
;Delay(1)
guiGetDevice(*this)
guiDisplay(*this)
FlipBuffers()
Until (KeyboardPushed(#PB_Key_Escape) = 0) And (MouseButton(#PB_MouseButton_Right) = 0)
EndProcedure
Procedure main()
Protected *gui.gui = guiCreate()
For i = 0 To 255 Step 2
*gui\widget[i] = clockCreate(x, y, RGBA(255, 255, 255, 255), 1, 16, *gui)
*gui\widget[i + 1] = clockCreate(x, y, RGBA(191, 191, 255, 255), 1/12, 0, *gui)
x + 128
If x > ScreenWidth()
x = 0
y + 128
EndIf
Next
*gui\lapIni = ElapsedMilliseconds()
*gui\scale = 1.0
Repeat
*gui\lap = ElapsedMilliseconds() - *gui\lapIni
Delay(1)
guiGetDevice(*gui)
guiDisplay(*gui)
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or MouseButton(#PB_MouseButton_Right)
guiRepeatWhileAnything(*gui)
EndProcedure
End main()