Petr,
is this the current version of the FontTool? I think on SVn you have a more advanced version. Or am I wrong?
Michael.
Hi Lydia,
I am happy it worked! I also recognize somebody can be confused by the amount of sample code, available on multiple places. The direction for future will be to have everything on one place, carefully labeled and divided to various interest areas (something like Bonus Pack sections of different areas).
Displaying frame rate is simple, you have multiple options:
- 1) As your example is rendered in dialog, you could simply print the info to some of the controls or dialog title
- 2) Use TT font rendered inside TBGL window
- 3) Use bitmap font rendered inside TBGL window ( hint -> you can create bitmap fonts easily using TBGL Font Creator )
Ad 1)
To set frameRate to control, you can do it like:
[code=thinbasic]
control set text hDlg, %control, format$(frameRate, "#.00") ' -- 2 decimals
[/code]
To set frameRate to dialog, you can do similar:
[code=thinbasic]
dialog set text hDlg, format$(frameRate, "#.00") ' -- 2 decimals
[/code]
Ad 2)
To use TT fonts inside TBGL, you do the following:
- build the font ( that means, create set of OpenGL compatible character primitives )
[code=thinbasic]
TBGL_BuildFont TBGL_FontHandle("Arial", 9)
[/code]
- print it at any 3D location
[code=thinbasic]
TBGL_PrintFont format$(frameRate, "#.00"), 0, 0, 0
[/code]
- you could also print it in "2D mode", but you have to set such a mode first using TBGL_RenderMatrix2D
Ad 3)
- you create the BMP file using mentioned font tool
- you load it
[code=thinbasic]
TBGL_LoadBmpFont "myFont.bmp"
[/code]
- you can print it on the screen later like:
[code=thinbasic]
TBGL_BeginPrintBMP
TBGL_PrintBMP "Information on frame rate:", 1, 1 ' -- Column = 1, Row = 1
TBGL_PrintBMP format$(frameRate, "#.00"), 1, 2 ' -- Column = 1, Row = 2
TBGL_EndPrintBMP
[/code]
So you can see the options are multiple each having its advantages. The control/dialog way is simple, but not very stylish and also little slower, TT font provides best quality and you can use it for both 2D and 3D positioned printing and latest BMP font allows you to position text like in console applications - using column/row.
To see example of #2 and #3, please have a look at:
SampleScripts/TBGL/TBGL_0220_Samples/4n4Fonts/TBGL022_MultipleFonts.tbasic.
It shows that you can use 4 TTF and 4 BMP different fonts at the same time ( dangerous mix ).
Regarding collision - TBGL provides some basic functions to be used for collision, but I am currently working on more comfortable system, providing bounding boxes and bouding spheres attachable to entities directly.
Still, if you need at least approximate collision now, you can try few interesting approaches:
- measure distance of 2 entities, and if it is too small consider it "collision"
- track "points of interest" on the entities using TBGL_EntityTrackPos and do the similar distance based test
I attach for you modified code showing how to print in 3D and how to do very elemental collision check.
If you are not in hurry, please wait for a while before I develop more advanced collision functions, it is already work in progress and it should save you some time coding.
Petr
P.S. Side note on frame rate. In your example, it won't be very high, because the display is pumped using timer.
This is approach I recommend - you let the PC breathe a bit. Of course, you can code tight loops in ThinBASIC to get maxximum out of the GPU and CPU performance too, when you need it.
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Petr,
is this the current version of the FontTool? I think on SVn you have a more advanced version. Or am I wrong?
Michael.
Yes,
you are right, I just updated the post with last version of the tool
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
hi petr and mike, thank you for help and infos again !
my pc makes some trouble at the moment, dont know why. I will test script example this day again.
@mike: do you have any example for sprite and collision ? sounds interesting for me. sorry, but I have still problems to orientate here at the board like a unknown djungle good idea, petr to collect everything at one place. a place for beginners and their needs and faq`s would be also nice.
saludos, lydia
hasta la vida
Sure, i am out now in cologne but when i am back tonight, i will write something about it.Originally Posted by lydia_sp
Hi,
Here is a link to sample scripts:
http://community.thinbasic.com/index.php?topic=2728.0
There you find a few ones that use the collision too.
And here is a sample game that I made to show off the new sprite commands:
http://community.thinbasic.com/index.php?topic=2737.0
The download link there contains the bundled game. You can find the source here:
http://community.thinbasic.com/index.php?topic=2738.0
Cu
Michael
hi michael, thanks for the links. I am for some days in cologne, holidays. I will explore sprite examples at week-end. at the moment I prefer sun bathing. then I will make a feedback if I understand all the sprite tbgl features. thank you, lydia
hasta la vida
Bookmarks