Posts: 688
Threads: 125
Joined: Apr 2022
Reputation:
49
10-08-2025, 04:07 PM
(This post was last modified: 10-08-2025, 04:12 PM by SierraKen.)
I found this original code on the Basic Programming Language FB group page. I modded it to say QB64 Phoenix Edition and also made it wavey.
This is from around 40 years ago (I removed the line numbers). Notice the old "Print String$(N, 32)". I had to look that up, it was used to move a string different spaces, like LOCATE does now. But it still works!  32 is the ASCII number for a space.
The person that posted this said this: "It got published on the back of Remarks magazine, the club letter of the Dutch TRS-80 User Group." His version slanted down in one direction and didn't make waves.
Press Esc to end.
Code: (Select All)
'Thank you to Richard Keijzer on BASIC Programming Language FB Group.
'Modded by SierraKen
'Press Esc to end.
A$ = "QB64 Phoenix Edition"
Do
For N = 1 To Len(A$) - 1: Print String$(N, 32);
For M = 1 To N
Print Mid$(A$, M, 1); " ";
_Delay .02
Next M: Print Mid$(A$, M): Next N
For N = Len(A$) - 1 To 1 Step -1: Print String$(N, 32);
For M = 1 To N
Print Mid$(A$, M, 1); " ";
_Delay .02
Next M: Print Mid$(A$, M): Next N
Loop Until InKey$ = Chr$(27)
Posts: 3,446
Threads: 376
Joined: Apr 2022
Reputation:
345
Wavy Words -- Steve Edition:
Code: (Select All)
Screen _NewImage(640, 480, 32)
WordScreen = _CopyImage(0)
$Color:32
font = _LoadFont("OLDENGL.ttf", 240)
_Dest WordScreen
_Font font
Locate 1, 1: Print "Hello";
Locate 2, 1: Print "World";
_Dest 0
WS_HW = _CopyImage(WordScreen, 33)
_PutImage , WS_HW
_Display
_DisplayOrder _Hardware
Do
wave = wave + .1
If wave > _Pi(2) Then wave = -_Pi(2)
x = x + 1
If x > 640 Then x = 0: _Display
_PutImage (x, 0 + Sin(wave) * 5)-Step(0, 480), WS_HW, , (x, 0)-Step(0, 480)
_Limit 6000
Loop Until _KeyHit
System
Posts: 688
Threads: 125
Joined: Apr 2022
Reputation:
49
10-08-2025, 06:36 PM
(This post was last modified: 10-08-2025, 06:36 PM by SierraKen.)
LOL Amazing Steve! It's so simple too, I'm stunned. lol I will have to use some of this code on wavey pictures or graphics, etc. And the use of fonts, I didn't know it was so easy. lol
Posts: 3,446
Threads: 376
Joined: Apr 2022
Reputation:
345
(10-08-2025, 06:36 PM)SierraKen Wrote: LOL Amazing Steve! It's so simple too, I'm stunned. lol I will have to use some of this code on wavey pictures or graphics, etc. And the use of fonts, I didn't know it was so easy. lol
You can honestly take out about half of it. I'm making it a hardware only screen there, just cause I was using a lot of CPU juice on my laptop and that chugs a lot of the processing into the GPU. On my laptop, running it as it is here, it uses all of 0% CPU... So less than 0.4% I suppose, which gets rounded down to nothing.
All we're basically doing is just a simple sine wave here to generate the waving motions. It really is quite a simple process. Adjust the math a little for bigger waves or longer waves or whatnot, as desired.
But run it and see what the CPU usage is for you. It should be almost nothing, since the vast majority of the work here is going to the hardware screen instead of anything software rendered.
Posts: 688
Threads: 125
Joined: Apr 2022
Reputation:
49
10-08-2025, 08:17 PM
(This post was last modified: 10-08-2025, 08:25 PM by SierraKen.)
I just modded yours to make different words appear from DATA lines. Took me awhile to figure out how to center any word$. It works, but when I do CTRL+ALT+DEL to see CPU usage, the program completely shuts down. So I tried it without the _DISPLAYORDER HARDWARE line and it still does the same thing. It's possible it's because nowadays I'm using a Mini-PC that doesn't have a video card. Intel made it so the video RAM is taken from the regular RAM. But feel free to try it. Otherwise it's fine. I also tested CTRL+ALT+DEL with other programs (with and without SCREEN) and it comes up fine those times. I'm guessing it has to do with the very high LIMIT number on here.
Code: (Select All)
'Thanks to Steve on QB64 Phoenix Edition forum for most of this code.
'This mod adds DATA words to change words.
Screen _NewImage(800, 600, 32)
WordScreen = _CopyImage(0)
$Color:32
font = _LoadFont("OLDENGL.ttf", 120)
_Dest WordScreen
_Font font
Do
If WS_HW <> 0 Then _FreeImage WS_HW
t = 0
tt = tt + 1
If tt = 12 Then 'There's 11 words in the DATA lines. Change for your own amount of words.
Restore words
tt = 1
End If
Read word$
Cls
L = Len(word$)
ll = 60 * L 'Half of the font size I'm using equals 60.
_PrintString (400 - (ll / 2), 1), word$
WS_HW = _CopyImage(WordScreen, 33)
_PutImage , WS_HW
_Display
_DisplayOrder _Hardware
Do
t = t + 1
wave = wave + .1
If wave > _Pi(2) Then wave = -_Pi(2)
x = x + 1
If x > 800 Then x = 0: _Display
_PutImage (x, 0 + Sin(wave) * 5)-Step(0, 600), WS_HW, , (x, 0)-Step(0, 600)
_Limit 6000
Loop Until t = 12000
Loop Until _KeyHit
System
words:
Data "Hello","my","name","is","SierraKen"
Data "I","program","in","QB64","Phoenix","Edition"
Posts: 3,446
Threads: 376
Joined: Apr 2022
Reputation:
345
Maybe try starting task manager first, then run it, then swap to task manager for cpu usage?
Posts: 688
Threads: 125
Joined: Apr 2022
Reputation:
49
Thanks, that works. I got around 1 to 3% CPU usage on it and 64.5 MB RAM. Which is odd because this CPU usage is very small compared to usual programs.
Posts: 3,446
Threads: 376
Joined: Apr 2022
Reputation:
345
(10-08-2025, 08:44 PM)SierraKen Wrote: Thanks, that works. I got around 1 to 3% CPU usage on it and 64.5 MB RAM. Which is odd because this CPU usage is very small compared to usual programs.
No software screen, no software rendering. It's all hardware images.
Posts: 4,692
Threads: 222
Joined: Apr 2022
Reputation:
322
Here is another way
Code: (Select All) _Title "Wavy Words, press escape to quit..." 'bplus mod 2025-10-08
Screen _NewImage(640, 400, 32): _ScreenMove 300, 150
_PrintMode _KeepBackground
p$ = "H.e.l.l.o...Q.B.6.4.P.E...W.o.r.l.d.!...H.e.l.l.o...Q.B.6.4.P.E...W.o.r.l.d.!.."
da = .01
Do
For y = 0 To 400
Line (0, y)-(640, y), _RGB32(255 - 300 * y / 400, 255 - 300 * y / 400, 255 - 255 * y / 400)
Next
For j = 0 To 16
Color _RGB32(255 - 32 * j, 255 - 32 * j, 255 - 16 * j)
For l = 1 To Len(p$)
_PrintString (l * 8, 184 + 32 * Sin(l / 10 + a) + j * 16), Mid$(p$, l, 1)
Next
Next
_Display: _Limit 200: a = a + da
Loop Until _KeyDown(27)
724 855 599 923 575 468 400 206 147 564 878 823 652 556 bxor cross forever
Posts: 688
Threads: 125
Joined: Apr 2022
Reputation:
49
Incredible Bplus. Yours doesn't even capture the screen and moves perfectly.
|