f = _LoadFont("./DejaVuSansMono.ttf", 16, "monospace") _Font f
'first, let's showcase WHY we need to use QPrint over Print:
a$ = "This_is_a_line_with_underscores" Print a$ Qlocate2, 1 Qprint a$, -1 Locate5, 1 Print"Notice something different with those two statements?" Print"The first line, which uses PRINT, clips off those underscores to make certain that our height is *EXACTLY* 16 pixels." Print Print"QPrint, with uses _UPrintString as its roots, renders above and below the main height as necessary for flourishes and underscores." Sleep Cls _Font16: _FreeFont f
f = _LoadFont("./DejaVuSansMono.ttf", 24, "monospace") _Font f
Locate1, 5'test positioning of first qprint For i = 1To25 QprintStr$(i), -1'print enough to test screen scrolling Sleep'so we can watch it in action! Next
'And here we have a test of multi-line string printing Cls
a$ = "This is a really long line of rambling text that represents nothing more than an attempt to write so much junk on a single line that we end up having to split this text and move it down onto multiple lines, so that we don't lose what we're printing beyond the bounds of the screen. Nothing here really, and if you read all of this, you're a good man(tm)!" For i = 1To5 Qprint a$, -1 Sleep'so we can watch it in action! Next
SubQprint (text$, newline) 'Note that this does NOT print unicode or utf-8 formated strings. 'That functionality has to be expanded in a future update. 'This only prints ASCII characters, but it does so by making use of the _UPrint commands, 'so that font clipping and such doesn't occur and make various fonts illegible.
TextWidth = _UPrintWidth(temp$) If TextWidth < MaxX Then'there's enough room to print on the current line _UPrintString (CurrentX, CurrentY), temp$
CurrentX = CurrentX + _UPrintWidth(temp$)
finished = -1 Else'we need to print what we can and continue to the next line
lastchar = QFindMaxPos(temp$, MaxX) _UPrintString (CurrentX, CurrentY), Left$(temp$, lastchar)
temp$ = Mid$(temp$, lastchar + 1)
MaxX = _Width GoSub scrollup
CurrentX = 0
CurrentY = CurrentY + _UFontHeight
finished = 0 End If GoSub scrollup Loop Until finished If newline Then CurrentY = CurrentY + _UFontHeight: CurrentX = 0
FunctionQFindMaxPos (text$, w) 'Quick Find Max Position 'This routine quickly finds which position fits within a given width of a string 'This works on a binary search method to determine max length and character position, 'So for long strings or large screens, it can find the proper position much quicker than just searching 'and comparing lengths from left to right, or right to left.
Currently, this basically mimics the behavior of PRINT in the fact that it breaks words at the border of the screen, with no concern whatsoever over performing any sort of decent word wrap.
Note that since _UPrintString uses more screen area than Print (as illustrated in those first lines where PRINT clips off part of the text on us), our LOCATE positions are *NOT* going to be the same here, when we swap back and forth between the two commands.
^The above will print to two completely different areas of the screen! (Print, as I've pointed out already, doesn't display the same height and width characters, so what is considered to be a "line", is going to be smaller than with UPrintString.)
Don't think you can swap back and forth between PRINT and QPRINT seemlessly. That's not gonna happen! Choose one. Use one. And forget the other even exists, except in the most extreme cases.
FunctionQFindMaxPos (text$, w) 'Quick Find Max Position 'This routine quickly finds which position fits within a given width of a string 'This works on a binary search method to determine max length and character position, 'So for long strings or large screens, it can find the proper position much quicker than just searching 'and comparing lengths from left to right, or right to left.
If your curiosity bug bites, here is a link to an open source version of BASIC with an included multi-value database. It is the open source version of OpenQM called ScarletDME (SDME for short). It was released as an open source 32 version in 2007 and has been updated over the years to 64 bit by some dedicated programmers. It is related to Pick like databases such as Universe, Unidata and D3.
It is multi-user and runs on current linux distros such as Debian 12, Ubuntu 23.10 and Fedora 39. The BASIC included will be very familar to any Quick Basic lover. And, it manages a database without the use of SQL.
Discovered "fantasy computers" recently and this might be of interest to other retro programming fans if you aren't too busy with QB64. Runs on probably all the platforms you'd want.
LowRes NX is a similar setup, though using a dialect of BASIC!
Tic-80 can be used with Lua, Python, Ruby, JavaScript, and some others. Lua seems nice so far, and I feel good about its usefulness in game development. I'm also working through tutorials for Defold which is an engine with much broader scope. Maybe I get comfortable using Lua in Tic-80, see if I can actually make anything substantial, and if I ever get tired of limitations, migrate to Defold and continue using Lua.
As a perpetual beginner who never completed a game and tends to get caught up in fine details, the limited ability & all-in-one nature of Tic-80 seems like it could be helpful to stay focused on the essentials, and the 8-bit sound and feel along with an optional CRT filter comes with the territory.
I had fun making the beginnings of a game with AppGameKit Studio, but hesitant to spend further time learning that IDE and AGK Script. Kept thinking that if I'm going to use BASIC, might as well be QB64! QB64 can most certainly create anything my brain could imagine, but from my perspective it seems better for those who have the patience to recreate the wheel. Some folks enjoy that but not quite confident that I would, or could.
In this post is an interesting drive display utility which lists drive volumes and serial numbers using a shell to vol:
Code: (Select All)
Rem Utility to display drives and volume and serial. PD 2023.
Dim Shared drives(26) As Integer
Dim Shared labels(26) As String
Dim Shared serial(26) As String
For i = 1 To 26
d$ = CheckDrive(i)
If d$ <> "" Then Print d$
Next
End
Function CheckDrive$ (i)
t$ = "tempfile.arg"
i$ = Chr$(i + 64) + ":"
j$ = "cd " + i$
Shell _Hide j$ + " > " + t$
Close
Open t$ For Input As #1
If EOF(1) = 0 Then
Line Input #1, s$
s$ = LCase$(s$)
If s$ = "path not found" Then
' eat
Else
Shell _Hide "vol " + i$ + " > " + t$
Close
Open t$ For Input As #1
z = 0
Do Until EOF(1)
Line Input #1, s$
If Len(s$) Then
z = -1
Exit Do
End If
Loop
If z Then
Close
Open t$ For Input As #1
x = 0
Do Until EOF(1)
Line Input #1, s$
'Print s$
If LCase$(s$) = "invalid drive specification" Then
Exit Do
Else
drives(i) = -1
If InStr(s$, " is ") Then
x = x + 1
' volume in drive C is Label
If x = 1 Then
labels(i) = Mid$(s$, InStr(s$, " is ") + 4)
End If
' volume serial number is xxxx-xxxx
If x = 2 Then
serial(i) = Mid$(s$, InStr(s$, " is ") + 4)
End If
End If
End If
Loop
End If
End If
End If
q$ = ""
If drives(i) Then
q$ = Chr$(i + 64) + ":\" + labels(i)
If Len(serial(i)) Then
q$ = q$ + " [" + serial(i) + "]"
End If
End If
CheckDrive = q$
End Function
I would like to bring it to the attention of those who make games. Even with a 2D game, it's worth considering what you want to show. The image update. Until now I never dealt with it, I always used a value. A value that is good for the speed of my current computer. In my last game, I was shocked at how important this is to the perfection of the display.
It also means a lot if someone makes a 2D game!
Something moves on the screen. This will have a path, a process. How many parts this process is divided into and how many times it is mapped determines the quality of the animation.
It is worth taking this into account before making the game! It can also be built in afterwards.
legalso_ypozicio = mony - ballr 'this value is the lowest position given by the size of the window and the ball, when the balls are on the ground
'RED BALL -------------------------------------------------------------------------------------------------------------------------------------
red_yvec = red_yvec + gravity * deltatime
red_bally = red_bally + red_yvec * deltatime
If legalso_ypozicio < red_bally Then red_bally = legalso_ypozicio: red_yvec = -14 'can also be used for jumping, yvec, momentum vector, which gravity tries to pull down in every cycle
Color _RGB32(255, 20, 20)
Circle (red_ballx, red_bally), ballr
Paint (red_ballx, red_bally)
'GREEN BALL ------------------------------- same as the red ball, only you jump with SPACE
green_yvec = green_yvec + gravity * deltatime
green_bally = green_bally + green_yvec * deltatime
If legalso_ypozicio < green_bally Then
green_bally = legalso_ypozicio
If _KeyDown(Asc(" ")) Then green_yvec = -5 'you jump to SPACE, which you can only do when you are on the ground (you can't jump while falling). it also has the power of jumping
End If
Color _RGB32(20, 255, 20)
Circle (green_ballx, green_bally), ballr
Paint (green_ballx, green_bally)
'BLUE BALL
blue_bally = blue_bally * 1.12 ^ deltatime '<------------------ in such cases deltatime must be increased!
If legalso_ypozicio < blue_bally Then blue_bally = 1
Color _RGB32(20, 20, 255)
Circle (blue_ballx, blue_bally), ballr
Paint (blue_ballx, blue_bally)
Umm... I had a topic here already on this subject, with the code I'd originally posted being (Windows-Only). I went back to modify that time as I was posting code which would turn my Windows-Only comment into a thing of the past, and... umm... some mod.... *whistles innocently*... who may, or may not have been me... *whistles a little more*... completely ended up destroying that whole topic, rather than just renaming it!!
*Whistles Innocently a whole lot!*
But, since these things happen, and nobody will cop up to deleting and obliterating my old topic... *hum humm deee hummm* ,,, then I guess I'll just start a new one, so I can share the new code which works on all OSes.
' Converts a normal string or binary data to a base64 string FunctionTo64$ (s AsString) Const BASE64_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
Dim i As_UnsignedLong: For i = 1To srcSize Step4
index = Asc(s, i): GoSub find_index: char1 = index
index = Asc(s, i + 1): GoSub find_index: char2 = index
index = Asc(s, i + 2): GoSub find_index: char3 = index
index = Asc(s, i + 3): GoSub find_index: char4 = index
And, as long as we're whistling innocently, I'd also like to point out to @a740g that I have no idea why large portions of this code may, or may not, resemble his so uncannily! *Whistle thistle hum and drum...*
I would like to try using the C language support to integrate certain functions that do not exist or are difficult to access in QB64.
Apart from the wiki, I have not found a proper guide that can help me understand how to do it, and the examples I have found have not been very helpful.
Can you help me with this?
Even Python, which is currently very popular, would be fantastic if it were implemented in QB64… but I realize I'm asking for too much.
Besides, I don't like Python but I have to acknowledge that it has an incredible amount of libraries.