sandyrepope
25-03-2007, 06:00
Is it possible to make an analog clock?
I've been looking through the help file for drawing commands that can be used for this but haven't found any.
I thought that tbgl might have some but I couldn't find any help about tbgl in there either.
Just curious.
Sandy
Check Petr's RObot Duel code, he has a clock in there with all the other goodies, amazing program.
http://community.thinbasic.com/index.php?topic=305.0
Petr Schreiber
25-03-2007, 08:19
Hi,
of course TBGL has documentation !
If you visit "Help" subdirectory in thinBASIC installation, you will find file thinbasic_tbgl.chm - and that's what you need :)
Another learning source could be SampleScripts\TBGL subdirectory.
Note - if you put text cursor on some TBGL keyword in source within thinAir, you will be teleported to topic in TBGL help file automatically.
TBGL has it's own dedicated website too, which is located on this server ( thanks to Eros! ): http://psch.thinbasic.com/
Of course, I am still around here so please ask any TBGL question, and I'll try to answer.
Bye,
Petr
sandyrepope
25-03-2007, 19:57
I just knew that if I mentioned what I wanted that someone would let me know and sure enough Psch gave me the exact information I wanted.
Thank you, Psch, the help file is what I was looking for.
Thank you to kryton9 for letting me know about the robotduel script. I'll be checking that out some time this afternoon.
Thanks
Sandy
You are welcome, but that game is amazing, get ready to be amazed by what Petr did.
sandyrepope
23-04-2007, 04:53
I've been looking at the robot duel script and find that it's too far advanced for me to understand right now.
Are there any other scripts that contain an analog clock?
Thanks
Sandy
Petr Schreiber
23-04-2007, 09:09
Hi,
maybe this could help ?
'
' Clock
'
Uses "TBGL"
Dim hWnd As Dword
hWnd = TBGL_CreateWindowEx("Clock - press ESC to quit", 640, 480, 32, 0)
TBGL_ShowWindow
TBGL_GetAsyncKeyState(-1) ' Resets status of all keys
tbgl_UseLighting 1
tbgl_UseLightSource %GL_LIGHT0, 1
tbgl_SetPrimitiveQuality 20
dim hours as long
dim look as long = %GL_FILL
While TBGL_IsWindow(hWnd)
' Keys
if tbgl_GetWindowKeyState(hWnd, %VK_tab) then
look = iif(look = %GL_FILL, %GL_LINE, %GL_FILL)
TBGL_PolygonLook look
sleep 100
end if
If TBGL_GetWindowKeyState( hWnd, %VK_ESCAPE) Then Exit While
' Rendering...
tbgl_ClearFrame
tbgl_PushMatrix
' First we will move clock by 6 Z units to the scene
tbgl_Translate 0,0,-6
' To Give them shape we will draw a torus around
tbgl_Rotate 90,1,0,0
tbgl_Torus 0.1, 2.25
tbgl_Rotate -90,1,0,0
' Clock hands
' ... "axis"
tbgl_Sphere 0.125
' ... hours
tbgl_PushMatrix
tbgl_Rotate val(PARSE$(time$, ":", 1))*30,0,0,-1
tbgl_Cylinder 0.125, 0, 1.5
tbgl_PopMatrix
' ... minutes
tbgl_PushMatrix
tbgl_Rotate val(PARSE$(time$, ":", 2))*6,0,0,-1
tbgl_Cylinder 0.125, 0, 2
tbgl_PopMatrix
' ... seconds
tbgl_PushMatrix
tbgl_Rotate val(PARSE$(time$, ":", 3))*6,0,0,-1
tbgl_Cylinder 0.0625, 0, 2
tbgl_PopMatrix
' Hour markers
for hours = 1 to 12
tbgl_PushMatrix
tbgl_Rotate hours * 360/12, 0, 0, 1
tbgl_Translate 2, 0, 0
tbgl_Sphere 0.1
tbgl_PopMatrix
next
tbgl_PopMatrix
tbgl_DrawFrame
Wend
TBGL_DestroyWindow
Quite ugly clock, but you can tune it as you wish :)
Bye,
Petr