QB64 Phoenix Edition
A Screensaver - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Utilities (https://qb64phoenix.com/forum/forumdisplay.php?fid=8)
+---- Thread: A Screensaver (/showthread.php?tid=3450)

Pages: 1 2


A Screensaver - SMcNeill - 02-07-2025

I guess this would be a screensaver.  As you guys can probably guess from some of the code that I've been sharing over the last few days, I've just been playing around at tossing different things at a program and seeing what sticks.  I'm not really doing anything by goofing off, but I guess this would be similar to the Windows Mystify Screensaver, if anyone is interested in it.

Code: (Select All)
Screen _NewImage(800, 600, 32)
_FullScreen
Dim x1, y1, x2, y2 As Integer
Dim dx1, dy1, dx2, dy2 As Integer
Dim r, g, b As Integer

' Initialize coordinates and directions
x1 = Int(Rnd * 800): y1 = Int(Rnd * 600)
x2 = Int(Rnd * 800): y2 = Int(Rnd * 600)
dx1 = 5: dy1 = 8: dx2 = -5: dy2 = -8

Do
r = Int(Rnd * 256): g = Int(Rnd * 256): b = Int(Rnd * 256): a = Int(Rnd * 256)
Line (x1, y1)-(x2, y2), _RGBA32(r, g, b, a)

' Update coordinates
x1 = x1 + dx1: y1 = y1 + dy1: x2 = x2 + dx2: y2 = y2 + dy2

' Bounce off the edges of the screen
If x1 <= 0 Or x1 >= 800 Then dx1 = -dx1
If y1 <= 0 Or y1 >= 600 Then dy1 = -dy1
If x2 <= 0 Or x2 >= 800 Then dx2 = -dx2
If y2 <= 0 Or y2 >= 600 Then dy2 = -dy2
Line (0, 0)-(_Width, _Height), &H10000020&&, BF
_Display
_Limit 60
Loop Until InKey$ <> ""
System



It might need a few more lines to it to be a better replica, but it certainly seems to be on the right track to being something similar.  Feel free to play with it and modify it as wanted for your own enjoyment.  Wink


RE: A Screensaver - dbox - 02-07-2025

Classic, and you can play that one right from the browser:



RE: A Screensaver - bplus - 02-07-2025

And you can see a more realistic Mystify as my first post in Screen savers.
https://qb64phoenix.com/forum/showthread.php?tid=219&pid=898#pid898


RE: A Screensaver - Pete - 02-07-2025

Wow Mark, that's really cool! +2!

Pete Wink


RE: A Screensaver - SMcNeill - 02-07-2025

An updated version which I guess I'd call a simple "Dancing Triangle":

Code: (Select All)
Screen _NewImage(800, 600, 32)
_FullScreen
Dim x1, y1, x2, y2, x3, y3
Dim dx1, dy1, dx2, dy2, dx3, dy3
Dim r, g, b As Integer

' Initialize coordinates and directions
x1 = Int(Rnd * 800): y1 = Int(Rnd * 600)
x2 = Int(Rnd * 800): y2 = Int(Rnd * 600)
x3 = Int(Rnd * 800): y3 = Int(Rnd * 600)
dx1 = 5: dy1 = 8: dx2 = -5: dy2 = -8: dx3 = 2: dy3 = 3

Do
    r = Int(Rnd * 256): g = Int(Rnd * 256): b = Int(Rnd * 256): a = Int(Rnd * 256)
    Line (x1, y1)-(x2, y2), _RGBA32(r, g, b, a)
    Line -(x3, y3), _RGBA(r, g, b, a)
    Line -(x1, y1), _RGBA(r, g, b, a)

    ' Update coordinates
    x1 = x1 + dx1: y1 = y1 + dy1: x2 = x2 + dx2: y2 = y2 + dy2: x3 = x3 + dx3: y3 = y3 + dy3

    ' Bounce off the edges of the screen
    If x1 <= 0 Or x1 >= 800 Then dx1 = -dx1
    If y1 <= 0 Or y1 >= 600 Then dy1 = -dy1
    If x2 <= 0 Or x2 >= 800 Then dx2 = -dx2
    If y2 <= 0 Or y2 >= 600 Then dy2 = -dy2
    If x3 <= 0 Or x3 >= 800 Then dx3 = -dx3
    If y3 <= 0 Or y3 >= 600 Then dy3 = -dy3

    Line (0, 0)-(_Width, _Height), &H10000020&&, BF
    _Display
    _Limit 60
Loop Until InKey$ <> ""
System

For just goofing and wasting time, that's not an overall bad effect for such simple little code.  Smile


RE: A Screensaver - Pete - 02-07-2025

I think you made a minor goof on this line...

Dim x1, y1, x2, y2, x3, y2 As Integer 

You don't need two types of y2.

-1 (Just kidding!)

Pete Big Grin


RE: A Screensaver - SMcNeill - 02-07-2025

I don't know whatchu talking 'bout, Willis!!

Tongue


RE: A Screensaver - Pete - 02-07-2025

Nice edit, Steve... Urkel!

[Image: d854570a0b893bf2fadb65f81b63159b.jpg]

Pete Big Grin


RE: A Screensaver - SMcNeill - 02-07-2025

You got the wrong reference.  Big Grin




RE: A Screensaver - Pete - 02-07-2025

I've seen both shows. Unfortunately, there was no funny retort associated with Colman's show, so I outsourced to another network, and used a character from Family Matters, Steve Urkel.

Pete Big Grin